A lightweight command-line tool written in C for parsing and analysing Windows Portable Executable (PE) files. The project manually parses PE structures without relying on external PE parsing libraries, making it suitable for learning the PE format, malware analysis, reverse engineering, and digital forensics.
- Parse DOS Header
- Parse NT Headers
- Parse File and Optional Headers
- Parse Section Table
- Display section permissions (Read, Write, Execute)
- Parse Import Directory
- Display imported DLLs and function names
- Parse Export Directory
- Display exported function names
- Detect PE overlay data
- Perform defensive bounds checking to safely handle malformed PE files
.
├── include/ Header files
├── src/ Source code
├── tests/ Unit tests
├── samples/ Sample PE files
├── tools/ Standalone utilities
├── build/ Generated object files
├── bin/ Generated executables
├── Makefile
├── README.md
└── LICENSE
- GCC
- GNU Make
- A Unix-like environment (Linux or macOS)
Compile the project:
makeThe executable will be generated at:
bin/scope
Remove generated files:
make cleanAnalyse a PE file by providing its path as the first argument.
./bin/scope <pe_file>The parser reports:
- File information
- DOS Header
- NT Headers
- Section Table
- Import Directory
- Export Directory
- Overlay information
Run the complete test suite:
make testThe test suite validates:
- File loading
- DOS Header parsing
- NT Header parsing
- Section table parsing
- RVA-to-file offset conversion
- Import parsing
- Export parsing
- Shared security and bounds-checking routines
The repository includes standalone utilities built using the same PE parsing concepts.
tools/c/overlay_extract.c
Extracts overlay data appended after the PE image while accounting for the Authenticode Certificate Table.
Build:
gcc tools/c/overlay_extract.c -o overlay_extracttools/py/overlay_extract.py
Python implementation of the same overlay extraction logic for scripting and rapid analysis.
Contributions are welcome. Bug reports, feature requests, and pull requests are appreciated.
This project is licensed under the MIT License. See the LICENSE file for details.