Sogen userspace emulator
momo5502 Sogen emulates at CPU + syscall, then runs the real system DLLs. It does not reimplement Win32. Kevlar is a kernel DriverEntry Unicorn harness (kevlar-driver-emulation). Qiling reimplements APIs. vmtrace is the WHP trap library Sogen can sit on.
Upstream: https://github.com/momo5502/sogen · demo https://sogen.dev · companion momo5502/sogen-linux-files · lecture momo5502/drm-analysis
When this is the PRIMARY
- Detonate a PE/ELF that probes ntdll / PEB / SEH / registry and must see real Microsoft/glibc bytes
- Invisible debug (GDB/IDA RSP) from outside the guest
- Deterministic replay / snapshot around a DRM or packer check
- Swap CPU backends: Unicorn, icicle-emu, WHP, KVM, FEX
Workflow
Pick backend vs host. See references/backends.md. WHP needs
Microsoft-Hyper-V-Hypervisor+HypervisorPlatform. KVM needs/dev/kvm. Unicorn/icicle run anywhere, including the browser build.- Done when the chosen backend is installed and a
helloPE/ELF exits 0.
- Done when the chosen backend is installed and a
Give it a real sysroot. Windows guests need a matching
ntdll.dll/kernel32.dll/user32.dlltree (and wow64 if 32-bit). Linux guests need thesogen-linux-filesrootfs. Do not stub those DLLs — the product is “real system DLLs.”- Done when the loader maps
ntdllfrom the sysroot (log the path + file hash).
- Done when the loader maps
Load like the OS. Confirm PE relocs, TLS callbacks, section protect, reserved vs committed, SEH registration, and the initial thread. A crash in TLS before
mainis a loader bug, not a sample bug.- Done when RIP is in the image entry and PEB/TEB look like a real process.
Hook the interesting surface. Intercept syscalls, specific ntdll exports, instruction ranges, and memory R/W. Rewrite return values instead of patching guest
.textwhen the sample hashes itself.- Done when a named syscall/API hook fired with logged args.
Debug from the host. Attach IDA/GDB to the GDB stub. Guest anti-debug (PEB.BeingDebugged,
NtQueryInformationProcess, timing ofint 3) must stay clean because the debugger is not in-process.- Done when a breakpoint hits without the sample’s anti-debug path firing.
Snapshot around the check. Full serialize + in-memory snapshot + minidump load. Restore, mutate one input, restore again. DRM lecture path: snapshot before the license VM, step with HyperDbg/Sogen, dump the slice into
llvm-lift-deobfuscation/virtualization-deobfuscation.- Done when two restores produce identical RIP/regs before the mutation.
GUI / GPU only if needed. Native windows work. D3D8–11 goes through DXVK over the GPU paravirtual bridge; WHP is the fast CPU path. Do not turn this on for a headless malware run.
- Done when the requested window presents, or the task is marked headless.
Pair with
kevlar-driver-emulation—.sys/DriverEntry, not usermodevm-and-bytecode-reverse/virtualization-deobfuscation/llvm-lift-deobfuscation— after you have a slicehypervisor-dev+vmtraceWHP API — write a custom trap guestmalware-analysis— detonation policyimgui-overlay— not Sogen’s CEFgameoverlay
Verification
- Backend named; hello guest exits 0
- Sysroot ntdll/kernel32 (or linux rootfs) hashed in the log
- TLS/entry reached with a sane PEB
- At least one syscall or export hook observed
- GDB/IDA attach does not set guest BeingDebugged
- Snapshot restore is bit-identical at the stated RIP