Monday, November 16, 2026

SuperMega for embedding shellcode carriers inside legitimate PE files

SuperMega for embedding shellcode carriers inside legitimate PE files

SuperMega is an open-source shellcode loader that splices an encrypted payload carrier into a genuine PE executable for authorized red team training and detection engineering.

Tooldobin/SuperMega — Python framework that injects an encrypted shellcode carrier into a legitimate .exe or .dll to study static-analysis evasion
CategoryShellcode loader / PE injection framework (x64 Windows)
Primary UseBuilding trojanized binaries in a lab to test how EDR and static analyzers handle carrier-based shellcode execution like backdoor entrypoint hijacking and xor_2 decoding
Safe UseUse only in isolated labs and authorized engagements against systems you own or have written permission to test; the tool's output is a deliberately malicious-looking binary and should never leave your test range
Telemetry NoteDefenders should watch for entrypoint anomalies (main() jmp patching), unexpected RWX/RW→RX permission transitions, entropy shifts in .rdata or .text, and behavioral deconditioning loops flagged by its sirallocalot anti-emulation module

SuperMega, published at dobin/SuperMega and written in Python around a VS2022 build chain, is a research-grade shellcode loader that exemplifies a technique its author calls Cordyceps, after the parasitic fungus that hijacks its host. Rather than crafting a standalone implant from scratch, SuperMega takes a genuine, signed-looking .exe or .dll as its host and splices a small carrier program into it, so that static analysis of the resulting artifact mostly surfaces the original binary's legitimate metadata, imports, and structures. With roughly 489 stars and a GPL-3.0 license, it sits in that interesting niche of offensive-security tooling that is simultaneously a red team aid and a valuable teaching artifact for detection engineers who want to understand what modern loaders actually do to a PE file.

The README frames the goal explicitly: make an infected executable hard to spot through static analysis while employing what it calls modern anti-EDR mechanisms. The important nuance for defenders is that the original functionality of the host executable does not survive the process — SuperMega notes that the trojanized file only executes the carrier, it no longer runs the host program's real logic. That gap between visual legitimacy and behavioral illegitimacy is precisely where behavioral detection can win, and it is a point worth remembering when evaluating any file-reputation-based control.

Internally, SuperMega is a compilation pipeline rather than a simple byte-patcher. The payload.py stage ingests a 64-bit shellcode .bin file from data/binary/shellcodes, then templater.py generates a C-language carrier from composable templates stored under data/source/. The carrier is compiled to assembly with cl.exe, assembled into a small position-independent blob with ml64.exe, and finally injector.py writes that carrier into the host PE and patches the necessary references. The console output in the README shows this flow clearly, including checks for whether the host's Import Address Table already contains the API entries the carrier needs — the Cordyceps trick is that the carrier deliberately reuses the host's existing IAT entries instead of performing a classic PEB walk to resolve Windows APIs, which removes one of the most well-known behavioral indicators of shellcode loaders.

The carrier itself is decomposed into swappable modules, which is what makes the project interesting from an analytical standpoint. The --carrier flag selects the execution strategy: alloc_rw_rx allocates writable memory, copies the payload, and flips it to read-execute; alloc_rw_rwx keeps it writable for self-modifying payloads; change_rw_rx instead decrypts the payload in place within .text to masquerade as trusted IMAGE-backed data, which the README calls IMAGE spoofing. There are also dll_loader_alloc and dll_loader_change variants that treat a .dll as the payload rather than raw shellcode, a configuration the author suggests may be even stealthier.

Payload concealment is similarly modular. The --decoder option ranges from plain to a recommended two-byte xor_2 scheme with randomly chosen keys — trivial obfuscation by modern standards, but enough to blunt naive signature and entropy checks, especially when the payload is stored in .rdata via --payload_location data, which the README recommends as the most natural placement from an entropy-analysis perspective. The --carrier_invoke option controls how execution reaches the carrier: overwrite replaces the host's main() outright, while the recommended backdoor mode parses the main function for unconditional jumps and redirects the last one to the carrier placed at a randomized offset in .text. That randomization plus partial preservation of original code flow is the core static-evasion argument of the whole design.

The remaining modules target dynamic analysis directly. The --antiemulation option offers timeraw, a CPU register timing check, and the recommended sirallocalot, which burns CPU cycles, memory, and time — and doubles as what the README calls an EDR deconditioner, presumably training or exhausting an EDR's memory-scanning heuristics before the payload is ever decrypted. The --guardrail mechanism supports execution gates, keyed via --guardrail-key, so the payload only decrypts on an intended target environment, complicating sandbox detonation and automated triage. For defenders, these modules are a concise checklist of what adversary tooling tries to do to your sandboxes and your endpoint agents, and each one has a detection counterpart: timing-tolerant emulation, memory scanning at the right lifecycle moment, and decoy-resistant instrumentation.

Operationally, the tool expects a fairly heavy build environment: a VS2022 installation with cl.exe and ml64.exe, launched through vcvarsall.bat for the x64 toolchain, plus Python dependencies installed via pip.exe install -r requirements.txt. There is a web interface, web.py, served on http://localhost:5001, and a command-line driver, supermega.py, where you can select options like --shellcode, --inject, --carrier, and --decoder. The author presented the design publicly at HITB2024 Bangkok under the title My first and last shellcode loader, and the README links accompanying write-ups on the Cordyceps injection techniques, all of which reinforce that this is a disclosed, research-oriented project rather than covert malware.

From a defensive perspective, SuperMega is best understood as a curriculum. Every module maps to a detection hypothesis: entrypoint and control-flow anomalies in .text for the backdoor invoker; unexpected section-permission transitions for the allocation-based carriers; section-entropy baselining for .rdata-hosted XOR payloads; emulator endurance for the anti-emulation tricks; and IAT-consistency checks for the Cordyceps reuse behavior. A purple team exercise built around this tool — running it strictly in an isolated lab with benign test payloads like the bundled calc64.bin or messagebox.bin examples — can validate whether an EDR actually catches the permission flips and the post-hijack execution flow rather than relying on file reputation.

The obvious caveat is that the tool exists to defeat security controls, so its legitimate audience is narrow: authorized red teamers with client permission, malware analysts studying loader tradecraft, and detection engineers testing their own telemetry. The output binaries are functionally trojans and must never be pointed at systems you do not own or control. Used within that boundary, SuperMega is one of the more instructive open-source loaders available, precisely because its modular design makes each evasion technique individually observable, testable, and — with well-instrumented defenders — detectable.

Official project repository for dobin/SuperMega.
Download Tool

Educational analysis for authorized security professionals. Use only in controlled, authorized environments.

Sponsored
Share articleFacebookXLinkedIn

Continue exploring

Browse all articles →

0 comentários:

Post a Comment

Note: Only a member of this blog may post a comment.