Lion Cipher Lab

Read a Windows PE file by hand with Python and guess what a program does from its imports

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

Steps in this lab

  1. Plan: read a Windows executable without running it
  2. Build two programs you can analyse safely
  3. The first 64 bytes: the DOS header and the pointer
  4. Read the COFF header and the optional header
  5. Write the parser: header, sections and imports
  6. Read the sections like an analyst
  7. Compare the imports and guess the capabilities
  8. Check your parser against objdump
  9. What imports cannot tell you, and how a pro goes further
  10. Clean up

Open the full interactive lab →

Keep learning