项目地址
https://github.com/mgeeky/msidump
msidump
MSI Dump – 一种分析恶意 MSI 安装包、提取文件、流、二进制数据并集成 YARA 扫描程序的工具。
在启用宏的 Office 文档上,我们可以快速使用 oletools mraptor 来确定文档是否是恶意的。 如果我们想进一步剖析它,我们可以引入 oletools olevba 或 oledump 。
为了剖析恶意 MSI 文件,到目前为止,我们只有一个可靠且值得信赖 的 lessmsi 。 但是, lessmsi
没有实现我正在寻找的功能:
- 快速分类
- 二进制数据提取
- YARA扫描
因此,这就是 msidump
发挥作用的地方。
特征
此工具有助于快速分类以及详细检查恶意 MSI 语料库。 它让我们:
- 快速确定文件是否可疑。
- 列出所有 MSI 表以及转储特定记录
- 提取二进制数据,来自 CAB 的所有文件,来自 CustomActions 的脚本
- 使用 YARA 规则扫描所有内部数据和记录
- 使用
file
/MIME 类型推导来确定内部数据类型
它是作为我在此处发布的博客文章的配套工具创建的:
限制
- 该程序仍处于早期 alpha 版本,预计会出现问题,分类/解析逻辑会发生变化
- 由于此工具严重依赖 Win32 COM
WindowsInstaller.Installer
接口,目前 无法支持原生 Linux 平台。 也许wine python msidump.py
可以帮助,但还没有尝试过。
用例
- 对使用 YARA 规则增强的可疑 MSI 进行快速分类:
cmd> python msidump.py evil.msi -y rules.yara
在这里我们可以看到输入 MSI 注入了可疑的 VBScript ,并且其中包含大量可执行文件。
- 现在我们想通过仅提取该记录来更仔细地查看此 VBScript。
我们从分类表中看到它存在于 Binary
表中。 让我们得到他:
python msidump.py putty-backdoored.msi -l binary -i UBXtHArj
我们可以通过其名称/ID 或其索引号(此处为 7)来指定记录转储。
让我们看另一个例子。 这次有可执行文件存储在 Binary
表中,将在安装期间执行:
要提取该文件,我们将使用
python msidump.py evil2.msi -x binary -i lmskBju -O extracted
在哪里
-x binary
告诉提取Binary
表的内容-i lmskBju
指定要提取的记录-O extracted
设置输出目录
为获得最佳输出体验,请在最大化的控制台窗口 上运行该工具 或将输出重定向到文件:
python msidump.py [...] -o analysis.log
完全使用
PS D:\> python .\msidump.py --help
options:
-h, --help show this help message and exit
Required arguments:
infile Input MSI file (or directory) for analysis.
Options:
-q, --quiet Surpress banner and unnecessary information. In triage mode, will display only verdict.
-v, --verbose Verbose mode.
-d, --debug Debug mode.
-N, --nocolor Dont use colors in text output.
-n PRINT_LEN, --print-len PRINT_LEN
When previewing data - how many bytes to include in preview/hexdump. Default: 128
-f {text,json,csv}, --format {text,json,csv}
Output format: text, json, csv. Default: text
-o path, --outfile path
Redirect program output to this file.
-m, --mime When sniffing inner data type, report MIME types
Analysis Modes:
-l what, --list what List specific table contents. See help message to learn what can be listed.
-x what, --extract what
Extract data from MSI. For what can be extracted, refer to help message.
Analysis Specific options:
-i number|name, --record number|name
Can be a number or name. In --list mode, specifies which record to dump/display entirely. In --extract mode dumps only this particular record to --outdir
-O path, --outdir path
When --extract mode is used, specifies output location where to extract data.
-y path, --yara path Path to YARA rule/directory with rules. YARA will be matched against Binary data, streams and inner files
------------------------------------------------------
- What can be listed:
--list CustomAction - Specific table
--list stats - Print MSI database statistics
--list all - All tables and their contents
--list olestream - Prints all OLE streams & storages.
To display CABs embedded in MSI try: --list _Streams
--list cabs - Lists embedded CAB files
--list binary - Lists binary data embedded in MSI for its own purposes.
That typically includes EXEs, DLLs, VBS/JS scripts, etc
- What can be extracted:
--extract all - Extracts Binary data, all files from CABs, scripts from CustomActions
--extract binary - Extracts Binary data
--extract files - Extracts files
--extract cabs - Extracts cabinets
--extract scripts - Extracts scripts
------------------------------------------------------
TODO
- 分类逻辑仍然有点古怪,我对此并不感到自豪。 因此,它将受到不断的重新设计和进一步的影响
- 添加更多输出格式:CSV、JSON
- 在更广泛的测试样本语料库上进行测试
- 添加对带密码的输入 ZIP 存档的支持
- 添加对摄取充满 YARA 规则的整个目录的支持,而不是仅处理单个文件
CustomAction Type
目前,该工具基于评估其数量来 匹配恶意s,这很容易被规避。- 它需要重新设计以正确使用类型编号并将其分解为 flag
没有回复内容