Lesson 11 of 13 · 24m
Packed and Defended: When the File Lies About Itself
High-entropy .text and a three-import table mean the program only exists in memory — recognize packers, catch the OEP, dump, rebuild imports, and defuse the anti-debug checks.
You open the binary and the ground truth isn't there: .text reads as high-entropy noise, the import table is three entries (LoadLibraryA, GetProcAddress, VirtualProtect), and the longest string is four bytes. The file isn't the program — it's a container. The real code is compressed or encrypted inside, materializes in memory at run time, and doesn't exist in the file at all. The wrong mental model is still "the file is the program." For packed targets, the file is a delivery mechanism; the program only exists while it's running.
Recognizing it
Three tells. Entropy: compressed/encrypted data sits near 7.9 bits per byte — diec (Detect It Easy) reports section entropy, and a .text that looks like randomness is a packed .text. Names: UPX leaves UPX0/UPX1 sections and an UPX! marker; other packers have their own signatures — diec names them. Shape: an import table that only knows how to resolve other imports (GetProcAddress/dlsym plus memory APIs) is a stub that unpacks then hands off.
The easy case and the real case
Stock UPX unpacks itself: upx -d packed restores the original binary, fully analyzable. That works often enough to always try first — real malware still ships in stock UPX because it's free and it defeats dumb scanners.
Modified packers — and everything more serious — make you catch the decompressed image in memory instead. The shape is universal: the unpacking stub decrypts/decompresses into a fresh memory region, then does a tail jmp to the original entry point (OEP). Your job is not to reverse the compressor — it's to stop at the OEP and dump:
- In x64dbg: set a breakpoint on the tail jump (the long jump after the decompression loop; often
popad; jmpor ajmp rax/jmp <distant VA>), run to it, single-step — you're standing at the OEP of the real program. - Dump the process memory: Scylla (bundled with x64dbg) does "dump + fix imports" — it scans the memory image for the IAT the stub built and rewrites the import directory so the dump analyzes like a normal PE.
- On Linux:
stracefirst — an unpackermprotects orexecves amemfd; thengcore <pid>or gdb'sdump binary memorywhile it's stopped at the right moment.rrhelps here: record, find the OEP,reverse-continueto it.
The unpacked dump is what you import into Ghidra. Analyze that, not the container.
When the program watches you back
Anti-debugging is a checklist of cheap APIs and one honest mechanism. The catalog:
ptrace(PTRACE_TRACEME)on Linux — a process can only be ptraced once; if the program does it to itself, yourptrace-based debugger fails on attach. You'll see it instracebefore you ever hit it.IsDebuggerPresentandCheckRemoteDebuggerPresenton Windows — readPEB.BeingDebugged(fs:[0x30]+2on x86), one byte you can flip.NtQueryInformationProcesswithProcessDebugPort(0x07) — returns nonzero under a debugger.- TLS callbacks run before the entry point — the loader calls them before
main; anti-debug code lives there so it fires before your breakpoint atWinMain. Check the TLS directory before assuming entry is the start. rdtscdeltas — read the timestamp counter before and after a block; a debugger's single-step inflates it by orders of magnitude. Timing checks don't prove a debugger; they prove the run is slow, which is close enough.
The counters: x64dbg's ScyllaHide plugin hooks the detection APIs at the source so the checks see a clean system. And where a check exists in code, it's a patchable branch like any other — find the IsDebuggerPresent xref, NOP the test.
Know the ceiling
VMProtect-, Themida-, and Denuvo-class protectors don't just compress — they translate selected functions into bytecode for a custom VM embedded in the binary. The "dump at OEP" trick doesn't apply because there is no single OEP for the virtualized code. That's a different discipline with its own tooling; the fundamentals course says: recognize it (diec names VMProtect), report it, and don't start there.
Field notes
- Always try
upx -dfirst — the five-second test that either solves the problem or tells you it's a modified pack. - Run packed samples in a VM or container, never your analysis host — "unpacks in memory" means "executes on your machine."
- After a memory dump, check imports before analysis: a dump without a rebuilt IAT leaves every external call as an indirect mystery.
binwalkis the same idea applied to firmware/carving — "the file is a container" shows up everywhere.
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.
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.
What is an Infostealer?
Infostealers are commodity malware that silently harvest credentials, session tokens, and crypto wallets from infected machines. The Lumma Stealer infection that triggered the Vercel breach started with one. Here is how they work and why they are so effective.