• Stars
    star
    1,167
  • Rank 40,028 (Top 0.8 %)
  • Language
    Rust
  • License
    MIT License
  • Created over 8 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An impish, cross-platform binary parsing crate, written in Rust

libgoblin

Actions crates.io version

say the right words

Documentation

https://docs.rs/goblin/

changelog

Usage

Goblin requires rustc 1.60.0 (Rust 2021 edition).

Add to your Cargo.toml

[dependencies]
goblin = "0.7"

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:

  1. Core, std-free #[repr(C)] structs, tiny compile time, 32/64 (or both) at your leisure.

  2. 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.rs for a basic example.

  3. std mode. This throws in read and write impls via Pread and Pwrite, reading from file, convenience allocations, extra methods, etc. This is for clients who can allocate and want to read binaries off disk.

  4. Endian_fd. A truly terrible name πŸ˜† 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):

  1. Write a compiler and use it to generate binaries (all the raw C structs have Pwrite derived).
  2. Write a binary analysis tool which loads, parses, and analyzes various binary formats, e.g., panopticon or falcon.
  3. Write a semi-functioning dynamic linker.
  4. Write a kernel and load binaries using no_std cfg. I.e., it is essentially just struct and const defs (like a C header) - no fd, no output, no std.
  5. 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
  • archive - a Unix Archive parser
  • endian_fd - parses according to the endianness in the binary
  • std - to allow no_std environments

Contributors

Thank you all ❀️ !

In lexicographic order:

Contributing

  1. Please prefix commits with the affected binary component; the more specific the better, e.g., if you only modify relocations in the elf module, then do "elf.reloc: added new constants for Z80"
  2. Commit messages must explain their change, no generic "changed", or "fix"; if you push commits like this on a PR, be aware @m4b or someone will most likely squash them.
  3. If you are making a large change to a module, please raise an issue first and lets discuss; I don't want to waste your time if its not a good technical direction, or etc.
  4. If your PR is not getting attention, please respond to all relevant comments raised on the PR, and if still no response, ping @m4b, @philipc, or @willglynn in github and also feel free to email @m4b.
  5. Please add tests if you are adding a new feature. Feel free to add tests even if you are not, tests are awesome and easy in rust.
  6. Once cargo format is officially released, please format your patch using the default settings.

More Repositories

1

bingrep

like ~~grep~~ UBER, but for binaries
Rust
1,704
star
2

faerie

Magical ELF and Mach-o object file writer backend
Rust
263
star
3

dryad

An almost-parallel, semi-functioning, dynamic linker experiment, written in Rust
Rust
162
star
4

scroll

Scroll - making scrolling through buffers fun since 2016
Rust
151
star
5

rdr

Rdr is a cross-platform binary analysis and reverse engineering library, utilizing a unique symbol map for global analysis.
OCaml
83
star
6

raml

OCaml runtime and FFI bindings directly in Rust
Rust
78
star
7

elf2json

Converts an ELF binary to a JSON representation
OCaml
32
star
8

bin2json

Converts ELF, mach-o, or PE binaries to a JSON representation
OCaml
29
star
9

cargo-sym

Prints various binary symbols in your crate
Rust
13
star
10

silicon-disassembler

A high-performance, asynchronous disassembler which uses capstone.js as the backend and Web Workers for non-blocking requests
HTML
11
star
11

compilers-vm

A sandmark VM, in OCaml. Very fast.
OCaml
8
star
12

lazy_transducer

Lazy, parallel, indexable, generic data iterators
Rust
7
star
13

apli

Haskell APL Interpreter - ver 0.1
Haskell
6
star
14

stackup

Statically modify a program binary's runtime stack size on Mac OS X --- without recompiling.
Swift
6
star
15

algos

Algebraic arithmetization of boolean algebra and its implementation.
OCaml
6
star
16

silicon-hex-table

An efficient web-component hex table for all your online hexadecimal needs.
HTML
4
star
17

cloaked-robot

compilers final project --- Data Flow
Haskell
3
star
18

silicon-instructions

Display assembly instructions in a list-like format, using highlight.js
CSS
3
star
19

paper-trek

Boldly going where no paper element has gone before!
JavaScript
2
star
20

derp-archer

Project 2: Grammar Analysis and Parsing, CS454/554
Haskell
2
star
21

dotfiles

dotfiles and other configuration files
Haskell
2
star
22

metagoblin

WIP: Provides abstracted meta information about a binary
Rust
1
star
23

element-party

The splash page for http://element-party.xyz --- for those times when you just need to party.
HTML
1
star
24

scroll_derive

Macros 1.1 implementing #[derive(Pread, Pwrite)]
Rust
1
star
25

m4b.github.io

HTML
1
star
26

chat

Simple OCaml chat program
OCaml
1
star
27

ms-present

Master's Examination slides
TeX
1
star
28

silicon-symbols

Displays a list of symbols
HTML
1
star
29

drag-drop-behaviors

HTML
1
star
30

topo-tango

NM Game Jam Topological Tango
Lua
1
star
31

silicon-upload

A simple binary upload widget, to deliver all those bits to the server of your choice
HTML
1
star
32

get-polymer-imports

Simple python script to get all the polymer imports from a bower_components directory
Python
1
star
33

avant-lexeme

haskell compilers project
Haskell
1
star
34

foiled

Scala Implementation of FOIL
Scala
1
star
35

silicon-image

Displays a rasterized binary image with `silicon-image-behavior`, to update binary offsets via mouse movement, and etc.
HTML
1
star