opensnitch:更改 "process.path" 规则以匹配命令参数

opensnitch: changing a "process.path" rule to match command args

Opensnitch 介绍

opensnitch is an open-source security tool modeled after the MAC OS-X littlesnitch 应用

我一直在桌面上使用 Gustavo Iniguez Goya 的 opensnitch 分支(这是对 Simone Margaritelli 最初的伟大开创性工作的重大改进)来根据规则限制传出连接。目标是加强传出网络安全,例如捕获恶意软件或限制某些“phone-home”应用程序与外界通信。

Configuration/rules

/etc/opensnitchd/rules 下创建的驱动 opensnitch 的默认规则存储为 *.json 个文件,每个规则一个文件。当我使用 UI 添加规则时,会创建一个新的 *.json 规则文件。

规则示例(为简洁起见进行了删减):

{
  "name": "allow-always-simple-usrbinpython",
  "enabled": true,
  "action": "allow",
  "duration": "always",
  "operator": {
    "type": "simple",
    "operand": "process.path",
    "data": "/usr/bin/python",
  }
}

问题

这些规则在 UI 中设置时可能过于粗略。例如当我允许我写的某个脚本与外界对话时,该可执行文件恰好是在 python 中编写的,选择 可执行文件 选项并单击 允许,我无意中允许任何python脚本与外界对话。

在网上搜索,我找到了一个 nice overview of opensnich,它缺少如何在 *.json 中直接指定连接规则的详细信息,并匹配完整的命令行,并附有示例。

问题:

Is it possible to limit such rule and allow running only a certain executable script (1st arg to /usr/bin/python) ?

您可以select选项“从此命令行”来过滤整个命令。

More generally: what would be the syntax, with an example, for an AND conjunction in the rule, and a clause for a regex-match vs. other arguments of the command line or remote IP-addresses, or both?

查看文档(也许您已经做过...但以防万一):

https://github.com/gustavo-iniguez-goya/opensnitch/wiki/Rules https://github.com/gustavo-iniguez-goya/opensnitch/wiki/Rules-editor

例如,如果您想按特定 (python) 脚本进行过滤:

[x] 从这个命令行:“.*/usr/bin/dnsping.*

(顺便说一句,我们终于为原始仓库做出了贡献,因此您可以使用那里的最新版本)