/usr/lib/radare/bin/bindiff is in radare-common 1:1.5.2-6.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | #!/usr/bin/env perl
#
# Binary diff utility for radare
#
# NOTES
# - allow to handle big files with low memory footprint. ha ha ha
# - we have to do an adaptative diff method using bytediff+bindiff
#
# author: pancake <pancake@youterm.com>
# license: gpl (>=2)
#
my $a = $ARGV[0];
my $b = $ARGV[1];
my $ws = 1024*1024*5; # warning size (5M)
die "Usage: bindiff [a-file] [b-file]\n".
"f.e.: bindiff a.out b.out | rsc bdcolor 3\n"
if ($a eq "" or $b eq "" or $a eq "-h");
sub domybest {
unlink $tmpa;
unlink $tmpb;
exit 0;
}
$SIG{INT}=\&domybest;
sub bin_to_hex_column {
my($filename, $column) = @_;
open LOG, '>', $column || die "Cannot open $column";
open FD, '<', $filename || die "Cannot open $filename";
for(;;) {
last if 0 == read(FD, $buf, 1);
$str = sprintf("%02x\n", ord($buf));
print LOG $str;
}
close LOG;
close FD;
}
die "Cannot read any of these files.\n" unless (-r $a and -r $b);
print STDERR "Warning: Probably so big files to handle with gnu diff, try radiff -b\n"
if (-s $a > $ws or -s $b > $ws);
$tmpa="/tmp/.a.$$.".int rand(0xfef);
bin_to_hex_column($a, $tmpa);
$tmpb="/tmp/.b.$$.".int rand(0xefe);
bin_to_hex_column($b, $tmpb);
system("diff -yW 15 $tmpa $tmpb"); # | rsc bdcolor 3
domybest;
|