Skip to content
KitploitKITPLOIT
工具漏洞利用博客
Log in
提交
工具漏洞利用博客
提交

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

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

订阅源联系隐私© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
ReflectivePluginLoader — Windows x64 的反射式 PE 映射器与抗规避模块覆盖引擎 | Kitploit
工具/GitHubGitHub/racoten/reflectivepluginloader
防御工具持久化机制逆向工程Shellcode后渗透利用恶意软件分析学习与教育红队Payload 开发二进制利用
GitHubracoten/reflectivepluginloader

ReflectivePluginLoader

821161天前尚未审核

最受欢迎

查看全部 →

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

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

Windows x64 的反射式 PE 映射器与抗规避模块覆盖引擎

查看仓库

ReflectivePluginLoader

License: MIT

一个面向 Windows x64 的极简反射式 PE 映射器与模块踩踏引擎,围绕一个简洁的 IPlugin ABI 构建。从内存中的字节缓冲区映射 DLL,解析导出,并调用插件函数——既可以来自匿名内存(经典反射式加载),也可以来自一个合法加载的牺牲 DLL 内部(模块踩踏)。

模块踩踏路径经过规避强化:按节保护(无 RWX)、私有映射清理、原始字节恢复以及堆清理。使用 pe-sieve、Moneta、hollows_hunter、BeaconEye 和 YARA 对被踩踏模块进行清理后扫描,结果为零发现。

快速开始

需要 CMake 3.15+ 以及 Windows 上的 MSVC、Clang 或 MinGW 之一。

# Configure (defaults to Release)
cmake -B build -G Ninja

# Build
cmake --build build

# The build produces:
#   build/Modules/CmdPlugin/cmdplugin.dll   (example plugin)
#   build/Testing/harness.exe               (test harness)

对于带有完整诊断输出的调试构建:

cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug
cmake --build build

使用方法

经典反射加载

.\harness.exe cmdplugin.dll whoami

将其映射到 VirtualAlloc 分配的内存中。无 PEB 条目,无加载器通知。

模块践踏

.\harness.exe cmdplugin.dll whoami --stomp xpsservices.dll
.\harness.exe cmdplugin.dll "dir C:\" --stomp mscms.dll

通过 LoadLibrary 合法加载牺牲 DLL,然后用插件作为连续映像覆盖其 .text。执行发生在牺牲 DLL 的地址空间中——调用栈和模块列表将代码归属于牺牲模块。

测试框架在清理后暂停,以便你可以针对该进程运行内存扫描器。

模块践踏的工作原理

1. MapImage(plugin)               private reflective mapping
2. LoadLibrary(sacrificial)       legitimate load, PEB entry
3. Save original .text bytes      for later restoration
4. Copy plugin image -> .text     contiguous image preserves RIP-relative offsets
5. Relocate stomped code          fix addresses for new base
6. Patch entry point              mov eax,1; ret (safe FreeLibrary)
7. Per-section protections        RX / R / RW per section (never RWX)
8. Resolve exports                from private mapping, return stomped addresses
9. Free private mapping           eliminates floating PE artifact
10. Execute plugin                code runs inside "sacrificial.dll"

清理(规避)

11. Restore original .text bytes  sacrificial code back in place
12. FreeLibrary(sacrificial)      unloads the module
13. LoadLibrary(sacrificial)      fresh load = clean file-backed pages
14. Scrub heap buffers            zero saved bytes + raw DLL data

清理后,牺牲 DLL 与正常加载的模块无法区分。页面由文件支持(非私有),内容与磁盘上的文件匹配,堆上不残留任何 PE 痕迹。

规避技术

IOC缓解措施
RWX 内存区域按节保护:.text RX、.rdata R、.data RW
私有可执行内存(浮动 PE)导出解析后对私有映射执行 VirtualFree
被修改的模块代码恢复原始 .text 字节,然后 FreeLibrary + LoadLibrary 以获得干净的由文件支持的页面
堆上的 PE 头在释放前对原始 DLL 缓冲区和保存的字节执行 memset(0)
卸载时 DllMain 崩溃在覆盖前将入口点修补为 mov eax,1; ret

