Add to your
[dependencies] goblin = "0.0.10"
- awesome crate name
- the best, most feature complete ELF64/32 implementation, ever - now with auto type punning!
- zero-copy, cross-platform, endian-aware, 32/64 bit Mach-o parser - wow!
- PE 32/64-bit parser
- many cfg options - it will make your head spin, and make you angry when reading the source!
- goblins (TBA)
libgoblin aims to be your one-stop shop for binary parsing, loading,
Goblin primarily supports the following important use cases:
#[repr(C)]structs, tiny compile time, 32/64 (or both) at your leisure
Type punning. Define a function once on a type, but have it work on 32 or 64-bit variants - without really changing anything, and no macros! See
examples/automagic.rsfor a basic example.
stdmode. This throws in read and write impls via
Pwrite, reading from file, convenience allocations, extra methods, etc. This is for clients who can allocate and want to read binaries off disk.
Endian_fd. A truly terrible name :laughing: this is for binary analysis like in panopticon which needs to read binaries of foreign endianness, or as a basis for constructing cross platform foreign architecture binutils, e.g. cargo-sym and bingrep are simple examples of this, but the sky is the limit.
Here are some things you could do with this crate (or help to implement so they could be done):
- write a compiler and use it to generate binaries (all ELF32/64 have
- write a binary analysis tool which loads, parses, and analyzes various binary formats, e.g., panopticon
- write a semi-functioning dynamic linker
- write a kernel and load binaries using
no_stdcfg. I.e., it is essentially just struct and const defs (like a C header) - no fd, no output, no std.
- write a bin2json tool (http://github.com/m4b/bin2json), because why shouldn't binary formats be in JSON?
libgoblin is designed to be massively configurable. The current flags are:
- elf64 - 64-bit elf binaries,
- elf32 - 32-bit elf binaries,
- mach64 - 64-bit mach-o
- mach32 - 32-bit mach-o
- pe32 - 32-bit PE
- pe64 - 64-bit PE
- archive - a Unix Archive parser
- endian_fd - parses according to the endianness in the binary
- std - to allow