Lion Cipher Lab
Recover a struct in Ghidra: turn raw offsets into named fields and retype a function
- Digital Forensics & IR (DFIR)
- Intermediate
- ~75 min
- Free · no account required
Why it matters
Real programs are made of structures: a network packet, a config record, a process entry, a malware task block. Compilers erase the names of the fields, so in a stripped binary all you see is a pointer and a pile of plus-number arithmetic. Until you rebuild the structure you are reading arithmetic, not meaning, and every analysis after that (what does this code store, what does it send, where is the length check) is slow and error-prone. Recovering structs is the step that turns a decompiler listing into something you can explain to a colleague. It also teaches the fact behind many memory…
What you'll learn
- explaining why a stripped binary shows pointer arithmetic instead of field names
- computing a struct's offsets, padding and size from its C declaration on x86-64
- using Auto Create Structure and Auto Fill in Structure to draft a struct from how code uses it
- finishing a struct in the Structure Editor and applying it with Retype Variable
- renaming functions, parameters and fields so the decompiler output reads like source
- checking a recovered layout by recompiling a changed struct and re-reading it
Steps in this lab
- The vocabulary, in plain words
- Write the program, work out its layout on paper, then build it stripped
- Import it into Ghidra and find the three functions
- See the problem: pointer plus a number
- Let Ghidra draft the structure, then see why it is incomplete
- Finish the structure by hand and name the fields
- Retype every function and watch the arithmetic disappear
- Test your understanding: change the layout, recompile, re-read
- When NOT to do this by hand, and how a pro does it better
Open the full interactive lab →