Goblin
An impish, cross-platform binary parsing crate, written in Rust
Install / Use
/learn @m4b/GoblinREADME
libgoblin
<!-- Badges' links -->
Documentation
https://docs.rs/goblin/
Usage
Goblin requires rustc 1.85.0 (Rust 2024 edition).
Add to your Cargo.toml
[dependencies]
goblin = "0.10"
Features
- awesome crate name
- zero-copy, cross-platform, endian-aware, ELF64/32 implementation - wow!
- zero-copy, cross-platform, endian-aware, 32/64 bit Mach-o parser - zoiks!
- PE 32/64-bit parser - bing!
- a Unix and BSD style archive parser (latter courtesy of [@willglynn]) - huzzah!
- many cfg options - it will make your head spin, and make you angry when reading the source!
- fuzzed - "I am happy to report that goblin withstood 100 million fuzzing runs, 1 million runs each for seed 1~100." - @sanxiyn
- tests
libgoblin aims to be your one-stop shop for binary parsing, loading, and analysis.
Use-cases
Goblin primarily supports the following important use cases:
-
Core, std-free
#[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 viaPreadandPwrite, 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 or falcon 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 the raw C structs have
Pwritederived). - Write a binary analysis tool which loads, parses, and analyzes various binary formats, e.g., panopticon or falcon.
- 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, because why shouldn't binary formats be in JSON?
Cfgs
libgoblin is designed to be massively configurable. The current flags are:
- elf64 - 64-bit elf binaries,
repr(C)struct defs - elf32 - 32-bit elf binaries,
repr(C)struct defs - mach64 - 64-bit mach-o
repr(C)struct defs - mach32 - 32-bit mach-o
repr(C)struct defs - pe32 - 32-bit PE
repr(C)struct defs - pe64 - 64-bit PE
repr(C)struct defs
- te - Terse Executable (TE)
repr(C)struct defs
- archive - a Unix Archive parser
- endian_fd - parses according to the endianness in the binary
- std - to allow
no_stdenvironments
Maintainers
- PE: @kkent030315
- Elf: @m4b, open for applications
- Mach-o: @m4b, open for applications
Maintainers are first contact reviewers for that particular backend. They are chosen based on prior contributions, activity, base knowledge, and amicable and gregarious behavior :D
Currently, I (@m4b) only have merge rights for all PRs. In the future it is likely, that the maintainer(s) for that given backend will also have merge rights as well.
Lastly, I will still likely give cursory reviews to all PRs, but will mostly/entirely default to the maintainer for that backend.
And always remember the wisdom of Bill and Ted: "Be excellent to each other!"
Contributors
Thank you all :heart: !
In lexicographic order:
- @000lbh
- @2vg
- @5225225
- @alessandrod
- @amanieu
- @anfedotoff
- @apalm
- @baloo
- @BinFlip
- @burjui
- @chf0x
- @connorkuehl
- @dancrossnyc
- @DreydenGys
- @dureuill
- @Evian-Zhang
- @ExPixel
- @flanfly
- @glandium
- @glslang
- @Gelbpunkt
- @gunbux
- @h33p
- @hannahfluch
- @Hexorg
- @ibabushkin
- @ideeockus
- @ivlzme
- @jackcmay
- @jan-auer
- @Javagedes
- @jessehui
- @jdub
- @Jhynjhiruu
- @johannst
- @JohnScience
- @joschock
- @jrmuizel
- @jsgf
- @Jvlegod
- @keith
- @kjempelodott
- @kkent030315
- @ko1n
- @le-jzr
- @Lichtso
- @lion128
- @lissyx
- @llogiq
- @lumag
- @lzutao
- @lzybkr
- @m-hilgendorf
- @makubacki
- @mmaekr
- @m4b
- @messense
- @mitsuhiko
- @mkroening
- @mre
- @Mrmaxmeier
- n01e0
- nathaniel-daniel
- @nick96
- @nico-abram
- @npmccallum
- @pchickey
- @philipc
- @PJB3005
- @prettyroseslover
- @Pzixel
- @quake
- @raindev
- @RaitoBezarius
- @ReturnRei
- @rocallahan
- @sanxiyn
- @skdltmxn
- @sollyucko
- @Swatinem
- @SweetVishnya
- @SquareMan
- @tathanhdinh
- @Techno-coder
- @tiann
- @ticki
- @Timmmm
- @Tiwalun
- @track-5
- @tux3
- @wickerwacka
- [@willglynn]
- [@woodruffw]
- [@wyxloading]
- [@xcoldhandsx]
- [@x0rb3l]
- [@x64k]
[@wi
Related Skills
node-connect
350.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
350.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
350.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
