explaingit

d7ead/mkpivm

404C++Audience · researcherComplexity · 5/5ActiveSetup · hard

TLDR

Offensive-security research tool that wraps x86 and x64 Windows shellcode in a per-build polymorphic virtual machine with a per-run cipher, reducing signature-based detection.

Mindmap

mindmap
  root((mkPIVM))
    Inputs
      Raw shellcode
      PE file
      Per-run seed
    Outputs
      Virtualized blob
      Patched PE
      Eligibility report
    Use Cases
      Red team research
      Shellcode obfuscation
      Detour injection
    Tech Stack
      C++
      Windows
      x86
      x64

Things people build with this

USE CASE 1

Wrap a piece of x64 Windows shellcode in a per-run virtual machine for malware research and red-team training.

USE CASE 2

Use packer mode to ship a payload as encrypted data that is decrypted at runtime by an embedded interpreter.

USE CASE 3

Embed a virtualized blob into an existing PE file with detour mode and patch a jump to the new entry.

USE CASE 4

Use scan mode to see which byte ranges of an input are eligible for virtualization before running a full lift.

Tech stack

C++Windows

Getting it running

Difficulty · hard Time to first run · 1day+

Targeted at red-team and malware researchers. Building and using on Windows requires offensive-security context and care to stay inside authorized testing.

License is not stated in the available content.

In plain English

mkPIVM is a C++ tool for Windows that takes a piece of raw machine code and wraps it in a tiny custom virtual machine. The README describes it as a polymorphic position-independent shellcode virtualizer for x86 and x64 Windows. The author frames the project as offensive security research, and an attached PDF research paper is linked at the top. Topic tags name antivirus and endpoint-protection products such as Cobalt Strike, Metasploit, and Havoc, signalling that the intended audience is red teamers and malware researchers rather than general developers. The README explains the idea like this: the input is a raw blob of code, and the output is another raw blob that contains a small interpreter plus a lifted, encrypted copy of the original instructions. Because every build is keyed by a per-run seed, two outputs from the same input share fewer than a hundred coincidental bytes, which makes signature-based detection harder. The author argues that ordinary shellcode is easy to fingerprint, and that running it through a per-instance VM with a per-instance cipher removes useful patterns from the file on disk. Usage is shown in one line: "mkpivm.exe shellcode.bin --arch x64 -o out.bin". The README then lists several modes selected by flags. Default mode lifts the whole input. Packer mode wraps the input as encrypted data that is decrypted at runtime. Hybrid mode lifts only specified byte ranges. Stacked mode combines the two. Detour mode embeds a prebuilt blob into an existing PE file and patches a jump. Scan mode prints which byte ranges would be eligible for lifting. A showcase section links to a demo video and shows VirusTotal screenshots for an example sample. An entropy table compares the output to common Windows system DLLs such as ntdll.dll and kernel32.dll, arguing that the tool keeps file entropy close to that of normal system libraries. The rest of the README is two Mermaid diagrams: one of the build pipeline (CFG building, IR lifting, obfuscation passes, codec encoding, encryption) and one of the runtime flow inside the emitted blob (prologue, decryption of internal tables, dispatcher loop, handler execution, and termination paths).

Copy-paste prompts

Prompt 1
Walk through the mkPIVM build pipeline as a study aid for understanding modern shellcode obfuscation. What does each pass (CFG building, IR lifting, codec encoding, encryption) do?
Prompt 2
For a red-team training lab, run mkpivm.exe in hybrid mode and explain why per-run seed-based encryption defeats naive signature detection.
Prompt 3
Explain how mkPIVM keeps file entropy close to ntdll.dll and kernel32.dll, and why that matters for evading entropy-based scanners in a research setting.
Prompt 4
Compare mkPIVM's per-instance VM approach to traditional packers like UPX. Where does the polymorphic VM add detection cost?
Prompt 5
Sketch a defender-side detection strategy for mkPIVM-style virtualized payloads, starting from the dispatcher loop pattern.
Open on GitHub → Explain another repo

Generated 2026-05-22 · Model: sonnet-4-6 · Verify against the repo before relying on details.