Lesson 6 of 12 · 25m
Unpacking: Let the Malware Do the Work
The effort ladder from upx -d to debugger breakpoints on memory APIs, catching payloads with pe-sieve, and how to know the dump is actually the payload.
The packer's whole job is to put the real payload in memory and run it. Your job is to be standing there when it does. New analysts burn days reversing a decompression routine; the senior move is to never read the algorithm at all. Set traps on the handful of APIs every unpacker must call, let the stub do its work, and collect the result.
The effort ladder — climb only as far as needed
- Known tool:
upx -d sample.exe -o sample.unpacked.exe. "Not packed by UPX" while DIE says UPX → tampered section names or strippedUPX!magic; restore them and retry before moving up the ladder. - Sandbox dumps: CAPE captures injected and unpacked payloads automatically — check the payloads tab before opening a debugger. This is the step people skip.
- Memory scanners: run the sample in the lab VM and point pe-sieve at the process.
- Debugger breakpoints on memory APIs.
- Reversing the stub — rare, and usually a sign a step above was skipped.
The pattern every unpacker follows
stub -> VirtualAlloc(NULL, 0x3A000, MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE)
-> decrypt / decompress payload into the buffer ; you don't care how
-> VirtualProtect(buf, 0x3A000, PAGE_EXECUTE_READ, &old)
-> jmp payload OEP ; self-injection
or CreateProcessW(CREATE_SUSPENDED) -> WriteProcessMemory
-> SetThreadContext -> ResumeThread ; hollowingTwo shapes worth naming. Self-injection allocates in its own process, flips the memory executable, and jumps — the payload never touches disk. Hollowing spawns a legitimate process suspended, writes the payload into it, and resumes — so the malicious code runs under explorer.exe's or svchost.exe's good name. Both paths funnel through the same four APIs, which is why the breakpoint set works for both.
The x64dbg recipe
bp VirtualAlloc
bp VirtualProtect
bp WriteProcessMemory
bp ResumeThread
runAt VirtualAlloc, rtr (run to return) and note RAX — the new buffer; follow it in the dump pane and set a hardware write breakpoint (bphws rax, w, 1) to watch it fill until it starts with 4D 5A. At WriteProcessMemory the x64 calling convention puts args in RCX, RDX, R8, R9: RCX is the target handle, RDX the remote address, R8 the buffer, R9 the size. Save it with savedata C:\dump\payload.bin, r8, r9 and stop before ResumeThread — you just caught a hollowing payload without letting it run.
pe-sieve: the lazy (correct) first try
C:\Tools> pe-sieve64.exe /pid 4312 /shellc /imp 1
[*] Scanning: C:\Windows\SysWOW64\explorer.exe
Implanted PE: 1 Implanted shc: 0 Replaced: 0
Dumped modules to: process_4312pe-sieve finds PEs and shellcode that don't match anything on disk — implants, hollowed images, patched modules — and dumps them realigned, with a scan_report.json explaining each flag. An Implanted PE inside explorer.exe is the hollowing case made concrete.
Is the dump the payload?
Re-run your static triage on the dump: meaningful strings, a rich import table, .text entropy around 6, capa describing malware behaviors instead of packer behaviors. Tiny imports and another high-entropy blob means you've peeled one layer of a multi-stage chain — keep going, and hash every stage separately.
Field notes
- Multi-stage is normal: loader → shellcode → loader → payload. Hash and label every stage in the case file.
- Memory dumps sit at virtual offsets — fine for strings, capa, and YARA. For a runnable PE, let pe-sieve unmap it or rebuild imports with Scylla.
IsDebuggerPresent,PEB.BeingDebugged, and timing checks will fight you; ScyllaHide defeats most commodity checks.- .NET loaders usually end in
Assembly.Load(byte[])— that's a different lesson; native breakpoints won't help you there. - Report both hashes: the packed file is what IR blocks on disk, the payload hash is what clusters the family.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
A Fake GTA 6 ISO Didn’t Install a Game. It Installed a Wiper.
A fake GTA 6 ISO used a believable installer error to cover remote-access malware, browser-data theft, and destructive file wiping. The “License not found” message wasn’t the crack failing. It was there so the victim would stop looking.
CVE-2025-62718: Critical Axios SSRF Vulnerability Explained
A critical SSRF flaw in Axios was used in a North Korean supply chain attack. Here's what it does and how to patch it today.
A Minecraft Mod Is a Program. In 2026, Attackers Started Acting Like It.
A Minecraft mod is a Java program that runs with your account's full permissions, and nothing in the game checks what it does.
Hacktivism, 2021 to Today: From Steel Mills to Power Grids
Part 1 ended on a 70-gigabyte breach in 2021. Since then, hacktivists derailed trains, dumped molten steel on camera, and reached grids in three countries.