XLM宏反混淆器
XLMMacroDeobfuscator可用于解码模糊的XLM宏(也称为Excel 4.0宏)。它利用内部XLM仿真器来解释宏,而无需完全执行代码。
它同时支持xls,xlsm和xlsb格式。
它使用xlrd2,pyxlsb2和它自己的解析器分别从xls,xlsb和xlsm文件中提取单元格和其他信息。
您还可以在xlm-macro-en.lark中找到XLM语法
安装仿真器
使用pip安装
pip install XLMMacroDeobfuscator
安装最新开发
pip install -U https://github.com/DissectMalware/xlrd2/archive/master.zip
pip install -U https://github.com/DissectMalware/pyxlsb2/archive/master.zip
pip install -U https://github.com/DissectMalware/XLMMacroDeobfuscator/archive/master.zip
运行模拟器
要对Excel文档中的宏进行模糊处理:
xlmdeobfuscator --file document.xlsm
要仅获取经过模糊处理的宏,并且没有任何缩进,请执行以下操作:
xlmdeobfuscator --file document.xlsm --no-indent --output-formula-format "[[INT-FORMULA]]"
以JSON格式导出输出
xlmdeobfuscator --file document.xlsm --export-json result.json
要查看示例JSON输出,请查看此链接。
使用配置文件
xlmdeobfuscator --file document.xlsm -c default.config
default.config文件必须是有效的json文件,例如:
{“ no-indent ”:true,“ output-formula-format ”:“ [[CELL-ADDR]] [[INT-FORMULA]] ”,“ non-interactive ”:true,“ output-level ”:1
}
命令行
_ _______
|\ /|( \ ( )
( \ / )| ( | () () |
\ (_) / | | | || || |
) _ ( | | | |(_)| |
/ ( ) \ | | | | | |
( / \ )| (____/\| ) ( |
|/ \|(_______/|/ \|
______ _______ _______ ______ _______ _______ _______ _______ _________ _______ _______
( __ \ ( ____ \( ___ )( ___ \ ( ____ \|\ /|( ____ \( ____ \( ___ )\__ __/( ___ )( ____ )
| ( \ )| ( \/| ( ) || ( ) )| ( \/| ) ( || ( \/| ( \/| ( ) | ) ( | ( ) || ( )|
| | ) || (__ | | | || (__/ / | (__ | | | || (_____ | | | (___) | | | | | | || (____)|
| | | || __) | | | || __ ( | __) | | | |(_____ )| | | ___ | | | | | | || __)
| | ) || ( | | | || ( \ \ | ( | | | | ) || | | ( ) | | | | | | || (\ (
| (__/ )| (____/\| (___) || )___) )| ) | (___) |/\____) || (____/\| ) ( | | | | (___) || ) \ \__
(______/ (_______/(_______)|/ \___/ |/ (_______)\_______)(_______/|/ \| )_( (_______)|/ \__/
XLMMacroDeobfuscator(v0.1.5) - https://github.com/DissectMalware/XLMMacroDeobfuscator
usage: deobfuscator.py [-h] [-c FILE_PATH] [-f FILE_PATH] [-n] [-x] [-2]
[--with-ms-excel] [-s] [-d DAY]
[--output-formula-format OUTPUT_FORMULA_FORMAT]
[--no-indent] [--export-json FILE_PATH]
[--start-point CELL_ADDR] [-p PASSWORD]
[-o OUTPUT_LEVEL]
optional arguments:
-h, --help show this help message and exit
-c FILE_PATH, --config_file FILE_PATH
Specify a config file (must be a valid JSON file)
-f FILE_PATH, --file FILE_PATH
The path of a XLSM file
-n, --noninteractive Disable interactive shell
-x, --extract-only Only extract cells without any emulation
-2, --no-ms-excel [Deprecated] Do not use MS Excel to process XLS files
--with-ms-excel Use MS Excel to process XLS files
-s, --start-with-shell
Open an XLM shell before interpreting the macros in
the input
-d DAY, --day DAY Specify the day of month
--output-formula-format OUTPUT_FORMULA_FORMAT
Specify the format for output formulas ([[CELL-ADDR]],
[[INT-FORMULA]], and [[STATUS]]
--no-indent Do not show indent before formulas
--export-json FILE_PATH
Export the output to JSON
--start-point CELL_ADDR
Start interpretation from a specific cell address
-p PASSWORD, --password PASSWORD
Password to decrypt the protected document
-o OUTPUT_LEVEL, --output-level OUTPUT_LEVEL
Set the level of details to be shown (0:all commands,
1: commands no jump 2:important commands 3:strings in
important commands).
图书馆
以下示例显示了如何在python项目中使用XLMMacroDeobfuscator来对XLM宏进行反模糊处理:
from XLMMacroDeobfuscator.deobfuscator import process_file
result = process_file(file='path/to/an/excel/file',
noninteractive= True,noindent= True,output_formula_format='[[CELL_ADDR]], [[INT-FORMULA]]',return_deobfuscated= True)for record in result:print(record)
注意:xlmdeofuscator徽标用作库时不会显示
要求
请阅读requirements.txt以获得XLMMacroDeobfuscator所依赖的python库列表。
可以在任何操作系统上执行xlmdeobfuscator,以提取和反模糊xls,xlsm和xlsb文件中的宏。您不需要安装MS Excel。
注意:如果要使用MS Excel(在Windows上),则需要安装pywin32库并使用--with-ms-excel开关。如果使用--with-ms-excel,则xlmdeobfuscator首先尝试使用MS Excel加载xls文件,如果失败,则使用xlrd2库。
项目地址:
https://github.com/DissectMalware/XLMMacroDeobfuscator/