# binparse
A colorful, user-friendly alternative to `readelf` for analyzing ELF binaries.
binparse provides beautiful colored terminal output with human-readable descriptions of all ELF structures including headers, segments, sections, and symbols. It supports both 32-bit and 64-bit ELF files with little and big endian byte ordering.
## Installation
### From Cargo
```bash
cargo install binparse
```
### From source
```bash
git clone https://github.com/kunalsinghdadhwal/binparse.git
cd binparse
cargo build --release
```
The binary will be available at `target/release/binparse`.
### Install globally
```bash
cargo install --path .
```
## Usage
```bash
binparse [OPTIONS] <FILE>
```
### Options
| `-H` | `--header` | Display ELF header |
| `-p` | `--segments` | Display program headers (segments) |
| `-s` | `--sections` | Display section headers |
| | `--symbols` | Display symbol tables |
| `-a` | `--all` | Display all information |
| `-h` | `--help` | Print help |
| `-V` | `--version` | Print version |
### Examples
Display ELF header (default behavior):
```bash
binparse /usr/bin/ls
```
Display program headers:
```bash
binparse -p /usr/bin/ls
```
Display section headers:
```bash
binparse -s /usr/bin/ls
```
Display symbol tables:
```bash
binparse --symbols /usr/bin/ls
```
Display all information:
```bash
binparse -a /usr/bin/ls
```
Combine multiple options:
```bash
binparse -H -p -s /usr/bin/ls
```
## Sample Output
```
File: /usr/bin/ls
Size: 142312 bytes
Format: 64-bit, little endian, System V
ELF Header
e_ident
Magic: (ELF) (7F 45 4C 46)
Class (EI_CLASS): 64-bit (2)
Data (EI_DATA): little endian (1)
Version (EI_VERSION): current (1)
OS/ABI (EI_OSABI): System V (0)
ABI Version (EI_ABIVERSION): 0
Core
Type (e_type): Shared object file - ET_DYN (0x0003)
Machine (e_machine): AMD x86-64 (0x003E)
Version (e_version): 1 (current) (0x00000001)
Flags (e_flags): none (0x00000000)
ELF Header Size (e_ehsize): 64 bytes
Addresses / Offsets
Entry Point (e_entry): 0x0000000000006D30
Program Headers Offset (e_phoff): 0x0000000000000040
Section Headers Offset (e_shoff): 0x0000000000022428
Program Header Size (e_phentsize): 56 bytes
Program Header Count (e_phnum): 13
Section Header Size (e_shentsize): 64 bytes
Section Header Count (e_shnum): 31
Section Name String Table Index (e_shstrndx): 30
```
## Features
- Full ELF header analysis with e_ident, core fields, and address/offset information
- Program header (segment) display with human-readable type descriptions
- Section header display with names resolved from .shstrtab
- Symbol table display for both .symtab and .dynsym
- Human-readable decoding of:
- Machine architectures (x86, x86-64, ARM, AArch64, RISC-V, and 50+ others)
- OS/ABI identifiers (System V, Linux, FreeBSD, etc.)
- Segment types (PT_LOAD, PT_DYNAMIC, PT_GNU_STACK, etc.)
- Section types and flags
- Symbol types, bindings, and visibility
- Colored output for improved readability
- Graceful error handling for invalid or unsupported files
## Dependencies
- [clap](https://crates.io/crates/clap) - Command-line argument parsing
- [colored](https://crates.io/crates/colored) - Terminal colors
- [goblin](https://crates.io/crates/goblin) - Binary format parsing
- [thiserror](https://crates.io/crates/thiserror) - Error handling
## Comparison with readelf
| Colored output | Yes | No |
| Human-readable descriptions | Yes | Limited |
| ELF header | Yes | Yes |
| Program headers | Yes | Yes |
| Section headers | Yes | Yes |
| Symbol tables | Yes | Yes |
| Relocations | No | Yes |
| Dynamic section | No | Yes |
| Notes | No | Yes |
| Version info | No | Yes |