处理和转换OSXCollector输出的过滤器
项目描述
OSXCollector输出过滤器

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_filters.virustotal.lookup_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
读取一组黑名单,并标记任何带有黑名单值的行。黑名单过滤器很灵活,允许您将OSXCollector输出与多个黑名单进行比较。
您真的应该为域名、文件哈希、文件名和任何已知可疑内容创建黑名单。
配置键
blacklist_name
: [必填]黑名单的名称。blacklist_keys
: [必填]获取这些键的值,并与黑名单进行比较。这些可以是a.b
的形式,用于查看{"a": {"b": "foo"}}
中的b
。blacklist_file_path
: [必填]带有实际要添加到黑名单中的值的文件的路径blacklist_is_regex
: [必填]黑名单文件中的值是否应被视为正则表达式blacklist_is_domains
: [可选]将值解释为域名,并使用它们进行一些智能正则表达式和子域操作。
如果您想查找被列入黑名单的域名,您将必须使用find_domains过滤器首先提取域名。要查看与特定黑名单domains
匹配的行,请尝试
$ 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.
RelatedFilesFilter
osxcollector.output_filters.related_files.RelatedFilesFilter
接受一组初始文件路径、名称或术语。它将此输入分解为单个文件和目录名称,然后在OSXCollector输出的整个范围内搜索这些术语。该过滤器很智能,会忽略常见的术语,如bin
或Library
,以及用户名。
此过滤器非常适合确定evil_invoice.pdf
是如何出现在计算机上的。它会找到与文件相关的浏览器历史记录、隔离区、电子邮件消息等。
要运行并查看相关行,请尝试
$ 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.
ChromeHistoryFilter
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")'
这与在特定时间窗口(例如,在可疑下载发生前5分钟)使用grep结合使用非常出色。
$ python -m osxcollector.output_filters.chrome.sort_history -i SirCray.json | \
jq -c 'select(.osxcollector_browser_history=="chrome")' | \
egrep '2015-02-02 20:3[2-6]'
用法
$ python -m osxcollector.output_filters.chrome.sort_history -h
usage: sort_history.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.
FirefoxHistoryFilter
osxcollector.output_filters.firefox.sort_history.SortHistoryFilter
构建了一个非常好的Firefox浏览器历史记录,按时间顺序降序排列。它与ChromeHistoryFilter
非常相似。
要运行并查看Firefox浏览器历史记录
$ python -m osxcollector.output_filters.firefox.sort_history -i CousingLobe.json | \
jq 'select(.osxcollector_browser_history=="firefox")'
用法
$ python -m osxcollector.output_filters.firefox.sort_history -h
usage: sort_history.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.
ChromeExtensionsFilter
osxcollector.output_filters.chrome.find_extensions.FindExtensionsFilter
在Chrome JSON文件中查找扩展。
要运行并查看Chrome扩展
$ python -m osxcollector.output_filters.chrome.find_extensions -i MotherlyWolf.json | \
jq 'select(.osxcollector_section=="chrome" and
.osxcollector_subsection=="extensions")'
用法
$ python -m osxcollector.output_filters.chrome.find_extensions -h
usage: find_extensions.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.
FirefoxExtensionsFilter
osxcollector.output_filters.firefox.find_extensions.FindExtensionsFilter
在Firefox JSON文件中查找扩展。
要运行并查看Firefox扩展
$ python -m osxcollector.output_filters.firefox.find_extensions -i FlawlessPelican.json | \
jq 'select(.osxcollector_section=="firefox" and
.osxcollector_subsection=="extensions")'
用法
$ python -m osxcollector.output_filters.firefox.find_extensions -h
usage: find_extensions.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.
威胁API过滤器
通过使用OpenDNS和VirusTotal API查找进一步的信息,Yelp增强了OSXCollector的输出,使其包含有用的信息。其中一些API不是免费的,但它们很有用。
使用这些过滤器作为示例,可以与额外的免费或付费威胁API集成。osxcollector.output_filters.base_filters.threat_feed.ThreatFeedFilter
已经为连接到任意API提供了大部分管道。
OpenDNS RelatedDomainsFilter
osxcollector.output_filters.opendns.related_domains.RelatedDomainsFilter
接收一组初始域名和IP,然后使用OpenDNS Umbrella API查找与它们相关的域名。
通常,一个初始警报包含分析员不熟悉的一个域名或IP。然而,通过收集第二代相关域名,熟悉的“朋友”可能会出现。当你幸运的时候,那些相关域名可能是你可能忽略的一些下载的下载源。
如果域名在名为domain_whitelist
的黑白名单中,该过滤器将忽略这些域名。这有助于减少波动和误报。
运行它并查看它发现了什么
$ python -m osxcollector.output_filters.find_domains -i NotchCherry.json | \
python -m osxcollector.output_filters.opendns.related_domains \
-d dismalhedgehog.com -d fantasticrabbit.org \
-i 128.128.128.28 | \
jq 'select(has("osxcollector_related")) |
select(.osxcollector_related | keys[] | contains("domains"))'
结果可能看起来像这样
{
'osxcollector_related': {
'domains': {
'domain_in_line.com': ['dismalhedgehog.com'],
'another.com': ['128.128.128.28']
}
}
}
用法
$ python -m osxcollector.output_filters.opendns.related_domains -h
usage: related_domains.py [-h] [-d INITIAL_DOMAINS] [-i INITIAL_IPS]
[--related-domains-generations GENERATIONS]
[--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.
opendns.RelatedDomainsFilter:
-d INITIAL_DOMAINS, --domain INITIAL_DOMAINS
[OPTIONAL] Suspicious domains to use in pivoting. May
be specified more than once.
-i INITIAL_IPS, --ip INITIAL_IPS
[OPTIONAL] Suspicious IP to use in pivoting. May be
specified more than once.
--related-domains-generations GENERATIONS
[OPTIONAL] How many generations of related domains to
lookup with OpenDNS
OpenDNS LookupDomainsFilter
osxcollector.output_filters.opendns.lookup_domains.LookupDomainsFilter
使用OpenDNS Umbrella API查找域名声誉和威胁信息。它将有关可疑域的信息添加到输出行。
该过滤器使用启发式算法来确定什么是可疑的。它可以创建误报,但通常来自标记为可疑的域的下载是一个好的线索。
运行它并查看它发现了什么
$ python -m osxcollector.output_filters.find_domains -i GladElegant.json | \
python -m osxcollector.output_filters.opendns.lookup_domains | \
jq 'select(has("osxcollector_opendns"))'
用法
$ python -m osxcollector.output_filters.opendns.lookup_domains -h
usage: lookup_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.
VirusTotal LookupDomainsFilter
osxcollector.output_filters.virustotal.lookup_domains.LookupDomainsFilter
使用VirusTotal API查找域名声誉和威胁信息。它将有关可疑域的信息添加到输出行。它与同名的OpenDNS过滤器非常相似。
该过滤器使用启发式算法来确定什么是可疑的。它可以创建很多误报,但也提供了很好的线索。
运行它并查看它发现了什么
$ python -m osxcollector.output_filters.find_domains -i PippinNightstar.json | \
python -m osxcollector.output_filters.virustotal.lookup_domains | \
jq 'select(has("osxcollector_vtdomain"))'
用法
$ python -m osxcollector.output_filters.virustotal.lookup_domains -h
usage: lookup_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.
VirusTotal LookupHashesFilter
osxcollector.output_filters.virustotal.lookup_hashes.LookupHashesFilter
使用VirusTotal API查找哈希值。这基本上找到了VirusTotal知道的所有内容,这可以节省大量时间。几乎不会有误报,但也没有检测未知内容的机会。
运行它并查看它发现了什么
$ python -m osxcollector.output_filters.virustotal.lookup_hashes -i FungalBuritto.json | \
jq 'select(has("osxcollector_vthash"))'
用法
$ python -m osxcollector.output_filters.virustotal.lookup_hashes -h
usage: lookup_hashes.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.
VirusTotal LookupURLsFilter
osxcollector.output_filters.virustotal.lookup_hashes.LookupURLsFilter
使用VirusTotal API查找URL。由于这仅查找报告,因此可能无法找到某些未知URL的报告。
运行它并查看它发现了什么
$ python -m osxcollector.output_filters.virustotal.lookup_urls -i WutheringLows.json | \
jq 'select(has("osxcollector_vturl"))'
用法
$ python -m osxcollector.output_filters.virustotal.lookup_urls -h
usage: lookup_urls.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.
每次请求的最大资源数
两者VirusTotal LookupHashesFilter和LookupURLsFilter都可以通过在单个API请求中包含多个资源(哈希或URL)的报告来节省时间。由于请求中最大资源数取决于你是否使用公共或私有API密钥,因此可以在osxcollector.yaml
文件中的virustotal
部分进行配置。
resources_per_req: 4
ShadowServer LookupHashesFilter
osxcollector.output_filters.shadowserver.lookup_hashes.LookupHashesFilter
使用ShadowServer bin-test API查找哈希值。这有点像是VirusTotal查找的反面,当它看到已知良好文件的哈希值时返回结果。这有助于提高文件不是恶意文件的信心。
运行它并查看它发现了什么
$ python -m osxcollector.output_filters.shadowserver.lookup_hashes -i ArkashKobiashi.json | \
jq 'select(has("osxcollector_shadowserver"))'
用法
$ python -m osxcollector.output_filters.shadowserver.lookup_hashes -h
usage: lookup_hashes.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.
AnalyzeFilter - 统治万物的过滤器
osxcollector.output_filters.analyze.AnalyzeFilter
是Yelp的统治万物的过滤器。它将所有之前的过滤器链接成一个巨大的分析。将增强的黑名单信息、威胁API、相关文件和域名,甚至漂亮的浏览器历史记录写入新的输出文件。
然后非常易读的输出机器人接管并打印出易于消化的、人类可读的、几乎像是英语的总结,说明了它发现了什么。这基本上相当于运行
$ python -m osxcollector.output_filters.chrome.find_extensions.FindExtensionsFilter -i SlickApocalypse.json | \
python -m osxcollector.output_filters.firefox.find_extensions.FindExtensionsFilter | \
python -m osxcollector.output_filters.find_domains | \
python -m osxcollector.output_filters.shadowserver.lookup_hashes | \
python -m osxcollector.output_filters.virustotal.lookup_hashes | \
python -m osxcollector.output_filters.find_blacklisted | \
python -m osxcollector.output_filters.related_files | \
python -m osxcollector.output_filters.opendns.related_domains | \
python -m osxcollector.output_filters.opendns.lookup_domains | \
python -m osxcollector.output_filters.virustotal.lookup_domains | \
python -m osxcollector.output_filters.chrome_history | \
python -m osxcollector.output_filters.firefox_history | \
tee analyze_SlickApocalypse.json | \
jq 'select(false == has("osxcollector_shadowserver")) |
select(has("osxcollector_vthash") or
has("osxcollector_vtdomain") or
has("osxcollector_opendns") or
has("osxcollector_blacklist") or
has("osxcollector_related"))'
然后让一个聪明的分析师向你解释结果。非常易读的输出机器人甚至建议要添加到黑名单中的哈希和域名。
这东西是真正的家伙,我们的分析师甚至直到运行了AnalyzeFilter
之后才看OSXCollector的输出。
运行它
$ python -m osxcollector.output_filters.analyze -i FullMonty.json
用法
$ python -m osxcollector.output_filters.analyze -h
usage: analyze.py [-f FILE_TERMS] [-d INITIAL_DOMAINS] [-i INITIAL_IPS]
[--related-domains-generations GENERATIONS] [-h] [--readout]
[--no-opendns] [--no-virustotal] [--no-shadowserver] [-M]
[--show-signature-chain] [--show-browser-ext]
[--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.
opendns.RelatedDomainsFilter:
-d INITIAL_DOMAINS, --domain INITIAL_DOMAINS
[OPTIONAL] Suspicious domains to use in pivoting. May
be specified more than once.
-i INITIAL_IPS, --ip INITIAL_IPS
[OPTIONAL] Suspicious IP to use in pivoting. May be
specified more than once.
--related-domains-generations GENERATIONS
[OPTIONAL] How many generations of related domains to
lookup with OpenDNS
AnalyzeFilter:
--readout [OPTIONAL] Skip the analysis and just output really
readable analysis
--no-opendns [OPTIONAL] Don't run OpenDNS filters
--no-virustotal [OPTIONAL] Don't run VirusTotal filters
--no-shadowserver [OPTIONAL] Don't run ShadowServer filters
-M, --monochrome [OPTIONAL] Output monochrome analysis
--show-signature-chain
[OPTIONAL] Output unsigned startup items and kexts.
--show-browser-ext [OPTIONAL] Output the list of installed browser
extensions.
为OSXCollector输出过滤器做出贡献
我们鼓励你扩展OSXCollector的功能以满足你的需求。
测试OSXCollector输出过滤器
在tests
目录下提供了一组用于OSXCollector输出过滤器的测试。为了运行这些测试,你必须安装tox
$ sudo pip install tox
要运行此测试套件,请使用 cd
命令进入 osxcollector
目录,然后输入
$ make test
开发技巧
在编辑源代码之前,请确保所有OSXCollector输出过滤器测试都通过。您可以使用以下命令运行测试:make test
在修改源代码后,再次运行 make test
命令以验证您的更改没有破坏任何测试。
许可证
本作品受GNU通用公共许可证的许可。
项目详情
下载文件
下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源代码分发
构建分发
osxcollector_output_filters-1.1.1.tar.gz的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | 1aa647a7a0a4d79929c51bec50dab692f6606fb373187d61443b9cd2cf67cde6 |
|
MD5 | a346cf3d31854cf90deafddd90d61401 |
|
BLAKE2b-256 | 3bd4d96cbde8df89d6d7a89c5fe7fdc7c6bedcba74df8def76f21ac960873f69 |
osxcollector_output_filters-1.1.1-py3-none-any.whl的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | f8d3be4e4bcc6dc6348d9b1cfb1dd5d6905a38adbb5190bded4d919dba590def |
|
MD5 | 1e9261542af6175c245fb641a83c7409 |
|
BLAKE2b-256 | 6b4e7254c4e6b4ff6900af9225715b14b5bf4635737666e58a32b3744990e393 |
osxcollector_output_filters-1.1.1-py2-none-any.whl的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | e6ecb880a37bea6523b2403afa7487a7081e94410fd7103d0baae181369820db |
|
MD5 | a8f29fa6f81a2d14c38092ba4a2eeb5c |
|
BLAKE2b-256 | 0baf6ed5e67a809612ca1887ec2b57339dd3a04d71e2bac4f935975a089682be |