Skip to content

Instantly share code, notes, and snippets.

@wideglide
Created March 26, 2019 01:31
Show Gist options
  • Save wideglide/0b2b91bf272c2443755433d38ffd8f72 to your computer and use it in GitHub Desktop.
Save wideglide/0b2b91bf272c2443755433d38ffd8f72 to your computer and use it in GitHub Desktop.
BinDiff scripts
#include <idc.idc>
static main() {
Batch(0);
Wait();
RunPlugin("zynamics_binexport_9", 2);
Exit(0);
}
#!/bin/bash
# A simple script to automate comparing two files
# - currently not very portable
# - currently using IDA Pro 6.95 and BinDiff 4.3
# - running on Ubuntu 16.04 host OS
IDC=/opt/zynamics/BinDiff/BinDiff.idc
TVHEADLESS=1
if [[ $# -eq 0 ]]; then
echo "Usage: $0 <PEfile1.exe> [ <PEfile2.exe> [ <workdir> ] ] "
fi
WK=/tmp/bd_results
if [[ $# -eq 3 ]]; then
echo "[*] using $3 as workdir"
WK=$3
fi
if [[ ! -e $WK ]]; then
mkdir $WK
fi
if [[ $# -gt 0 ]]; then
echo "[*] Processing $1"
f1=${1##*/}
if [ ! -f "${1%.*}.i64" ]; then
echo "[*] Creating IDB < ${1%.*}.i64 >"
xvfb-run --server-args="-screen 0 1024x768x24" -- idaq64 -B -R -P+ -c $1
fi
if [ ! -f "$WK/${f1%.*}.BinExport" ]; then
echo "[*] Creating BinExport file"
xvfb-run --server-args="-screen 0 1024x768x24" -- idaq64 -A -OExporterModule:$WK -OExporterLogFile:$WK/bd.log -S$IDC ${1%.*}.i64
fi
fi
if [[ $# -gt 1 ]]; then
echo "[*] Processing $2"
f2=${2##*/}
if [ ! -f "${2%.*}.i64" ]; then
echo "[*] Creating IDB < ${2%.*}.i64 >"
xvfb-run --server-args="-screen 0 1024x768x24" -- idaq64 -B -R -P+ -c $2
fi
if [ ! -f "$WK/${f2%.*}.BinExport" ]; then
echo "[*] Creating BinExport file"
xvfb-run --server-args="-screen 0 1024x768x24" -- idaq64 -A -OExporterModule:$WK -OExporterLogFile:$WK/bd.log -S$IDC ${2%.*}.i64
fi
echo "[*] Diffing $1 vs $2"
differ --primary=$WK/${f1%.*}.BinExport --secondary=$WK/${f2%.*}.BinExport --output_dir=$WK > $WK/diff.log
echo "[*] Diffing complete, zipping up results"
echo "${1##*/} ${2#*/}"
7za a ${f1%.*}-vs-${f2%.*}.7z $WK
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment