8 releases

new 0.1.8 Jan 19, 2025
0.1.7 Jan 19, 2025

#768 in Filesystem

Download history 114/week @ 2025-01-13

114 downloads per month

MIT/Apache

71KB
622 lines

Logo

bindiff-rs

Rust library to interface with BinDiff


Usage

use bindiff::BinDiff;

fn main() -> anyhow::Result<()> {
    let input_path = std::env::args().nth(1)
        .ok_or_else(|| anyhow::anyhow!("Please provide a path to a BinDiff file"))?;
    let bd = BinDiff::open(&input_path)?;

    // Read function matches
    let func_matches = bd.read_function_matches()?;
    for func_match in func_matches {
        println!("{:#?}", func_match);
    }

    Ok(())
}

Install bindiff-rs binary

Via homebrew

brew install blacktop/tap/bindiff-rs

Via cargo

cargo install bindiff-rs

Run bindiff-rs

Dump the BinDiff file metadata

 bindiff-rs path/to/BinDiff --info
FILE:
  id:               1
  filename:         kernel.release
  exe_filename:     kernel.release.t6020
  hash:             8a9f5d9305cec0a85bbaae3288ef3a5732bda406edcf20aa6edd9352fb555de0
  functions:        22140
  lib_functions:    0
  calls:            229914
  basic_blocks:     1037258
  lib_basic_blocks: 0
  edges:            1546378
  lib_edges:        0
  instructions:     4958934
  lib_instructions: 0

METADATA:
  version:      BinDiff 8 (@568181968, Sep 25 2023)
  file1:        1
  file2:        2
  description:
  created:      2025-01-12 23:51:57
  modified:     2025-01-12 23:51:57
  similarity:   0.99
  confidence:   0.99

Dump the BinDiff file function matches

 bindiff-rs path/to/BinDiff
memset_s:       similarity: 1.00, confidence: 0.99
timingsafe_bcmp:        similarity: 1.00, confidence: 0.99
cc_clear:       similarity: 1.00, confidence: 0.99
cc_disable_dit: similarity: 1.00, confidence: 0.97
ccdigest_init:  similarity: 1.00, confidence: 0.99
ccdigest_update:        similarity: 1.00, confidence: 0.99
cchmac: similarity: 1.00, confidence: 0.99
cchmac_init:    similarity: 1.00, confidence: 0.99
cchmac_update:  similarity: 1.00, confidence: 0.99
cchmac_final:   similarity: 1.00, confidence: 0.99
ccdigest_final_64be:    similarity: 1.00, confidence: 0.99
_ovbcopy:       similarity: 1.00, confidence: 0.99
_memmove:       similarity: 1.00, confidence: 0.99
_bzero: similarity: 1.00, confidence: 0.99
_memset:        similarity: 1.00, confidence: 0.99
<SNIP>

Dump the BinDiff file function matches in JSON format

 bindiff-rs path/to/BinDiff --json
[
  {
    "id": 1,
    "address1": -2198902980608,
    "name1": "memset_s",
    "address2": -2198902980608,
    "name2": "memset_s",
    "similarity": 1.0,
    "confidence": 0.9933071490757153,
    "flags": 0,
    "algorithm": "NameHashMatching",
    "evaluate": false,
    "comment_supported": false,
    "basic_blocks": 6,
    "edges": 7,
    "instructions": 21
  },
  <SNIP>
]

License

MIT Copyright (c) 2025 blacktop

Dependencies

~33MB
~542K SLoC