XLMMacroDeobfuscator
XLMMacroDeobfuscator 可用于解码混淆的 XLM 宏(也称为 Excel 4.0 宏)。它利用内部 XLM 仿真器来解释宏,而无需完全执行代码。
它支持 xls、xlsm 和 xlsb 格式。
它使用xlrd2、pyxlsb2和它自己的解析器分别从 xls、xlsb 和 xlsm 文件中提取单元格和其他信息。
您还可以在xlm-macro-lark.template中找到 XLM 语法。
安装模拟器
使用 pip 安装
pip install XLMMacroDeobfuscator --force
安装最新的开发pip install -U https://github.com/DissectMalware/XLMMacroDeobfuscator/archive/master.zip --force
运行
要对 Excel 文档中的宏进行去混淆处理
xlmdeobfuscator --file document.xlsm
仅提取 Excel 文档中的宏(不进行任何反混淆)
xlmdeobfuscator --file document.xlsm -x
只获取去混淆的宏并且没有任何缩进
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}
命令行
```shell
_ _______
|\ /|( \ ( ) ( \ / )| ( | () () | \ () / | | | || || | ) ( | | | |()| | / ( ) \ | | | | | | ( / \ )| (/| ) ( | |/ |(__/|/ |
( \ ( __ ( )( \ ( |\ /|( ( _ ( )_ /( )( __ ) | ( \ )| ( \/| ( ) || ( ) )| ( \/| ) ( || ( \/| ( \/| ( ) | ) ( | ( ) || ( )| | | ) || ( | | | || (/ / | ( | | | || (_ | | | () | | | | | | || (_)| | | | || ) | | | || ( | ) | | | |(_ )| | | _ | | | | | | || ) | | ) || ( | | | || ( \ \ | ( | | | | ) || | | ( ) | | | | | | || (\ ( | (/ )| (__/| () || )) )| ) | () |/_) || (_/| ) ( | | | | () || ) \ _ (__/ (__/(_)|/ _/ |/ (_)___)(_/|/ | )( (__)|/ __/
XLMMacroDeobfuscator(v0.2.0) - https://github.com/DissectMalware/XLMMacroDeobfuscator
Error: —file is missing
usage: deobfuscator.py [-h] [-c FILE_PATH] [-f FILE_PATH] [-n] [-x] [—sort-formulas] [—defined-names] [-2] [—with-ms-excel] [-s] [-d DAY] [—output-formula-format OUTPUT_FORMULA_FORMAT] [—extract-formula-format EXTRACT_FORMULA_FORMAT] [—no-indent] [—silent] [—export-json FILE_PATH] [—start-point CELL_ADDR] [-p PASSWORD] [-o OUTPUT_LEVEL] [—timeout N]
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 —sort-formulas Sort extracted formulas based on their cell address (requires -x) —defined-names Extract all defined names -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]] —extract-formula-format EXTRACT_FORMULA_FORMAT Specify the format for extracted formulas ([[CELL- ADDR]], [[CELL-FORMULA]], and [[CELL-VALUE]] —no-indent Do not show indent before formulas —silent Do not print output —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). —timeout N stop emulation after N seconds (0: not interruption N>0: stop emulation after N seconds)
<a name="YvTZm"></a>### 中文命令参数```jsonusage: deobfuscator.py [-h] [-c FILE_PATH] [-f FILE_PATH] [-n] [-x][--sort-formulas] [--defined-names] [-2][--with-ms-excel] [-s] [-d DAY][--output-formula-format OUTPUT_FORMULA_FORMAT][--extract-formula-format EXTRACT_FORMULA_FORMAT][--no-indent] [--silent] [--export-json FILE_PATH][--start-point CELL_ADDR] [-p PASSWORD][-o OUTPUT_LEVEL] [--timeout N]可选参数:-h, --help show this help message and exit-c FILE_PATH, --config-file FILE_PATH指定一个配置文件(必须是一个有效的JSON文件)-f FILE_PATH, --file FILE_PATHXLSM文件的路径-n, --noninteractive 禁用交互式shell-x, --extract-only 仅提取单元格,不进行任何仿真--sort-formulas 根据计算单元地址对提取的公式进行排序(requires -x)--defined-names 提取所有已定义的名称-2, --no-ms-excel [已弃用]不要使用MS Excel处理XLS文件--with-ms-excel 使用MS Excel处理XLS文件-s, --start-with-shell在解释输入中的宏之前,打开XLM shell-d DAY, --day DAY 指定月份中的日期--output-formula-format指定输出公式的格式([[CELL-ADDR]],[[INT-FORMULA]], and [[STATUS]]--extract-formula-format 指定提取公式的格式[[CELL-ADDR]], [[CELL-FORMULA]], and [[CELL-VALUE]]--no-indent 公式前不显示缩进--silent 不打印输出--export-json FILE_PATH不打印输出--start-point CELL_ADDR不打印输出-p PASSWORD, --password PASSWORD不打印输出-o OUTPUT_LEVEL, --output-level OUTPUT_LEVEL设置显示的详细信息级别(0:所有命令1:表示命令no jump2:表示重要命令3:表示重要命令中包含字符串)--timeout N N秒后停止仿真(0:非中断N>0: N秒后停止仿真)
Library
以下示例显示了如何在 python 项目中使用 XLMMacroDeobfuscator 来对 XLM 宏进行反混淆:
from XLMMacroDeobfuscator.deobfuscator import process_fileresult = process_file(file='path/to/an/excel/file',noninteractive= True,noindent= True,output_formula_format='[[CELL-ADDR]], [[INT-FORMULA]]',return_deobfuscated= True,timeout= 30)for record in result:print(record)
注意:当您将 xlmdeofuscator 用作库时,不会显示 xlmdeofuscator 徽标。
Requirements
请阅读 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 library。