项目结构

ReflectivePluginLoader/
├── CMakeLists.txt
├── Include/
│   ├── IPlugin.h                      Plugin ABI (TaskApi, IPlugin)
│   ├── ReflectiveLoaderEngine.h       PE mapper + export resolver
│   └── StompedLoaderEngine.h          Module stomping engine
├── Modules/
│   └── CmdPlugin/
│       ├── cmdplugin.cpp              Command execution plugin
│       └── CMakeLists.txt
├── Testing/
│   ├── main.cpp                       Test harness
│   └── CMakeLists.txt
└── Tools/
    └── file2hex.py                    DLL to C byte array converter

编写插件

  1. 在 Modules/ 下创建一个目录,并包含 IPlugin.h。
  2. 实现 IPlugin 接口:
#include "IPlugin.h"

class MyPlugin : public IPlugin {
public:
    void init()                  const override { /* setup */ }
    void execute(TaskApi* task)  const override { /* work  */ }
    void cleanup()               const override { /* tear  */ }
};
  1. 导出五个入口点(create_plugin、destroy_plugin、plugin_init、plugin_exec、plugin_cleanup)。使用 HeapAlloc + placement new 进行 CRT 安全分配。

  2. 添加 CMakeLists.txt 并在根目录中使用 add_subdirectory() 注册它。

选择牺牲 DLL

牺牲 DLL 的 .text 节必须大于插件的虚拟映像大小。它不应被进程主动使用或在运行时进行完整性检查。

好的候选:xpsservices.dll(1.8 MB .text)、mscms.dll、colorui.dll、npmproxy.dll

坏的候选:ntdll.dll、kernel32.dll(被主动使用)、clr.dll(进行完整性检查)

限制

  • 支持: 基址重定位、导入解析、按节保护、连续映像覆盖、带页面恢复的完整清理
  • 不支持: TLS 回调、延迟加载导入、转发导出、CFG、SEH 表注册
  • 覆盖: 整个插件虚拟映像必须能放入牺牲 .text 节中

变更内容(v2.0 — 规避强化)

此版本是对原始概念验证的彻底重写:

  • 模块覆盖引擎(StompedLoaderEngine.h)— 连续映像覆盖,带完整规避清理
  • 按节内存保护 — .text RX、.rdata R、.data RW;不再有 RWX 区域
  • 私有页面消除 — FreeLibrary + LoadLibrary 循环用干净的文件支持页面替换私有化页面
  • 堆清理 — 在扫描窗口之前将原始 DLL 字节和保存的原始 .text 清零
  • 入口点修补 — mov eax,1; ret 防止 FreeLibrary 期间 DllMain 崩溃
  • 私有映射清理 — 在导出解析后 VirtualFree 反射映射(消除浮动 PE)
  • 反射加载器重写(ReflectiveLoaderEngine.h)— 直接从输入缓冲区映射,无中间 VirtualAlloc 副本
  • 插件 ABI 清理(IPlugin.h)— 移除无用辅助函数(BeaconCout、CStrLenA、PluginAlloc、PluginFree)
  • CmdPlugin 清理 — 移除所有标记字符串和调试产物
  • 测试框架重写(main.cpp)— 通过 NDEBUG 进行条件编译;Release 构建仅显示命令输出和扫描命令
  • CMake 默认值 — 默认 Release 构建类型,插件 DLL 使用 -nostartfiles(反射加载代码中无 CRT)

扫描器结果(清理后)

image

参考

  • stephenfewer/ReflectiveDLLInjection
  • ired.team - Module Stomping
  • fancycode/MemoryModule
  • PE Format (Microsoft)
  • forrest-orr/moneta
  • hasherezade/pe-sieve

许可证

MIT

下载工具