Crates.io | deaf |
lib.rs | deaf |
version | 0.1.2 |
source | src |
created_at | 2023-09-04 12:29:44.183503 |
updated_at | 2023-09-04 12:29:44.183503 |
description | A library for parsing and modifying ELF binaries |
homepage | https://github.com/mjhouse/deaf |
repository | https://github.com/mjhouse/deaf |
max_upload_size | |
id | 963121 |
size | 5,659,233 |
A Rust library for parsing and modifying ELF binaries
Contributions
·
Code Of Conduct
·
Report Bug
·
Request Feature
This is a library for parsing and modifying ELF-format binaries. There are other libraries like elf, elfy, and elfkit for parsing the format, but they are either not able to modify the ELF binary (elf and elfy) or are limited/unmaintained (elfkit). DEAF is written with the explicit goal of allowing users to modify anything that they can see in the binary- you should be able to add symbols to the symbol tables, remove the body of a function, or change the name of a section, easily and intuitively. Some of the changes you can make will probably break the binary. For example, if you remove the body of a function then relative branch instructions after the gap will no longer point to the correct address.
As the development of the library progresses, there should be fewer and fewer ways that your changes break the ELF binary, and the end goal is to even handle updating branch instructions when code is removed from an executable section.
This project is still in the very early stages, so expect a lot of breaking changes, restructuring, and reorganization from one version to the next as we figure out where things belong. If you still want to try it out, include deaf in your project by using cargo add:
cargo add deaf
Or by manually updating your cargo toml:
deaf = "0.1.0"
Then use it in your project like so:
use deaf::{Binary,Section,common::SectionType};
let binary = Binary::load("assets/libjpeg/libjpeg.so.9").unwrap();
for section in binary.sections(SectionType::Strings).iter() {
let name_offset = section.name();
let name_value = binary.section_name(name_offset).unwrap();
println!("{}",name_value);
}
For more details, refer to the documentation.
This version is mainly aimed at providing initial functionality.
This release is generally aimed at propagating changes to keep the binary useable.
This release is going to be all about gathering context about executable code, if not outright disassembling it.
EI_OSABI
and e_machine
values in file headerThis is a haphazard collection of things that should be added to the library at some point but that aren't quite on the roadmap yet.
Make it possible to iter/iter_mut over instructions in functions without explicitly calling disassembly methods, inspecting the binary target etc. You should be able to iterate instructions as easily as you iterate symbols.
Provide integration tests that verify that modified binaries are still useable. I'm not sure how to do this without having some sort of third-party emulation platform for an ARM64 system set up.
Anyone is welcome to contribute to DEAF, just try to follow the code of conduct and the contribution guidelines. If something is unclear or not covered in the guides, create an issue describing the problem and someone will get back to you as soon as possible.
Create an issue and @mjhouse to get my attention, or email me at mjhouse@protonmail.com.