• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

src/H03-May-2022-18,53913,293

tests/bins/elf/gnu_hash/H03-May-2022-113103

.cargo-checksum.jsonH A D03-May-202289 11

.cargo_vcs_info.jsonH A D01-Jan-197074 65

CHANGELOG.mdH A D29-Nov-197314.7 KiB289245

Cargo.lockH A D01-Jan-19702.1 KiB8978

Cargo.tomlH A D01-Jan-19701.7 KiB5348

Cargo.toml.orig-cargoH A D29-Nov-19731.3 KiB5650

LICENSEH A D29-Nov-19731 KiB2217

README.mdH A D29-Nov-19737.6 KiB230194

README.md

1# libgoblin
2
3[![Actions][actions-badge]][actions-url]
4[![crates.io version][crates-goblin-badge]][crates-goblin]
5
6<!-- Badges' links -->
7
8[actions-badge]: https://github.com/m4b/goblin/workflows/CI/badge.svg?branch=master
9[actions-url]: https://github.com/m4b/goblin/actions
10[crates-goblin-badge]: https://img.shields.io/crates/v/goblin.svg
11[crates-goblin]: https://crates.io/crates/goblin
12
13![say the right words](https://s-media-cache-ak0.pinimg.com/736x/1b/6a/aa/1b6aaa2bae005e2fed84b1a7c32ecb1b.jpg)
14
15### Documentation
16
17https://docs.rs/goblin/
18
19[changelog](CHANGELOG.md)
20
21### Usage
22
23Goblin requires `rustc` 1.40.0.
24
25Add to your `Cargo.toml`
26
27```toml
28[dependencies]
29goblin = "0.4"
30```
31
32### Features
33
34* awesome crate name
35* zero-copy, cross-platform, endian-aware, ELF64/32 implementation - wow!
36* zero-copy, cross-platform, endian-aware, 32/64 bit Mach-o parser - zoiks!
37* PE 32/64-bit parser - bing!
38* a Unix _and_ BSD style archive parser (latter courtesy of [@willglynn]) - huzzah!
39* many cfg options - it will make your head spin, and make you angry when reading the source!
40* fuzzed - "I am happy to report that goblin withstood 100 million fuzzing runs, 1 million runs
41  each for seed 1\~100." - [@sanxiyn]
42* tests
43
44`libgoblin` aims to be your one-stop shop for binary parsing, loading, and analysis.
45
46### Use-cases
47
48Goblin primarily supports the following important use cases:
49
501. Core, std-free `#[repr(C)]` structs, tiny compile time, 32/64 (or both) at your leisure.
51
521. Type punning. Define a function once on a type, but have it work on 32 or 64-bit variants -
53   without really changing anything, and no macros! See `examples/automagic.rs` for a basic example.
54
551. `std` mode. This throws in read and write impls via `Pread` and `Pwrite`, reading from file,
56   convenience allocations, extra methods, etc. This is for clients who can allocate and want to
57   read binaries off disk.
58
591. `Endian_fd`. A truly terrible name :laughing: this is for binary analysis like in [panopticon]
60   or [falcon] which needs to read binaries of foreign endianness, _or_ as a basis for
61   constructing cross platform foreign architecture binutils, e.g. [cargo-sym] and [bingrep] are
62   simple examples of this, but the sky is the limit.
63
64Here are some things you could do with this crate (or help to implement so they could be done):
65
661. Write a compiler and use it to [generate binaries][faerie] (all the raw C structs have
67   [`Pwrite`][scroll] derived).
681. Write a binary analysis tool which loads, parses, and analyzes various binary formats, e.g.,
69   [panopticon] or [falcon].
701. Write a [semi-functioning dynamic linker][dryad].
711. Write a [kernel][redox-os] and load binaries using `no_std` cfg. I.e., it is essentially just
72   struct and const defs (like a C header) - no fd, no output, no std.
731. Write a [bin2json] tool, because why shouldn't binary formats be in JSON?
74
75<!-- Related projects  -->
76
77[PyO3/maturin]: https://github.com/PyO3/maturin
78[occlum]: https://github.com/occlum/occlum
79[memflow]: https://github.com/memflow/memflow
80[cargo-sym]: https://github.com/m4b/cargo-sym
81[bingrep]: https://github.com/m4b/bingrep
82[faerie]: https://github.com/m4b/faerie
83[dryad]: https://github.com/m4b/dryad
84[scroll]: https://github.com/m4b/scroll
85[redox-os]: https://github.com/redox-os/redox
86[bin2json]: https://github.com/m4b/bin2json
87[panopticon]: https://github.com/das-labor/panopticon
88[falcon]: https://github.com/endeav0r/falcon
89
90### Cfgs
91
92`libgoblin` is designed to be massively configurable. The current flags are:
93
94* elf64 - 64-bit elf binaries, `repr(C)` struct defs
95* elf32 - 32-bit elf binaries, `repr(C)` struct defs
96* mach64 - 64-bit mach-o `repr(C)` struct defs
97* mach32 - 32-bit mach-o `repr(C)` struct defs
98* pe32 - 32-bit PE `repr(C)` struct defs
99* pe64 - 64-bit PE `repr(C)` struct defs
100* archive - a Unix Archive parser
101* endian_fd - parses according to the endianness in the binary
102* std - to allow `no_std` environments
103
104# Contributors
105
106Thank you all :heart: !
107
108In lexicographic order:
109
110- [@2vg]
111- [@amanieu]
112- [@burjui]
113- [@connorkuehl]
114- [@dancrossnyc]
115- [@ExPixel]
116- [@Evian-Zhang]
117- [@flanfly]
118- [@glandium]
119- [@ibabushkin]
120- [@jackcmay]
121- [@jan-auer]
122- [@jessehui]
123- [@jdub]
124- [@johannst]
125- [@jrmuizel]
126- [@jsgf]
127- [@keith]
128- [@kjempelodott]
129- [@ko1n]
130- [@le-jzr]
131- [@Lichtso]
132- [@lion128]
133- [@llogiq]
134- [@lzutao]
135- [@lzybkr]
136- [@m4b]
137- [@messense]
138- [@mitsuhiko]
139- [@mre]
140- [@Mrmaxmeier]
141- [@nico-abram]
142- [@npmccallum]
143- [@pchickey]
144- [@philipc]
145- [@Pzixel]
146- [@quake]
147- [@raindev]
148- [@rocallahan]
149- [@sanxiyn]
150- [@sollyucko]
151- [@tathanhdinh]
152- [@Techno-coder]
153- [@ticki]
154- [@Timmmm]
155- [@Tiwalun]
156- [@wickerwacka]
157- [@willglynn]
158- [@woodruffw]
159- [@wyxloading]
160- [@xcoldhandsx]
161
162<!-- Contributors -->
163
164[@2vg]: https://github.com/2vg
165[@amanieu]: https://github.com/amanieu
166[@burjui]: https://github.com/burjui
167[@connorkuehl]: https://github.com/connorkuehl
168[@dancrossnyc]: https://github.com/dancrossnyc
169[@Evian-Zhang]: https://github.com/Evian-Zhang
170[@ExPixel]: https://github.com/ExPixel
171[@flanfly]: https://github.com/flanfly
172[@glandium]: https://github.com/glandium
173[@ibabushkin]: https://github.com/ibabushkin
174[@jackcmay]: https://github.com/jackcmay
175[@jan-auer]: https://github.com/jan-auer
176[@jessehui]: https://github.com/jessehui
177[@johannst]: https://github.com/johannst
178[@jdub]: https://github.com/jdub
179[@jrmuizel]: https://github.com/jrmuizel
180[@jsgf]: https://github.com/jsgf
181[@keith]: https://github.com/keith
182[@kjempelodott]: https://github.com/kjempelodott
183[@ko1N]: https://github.com/ko1N
184[@le-jzr]: https://github.com/le-jzr
185[@Lichtso]: https://github.com/Lichtso
186[@lion128]: https://github.com/lion128
187[@llogiq]: https://github.com/llogiq
188[@lzutao]: https://github.com/lzutao
189[@lzybkr]: https://github.com/lzybkr
190[@m4b]: https://github.com/m4b
191[@messense]: https://github.com/messense
192[@mitsuhiko]: https://github.com/mitsuhiko
193[@mre]: https://github.com/mre
194[@Mrmaxmeier]: https://github.com/Mrmaxmeier
195[@nico-abram]: https://github.com/nico-abram
196[@npmccallum]: https://github.com/npmccallum
197[@pchickey]: https://github.com/pchickey
198[@philipc]: https://github.com/philipc
199[@Pzixel]: https://github.com/Pzixel
200[@quake]: https://github.com/quake
201[@raindev]: https://github.com/raindev
202[@rocallahan]: https://github.com/rocallahan
203[@sanxiyn]: https://github.com/sanxiyn
204[@sollyucko]: https://github.com/sollyucko
205[@tathanhdinh]: https://github.com/tathanhdinh
206[@Techno-coder]: https://github.com/Techno-coder
207[@ticki]: https://github.com/ticki
208[@Timmmm]: https://github.com/Timmmm
209[@Tiwalun]: https://github.com/Tiwalun
210[@wickerwacka]: https://github.com/wickerwaka
211[@willglynn]: https://github.com/willglynn
212[@woodruffw]: https://github.com/woodruffw
213[@wyxloading]: https://github.com/wyxloading
214[@xcoldhandsx]: https://github.com/xcoldhandsx
215
216## Contributing
217
2181. Please prefix commits with the affected binary component; the more specific the better, e.g.,
219   if you only modify relocations in the elf module, then do "elf.reloc: added new constants for Z80"
2201. Commit messages must explain their change, no generic "changed", or "fix"; if you push commits
221   like this on a PR, be aware [@m4b] or someone will most likely squash them.
2221. If you are making a large change to a module, please raise an issue first and lets discuss;
223   I don't want to waste your time if its not a good technical direction, or etc.
2241. If your PR is not getting attention, please respond to all relevant comments raised on the PR,
225   and if still no response, ping [@m4b], [@philipc], or [@willglynn] in github and also feel free
226   to email [@m4b].
2271. Please add tests if you are adding a new feature. Feel free to add tests even if you are not,
228   tests are awesome and easy in rust.
2291. Once cargo format is officially released, please format your _patch_ using the default settings.
230