Skip to content
KitploitKITPLOIT
ToolsExploitsBlog
Log in
Submit
ToolsExploitsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

FeedsContactPrivacy© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
ReflectivePluginLoader — Reflective PE mapper and evasion-hardened module stomping engine for Windows x64 | Kitploit
Tools/GitHubGitHub/racoten/reflectivepluginloader
Defensive ToolsPersistence MechanismsReverse EngineeringShellcodePost-ExploitationMalware AnalysisLearning & EducationRed TeamingPayload DevelopmentBinary Exploitation
GitHubracoten/reflectivepluginloader
8211619 hours agoNot yet reviewed

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →

ReflectivePluginLoader

Reflective PE mapper and evasion-hardened module stomping engine for Windows x64

View Repository
Share

ReflectivePluginLoader

License: MIT

A minimal reflective PE mapper and module stomping engine for Windows x64, built around a clean IPlugin ABI. Maps a DLL from a byte buffer in memory, resolves exports, and calls plugin functions — either from anonymous memory (classic reflective load) or from inside a legitimately loaded sacrificial DLL (module stomping).

The module stomping path is evasion-hardened: per-section protections (no RWX), private mapping cleanup, original byte restoration, and heap scrubbing. Post-cleanup scans with pe-sieve, Moneta, hollows_hunter, BeaconEye, and YARA return zero findings on the stomped module.

Quick Start

Requires CMake 3.15+ and either MSVC, Clang, or MinGW on Windows.

# 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)

For a Debug build with full diagnostic output:

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

Usage

Classic Reflective Load

.\harness.exe cmdplugin.dll whoami

Maps the plugin into VirtualAlloc'd memory. No PEB entry, no loader notification.

Module Stomping

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

Loads the sacrificial DLL legitimately via LoadLibrary, then overwrites its .text with the plugin as a contiguous image. Execution happens from the sacrificial DLL's address space — call stacks and module lists attribute the code to the sacrificial module.

The harness pauses after cleanup so you can run memory scanners against the process.

How Module Stomping Works

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"

Cleanup (Evasion)

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

After cleanup, the sacrificial DLL is indistinguishable from a normally loaded module. Pages are file-backed (not private), content matches the on-disk file, and no PE artifacts remain on the heap.

Evasion Techniques

IOCMitigation
RWX memory regionsPer-section protections: .text RX, .rdata R, .data RW
Private executable memory (floating PE)VirtualFree the private mapping after export resolution
Modified module codeRestore original .text bytes, then FreeLibrary + LoadLibrary for clean file-backed pages
PE headers on heapmemset(0) raw DLL buffer and saved bytes before freeing
DllMain crash on unloadEntry point patched to mov eax,1; ret before stomping

Project Structure

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

Writing a Plugin

  1. Create a directory under Modules/ and include IPlugin.h.
  2. Implement the IPlugin interface:
#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. Export the five entry points (create_plugin, destroy_plugin, plugin_init, plugin_exec, plugin_cleanup). Use HeapAlloc + placement new for CRT-safe allocation.

  2. Add a CMakeLists.txt and register it in the root with add_subdirectory().

Picking a Sacrificial DLL

The sacrificial DLL's .text section must be larger than the plugin's virtual image size. It should not be actively used by the process or integrity-checked at runtime.

Good candidates: xpsservices.dll (1.8 MB .text), mscms.dll, colorui.dll, npmproxy.dll

Bad candidates: ntdll.dll, kernel32.dll (actively used), clr.dll (integrity checked)

Limitations

  • Supported: Base relocations, import resolution, per-section protections, contiguous image stomping, full cleanup with page restoration
  • Not supported: TLS callbacks, delay-load imports, forwarded exports, CFG, SEH table registration
  • Stomping: The entire plugin virtual image must fit in the sacrificial .text section

What Changed (v2.0 — Evasion Hardening)

This release is a ground-up rewrite of the original proof-of-concept:

  • Module stomping engine (StompedLoaderEngine.h) — contiguous image stomping with full evasion cleanup
  • Per-section memory protections — .text RX, .rdata R, .data RW; no more RWX regions
  • Private page elimination — FreeLibrary + LoadLibrary cycle replaces privatized pages with clean file-backed ones
  • Heap scrubbing — raw DLL bytes and saved original .text are zeroed before the scan window
  • Entry point patching — mov eax,1; ret prevents DllMain crash during FreeLibrary
  • Private mapping cleanup — VirtualFree the reflective mapping after export resolution (eliminates floating PE)
  • Reflective loader rewrite (ReflectiveLoaderEngine.h) — direct mapping from input buffer, no intermediate VirtualAlloc copy
  • Plugin ABI cleanup (IPlugin.h) — removed dead helpers (BeaconCout, CStrLenA, PluginAlloc, PluginFree)
  • CmdPlugin cleanup — removed all marker strings and debug artifacts
  • Test harness rewrite (main.cpp) — conditional compilation via NDEBUG; Release builds show only command output and scan commands
  • CMake defaults — Release build type by default, -nostartfiles for plugin DLLs (no CRT in reflective-loaded code)

Scanner Results (post-cleanup)

image

References

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

License

MIT

Download Tool