处理和转换osxcollector输出的筛选器
osxcollector-output-filters的Python项目详细描述
OSXcollector输出过滤器c65637446f725f6f75747075745f66696c746572732e7376673f6272616e63683d6d6173746572" />
osxcollector.output_filters
包包含处理和转换osxcollector输出的筛选器。过滤器的目标是使分析OSxCollector输出变得容易。
每个过滤器都有一个用途。他们只做一件事,而且做得对。
在virtualenv中运行筛选器
与osxcollector.py不同的是,过滤器具有尚未安装在新Mac上的依赖项。确保找到依赖关系的最佳解决方案是使用virtualenv。
要首次设置virtualenv,请使用:
$ sudo pip install tox virtualenv $ make venv $ source virtualenv_run/bin/activate # Not necessary if you use aactivator
过滤器配置
许多过滤器需要配置,比如api密钥或黑名单上的详细信息。过滤器的配置在yaml文件中完成。文件名为osxcollector.yaml
。筛选器将在中查找配置文件:
- 当前目录。
- 用户的主目录。
- 环境变量osxcollector_conf指向的路径
包含一个示例配置。复制一份,然后修改是否为您自己:
$ cp osxcollector.yaml.example osxcollector.yaml $ emacs osxcollector.yaml
基本过滤器
使用这些基本过滤器的组合,分析员可以在没有昂贵工具、没有威胁源或花哨的api的情况下找出发生的许多事情。
finddomainsfilter
osxcollector.output_filters.find_domains.finddomainsfilter
尝试在osxcollector输出中查找域名。域用键osxcollector_domains
添加到行中。
finddomainsfilter本身并不太有用,但是当它与诸如findblacklistedfilter
和或osxcollector.output\u filters.virustotal.lookup\u domains.lookupdomainsfilter
之类的过滤器链接时,它的功能非常强大。
若要运行并查看已添加域的行,请尝试:
$ python -m osxcollector.output_filters.find_domains -i RomeoCredible.json |\ jq 'select(has("osxcollector_domains"))'
用法:
$ python -m osxcollector.output_filters.find_domains -h usage: find_domains.py [-h][--input-file INPUT_FILE] optional arguments: -h, --help show this help message and exit --input-file INPUT_FILE [OPTIONAL] Path to OSXCollector output to read. Defaults to stdin otherwise.
findblacklistedfilter
osxcollector.output_filters.find_blacklisted.findblacklistedfilter
从osxcollector.yaml
读取一组黑名单,并用黑名单上的值标记任何行。BlackListFilter非常灵活,允许您将OSxCollector输出与多个黑名单进行比较。
你真的应该为域、文件哈希、文件名和任何已知的小东西创建黑名单。
配置键:
黑名单u name
:[必需]黑名单的名称。黑名单键
:[必需]获取这些键的值并与黑名单进行比较。它们的形式可以是a.b
查看{"a":{"b":"foo"}
中的黑名单文件路径
:[必需]具有黑名单实际值的文件路径黑名单是regex
:[必需]如果黑名单文件中的值被视为regex黑名单是域
:[可选]将值解释为域,并使用它们执行一些智能regex和子域操作。
b
。
如果要查找黑名单域,则必须使用"查找域"筛选器首先将这些域拉出。要查看与名为域的特定黑名单匹配的行,请尝试:
$ python -m osxcollector.output_filters.find_domains -i RiddlerBelize.json |\ python -m osxcollector.output_filters.find_blacklisted |\ jq 'select(has("osxcollector_blacklist")) | \ select(.osxcollector_blacklist | keys[] | contains("domains"))'
用法:
$ python -m osxcollector.output_filters.find_blacklisted -h usage: find_blacklisted.py [-h][--input-file INPUT_FILE] optional arguments: -h, --help show this help message and exit --input-file INPUT_FILE [OPTIONAL] Path to OSXCollector output to read. Defaults to stdin otherwise.
相关文件筛选器
osxcollector.output_filters.related_files.relatedfilesfilter
接受一组初始文件路径、名称或术语。它将此输入分解为单独的文件名和目录名,然后在整个osxcollector输出中搜索这些术语。过滤器是智能的,它会忽略诸如bin
或library
之类的常用术语以及忽略用户名。
这个过滤器非常适合于找出如何在机器上登陆。它可以找到与文件相关的浏览器历史记录、隔离、电子邮件等。
要运行并查看相关行,请尝试:
$ python -m osxcollector.output_filters.related_files -i CanisAsp.json -f '/foo/bar/baz' -f 'dingle'|\ jq 'select(has("osxcollector_related")) | \ select(.osxcollector_related | keys[] | contains("files"))'
用法:
$ python -m osxcollector.output_filters.related_files -h usage: related_files.py [-h][-f FILE_TERMS][--input-file INPUT_FILE] optional arguments: -h, --help show this help message and exit --input-file INPUT_FILE [OPTIONAL] Path to OSXCollector output to read. Defaults to stdin otherwise. RelatedFilesFilter: -f FILE_TERMS, --file-term FILE_TERMS [OPTIONAL] Suspicious terms to use in pivoting through file names. May be specified more than once.
铬合金过滤器
osxcollector.output_filters.chrome.sort_history.sorthistoryfilter
构建一个按时间降序排序的非常好的chrome浏览器历史记录。此输出类似于在浏览器中查看"历史记录"选项卡,但实际上包含更多信息。core_transition
和page_transition
键解释用户是否通过单击链接、通过重定向、隐藏的iframe等到达页面。
运行并查看Chrome浏览器历史记录:
$ python -m osxcollector.output_filters.chrome.sort_history -i SirCray.json |\ jq 'select(.osxcollector_browser_history=="chrome")'
这是一个很好的混合grep在某个特定的时间窗口,可能是5分钟前,那不正常的下载发生。
$ sudo pip install tox virtualenv $ make venv $ source virtualenv_run/bin/activate # Not necessary if you use aactivator0
用法:
$ sudo pip install tox virtualenv $ make venv $ source virtualenv_run/bin/activate # Not necessary if you use aactivator1
firefoxhistoryfilter
osxcollector.output\u filters.firefox.sort\u history.sorthistoryfilter
构建一个按时间降序排序的非常好的firefox浏览器历史记录。它很像chromehistoryfilter。
运行并查看Firefox浏览器历史记录:
$ sudo pip install tox virtualenv $ make venv $ source virtualenv_run/bin/activate # Not necessary if you use aactivator2
用法:
$ sudo pip install tox virtualenv $ make venv $ source virtualenv_run/bin/activate # Not necessary if you use aactivator3
色度延伸过滤器
osxcollector.output_filters.chrome.find_extensions.findextensionsfilter
在chrome json文件中查找扩展名。
运行并查看chrome扩展:
$ sudo pip install tox virtualenv $ make venv $ source virtualenv_run/bin/activate # Not necessary if you use aactivator4
用法:
$ sudo pip install tox virtualenv $ make venv $ source virtualenv_run/bin/activate # Not necessary if you use aactivator5
FirefoxExtensionsFilter
osxcollector.output_filters.firefox.find_extensions.findextensionsfilter
在firefox json文件中查找扩展名。
运行并查看Firefox扩展:
$ sudo pip install tox virtualenv $ make venv $ source virtualenv_run/bin/activate # Not necessary if you use aactivator6
用法:
$ sudo pip install tox virtualenv $ make venv $ source virtualenv_run/bin/activate # Not necessary if you use aactivator7
威胁API过滤器
通过获取osxcollector的输出并使用opendns和virustotalapi查找更多信息,yelp使用有用的信息增强了输出。有些api不是免费的,但它们很有用。
以这些过滤器为例,可以与额外的免费或高级威胁api集成。osxcollector.output\u filters.base\u filters.threat\feed.threatfeedfilter
具有连接任意api的大部分管道。
OpenDNS相关域筛选器
osxcollector.output_filters.opendns.related_domains.relateddomainsfilter
获取一组初始域和IP,然后使用OpenDNS伞形API查找与其相关的域。
通常,初始警报包含您的分析人员不知道的域或IP。然而,通过收集与第二代相关的域,可能会出现熟悉的朋友。当你幸运的时候,那些相关的域名会成为你可能忽略的下载源。
如果域位于名为domain\u whitelist
的黑名单中,则筛选器将忽略这些域。这有助于减少客户流失和误报。
按原样运行并查看找到的内容:
$ sudo pip install tox virtualenv $ make venv $ source virtualenv_run/bin/activate # Not necessary if you use aactivator8
结果如下:
$ sudo pip install tox virtualenv $ make venv $ source virtualenv_run/bin/activate # Not necessary if you use aactivator9
用法:
$ cp osxcollector.yaml.example osxcollector.yaml $ emacs osxcollector.yaml0
OpenDNS查找域筛选器
osxcollector.output_filters.opendns.lookup_domains.lookupdomainsfilter
使用opendns伞形api查找域信誉和威胁信息。它将有关可疑域的信息添加到输出行。
过滤器使用启发式来确定什么是可疑的。它可以产生误报,但通常从标记为可疑的域下载是一个很好的方法广告
运行它并查看找到了什么:
$ cp osxcollector.yaml.example osxcollector.yaml $ emacs osxcollector.yaml1
用法:
$ cp osxcollector.yaml.example osxcollector.yaml $ emacs osxcollector.yaml2
虚拟总体查找域筛选器
osxcollector.output_filters.virustotal.lookup_domains.lookupdomainsfilter
使用virustotal api查找域信誉和威胁信息。它将有关可疑域的信息添加到输出行。它很像同名的opendns过滤器。
过滤器使用启发式来确定什么是可疑的。它可以产生许多误报,但也提供了良好的线索。
运行它并查看找到了什么:
$ cp osxcollector.yaml.example osxcollector.yaml $ emacs osxcollector.yaml3
用法:
$ cp osxcollector.yaml.example osxcollector.yaml $ emacs osxcollector.yaml4
virustotal lookuphashesfilter
osxcollector.output_filters.virustotal.lookup_hashes.lookuphashesfilter
使用virustotal api查找哈希。这基本上可以找到virustotal知道的任何可以节省大量时间的东西。这里几乎没有误报,但也没有机会发现未知的东西。
运行它并查看找到了什么:
$ cp osxcollector.yaml.example osxcollector.yaml $ emacs osxcollector.yaml5
用法:
$ cp osxcollector.yaml.example osxcollector.yaml $ emacs osxcollector.yaml6
virustotal lookupurlsfilter
osxcollector.output_filters.virustotal.lookup_hashes.lookupurlsfilter
使用virustotal API查找URL。由于它只查找报告,因此可能找不到某些未知URL的报告。
运行它并查看找到了什么:
$ cp osxcollector.yaml.example osxcollector.yaml $ emacs osxcollector.yaml7
用法< /P>
$ cp osxcollector.yaml.example osxcollector.yaml $ emacs osxcollector.yaml8
每个请求的最大资源
virustotal lookuphashesfilter和lookupurlsfilter都可以通过在单个api请求中包含多个资源(散列或url)的报告来节省时间。
由于请求中的最大资源数取决于您使用的是公共还是私有api密钥,因此可以在virustotal
部分的osxcollector.yaml
文件中配置它:
$ cp osxcollector.yaml.example osxcollector.yaml $ emacs osxcollector.yaml9
shadowserver lookuphashesfilter
osxcollector.output\u filters.shadowserver.lookup\u hashes.lookuphashesfilter
使用shadowserver bin测试api进行查找散列。这有点与virustotal查找相反,当它看到已知良好文件的散列时返回结果。这有助于提高对文件不是恶意文件的信心。
运行它并查看找到了什么:
$ python -m osxcollector.output_filters.find_domains -i RomeoCredible.json |\ jq 'select(has("osxcollector_domains"))'0
用法:
$ python -m osxcollector.output_filters.find_domains -i RomeoCredible.json |\ jq 'select(has("osxcollector_domains"))'1
analyzefilter-一个将它们全部规则化的过滤器
osxcollector.output_filter s.analyze.analyze filter
是yelp的一个过滤器,用来控制所有的过滤器。它将之前的所有过滤器链接到一个怪物分析中。通过黑名单信息、威胁API、相关文件和域,甚至漂亮的浏览器历史记录,这些结果都会被写入一个新的输出文件。
然后,非常可读的输出bot接管并打印出一个简单易懂的、人类可读的、几乎是英文的摘要。基本上等同于跑步:
$ python -m osxcollector.output_filters.find_domains -i RomeoCredible.json |\ jq 'select(has("osxcollector_domains"))'2
然后让一个聪明的分析员向你解释结果。非常可读的输出bot甚至建议将散列和域添加到黑名单中。
这才是真正的问题,我们的分析人员在运行analyzefilter
之后才会查看osxcollector的输出。
运行方式:
$ python -m osxcollector.output_filters.find_domains -i RomeoCredible.json |\ jq 'select(has("osxcollector_domains"))'3
用法:
$ python -m osxcollector.output_filters.find_domains -i RomeoCredible.json |\ jq 'select(has("osxcollector_domains"))'4
对OSxCollector输出过滤器的贡献
我们鼓励您扩展osxcollector的功能以满足您的需要。
测试OSxCollector输出过滤器
osxcollector输出过滤器的测试集合在tests
目录下提供。为了运行这些测试,您必须安装tox
$ python -m osxcollector.output_filters.find_domains -i RomeoCredible.json |\ jq 'select(has("osxcollector_domains"))'5
要运行这套测试,请将cd
插入osxcollector
并输入:
$ python -m osxcollector.output_filters.find_domains -i RomeoCredible.json |\ jq 'select(has("osxcollector_domains"))'6
开发技巧
在编辑源代码之前,请确保所有osxcollector输出筛选器测试都通过。您可以使用:进行测试
对源代码进行更改后,再次运行make test
以验证您的更改没有破坏测试。
许可证
这项工作是根据GNU通用公共许可证授权的。