How connorpatterson/pe-loader-sample works
Project Type and Purpose
• This is a two-part Windows PE crypter proof-of-concept, written in C++.
• Part 1 (“XOR-Cipher-Executable”) is a CLI tool that takes a PE file, applies an XOR cipher, and emits “crypt.exe.”
• Part 2 (“Pe-Loader-Sample”) is a custom PE loader. It embeds the encrypted PE as a resource, decrypts it in memory at runtime, performs relocations and import resolution, and then transfers execution to it—all without writing the decrypted image to disk.
File Structure
Top-level folders:
• XOR-Cipher-Executable
– XOR-Cipher-Executable.cpp (main encryption logic)
– README.md (usage instructions)
• Loader-Sample-master
– .vcproj (Visual Studio project definition for the loader)
– src/
• PeLdr.cpp / PeLdr.h (core loader code: map image, fix relocations, resolve imports)
• Main.cpp (entry point modified to load from resource rather than disk)
• Debug.h, PEB.h (helper headers), resource.h
– .gitignore, .gitattributes
Observations:
– Two distinct executables, each with its own source and build configuration.
– The loader uses Windows resource mechanism (RCDATA) to carry the encrypted payload.
– No database or external service; the system relies on OS services for memory mapping and PE parsing.
README for Insights
• The crypter tutorial: codeproject.com/Articles/1174823…
• Workflow: encrypt → embed as resource → build loader → run loader → in-memory decryption and execution.
• Modifications: loader removed disk I/O, arguments, added XOR decryption prior to invoking original loader logic.