Lion Cipher Lab
Read a Windows PE file by hand with Python and guess what a program does from its imports
- Digital Forensics & IR (DFIR)
- Intermediate
- ~75 min
- Free · no account required
Why it matters
The Portable Executable (PE) format is the container for every Windows program: .exe, .dll and drivers. An analyst who can read it by hand knows what a tool like a PE viewer is really doing, can spot a file that is not what it claims, and can take a first triage pass in seconds: which libraries does it load, which functions does it ask Windows for, which parts are executable and writable. Imports are one of the quickest, cheapest and most honest clues about a program's capabilities, which is why triage tools show them first. They are also easy to hide, and knowing how they work shows you why.
What you'll learn
- cross-compiling two small Windows programs on Linux without running them
- walking the PE structure by offsets: DOS header, e_lfanew, signature, COFF header, optional header
- reading the section table and the three permission bits that matter (read, write, execute)
- converting an RVA (a memory address) to a file offset using the section table
- walking the import table and turning a list of API names into a capability guess
- checking your own parser against objdump, and explaining what imports cannot tell you
Steps in this lab
- Plan: read a Windows executable without running it
- Build two programs you can analyse safely
- The first 64 bytes: the DOS header and the pointer
- Read the COFF header and the optional header
- Write the parser: header, sections and imports
- Read the sections like an analyst
- Compare the imports and guess the capabilities
- Check your parser against objdump
- What imports cannot tell you, and how a pro goes further
- Clean up
Open the full interactive lab →