HexSpell: The Executable Rust Parser
Table of Contents
Description
HexSpell is an open source library created in Rust, designed to parse and manipulate various types of executable files, including PE (Portable Executable), ELF (Executable and Linkable Format), and Mach-O binaries. The library is built with minimal dependencies, aiming to provide an easy-to-use and flexible tool for analyzing and modifying executables.
Features
- Low Dependency: Uses minimal external libraries for easy integration and maintenance
- Multi-format Support: Parses and manipulates PE (Windows), ELF (Linux), and Mach-O (macOS) executable formats
- Executable Manipulation: Modify executable attributes such as entry points, inject sections, and update headers
- Checksum Calculation: Validate or update checksums of parsed files
- Cross-platform Support: Provides consistent parsing and manipulation tools across multiple platforms
Installation
To include HexSpell in your Rust project, add it to your dependencies with Cargo:
Or manually add this line to your Cargo.toml
:
[]
= "0.1.x"
Examples of use
Parsing PE Files
HexSpell allows you to parse and display important information from PE files.
use PE;
OUTPUT
╔════════════════════════════════════════╗
║ File: tests/samples/sample1.exe ║
╠════════════════════════════════════════╣
║ PE Checksum: 0x00007106 ║
║ Architecture: x86 ║
║ PE Type: PE32 ║
║ Number of sections: 0x00000008 ║
║ Size of image: 0x0000C000 ║
╚════════════════════════════════════════╝
Parsing ELF Files
You can also easily parse ELF binaries (Linux executables) with HexSpell.
use ELF;
OUTPUT
╔════════════════════════════════════════╗
║ File: tests/samples/linux ║
╠════════════════════════════════════════╣
║ Entry point: 0x00001060 ║
║ Program headers: 13 ║
║ Section headers: 31 ║
╚════════════════════════════════════════╝
Parsing Mach-O Files
Mach-O files, commonly used in macOS, can also be parsed and inspected.
use MachO;
OUTPUT
╔════════════════════════════════════════╗
║ File: tests/samples/machO-OSX-x86-ls ║
╠════════════════════════════════════════╣
║ Number of load commands: 16 ║
║ File type: 2 ║
║ First segment name: __PAGEZERO ║
╚════════════════════════════════════════╝
Modify PE Attributes
HexSpell provides utilities to modify executables, such as changing the entry point of a PE file.
use PE;
Create new section and injecting a shellcode
Adding code in a section with its own header
use PE;
const SHELLCODE: =
Support or Contact
Having trouble with HexSpell? Please submit an issue on GitHub.
License
HexSpell is distributed under the terms of the MIT License. See LICENSE for details.