/usr/lib/radare/bin/rfile-foreach 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 | #!/usr/bin/env perl
#
# Apply a 'file' for every offset inside the target file
#
# author: pancake
#
die "Usage: rsc rfile-foreach [-h] [target-file] [start-offset]\n"
unless $ARGV[0] and $ARGV[0] ne "-h";
sub get_time {
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
return $sec+$min*60+$hour*360;
}
sub get_eta {
my ($now, $now2, $i, $size) = @_;
#10 ($now2-$now)
#$size-$i x
return (($size-$i)*($now2-$now))/10;
}
my $size = (stat $ARGV[0])[7];
my $offset = $ARGV[1]?$ARGV[1]:0;
my $eta = 0;
print "size $size\n";
$now = get_time();
for my $i ($offset .. $size) {
$str = qx(rsc rfile $ARGV[0] $i);
$now2 = get_time() unless ($i%10);
printf "\n0x%08x $str\n", $i unless $str=~/data$/;
$teta = get_eta($now, $now2, $i, $size) unless ($i%10);
$eta = $teta if ($teta != 0);
$now = $now2 unless ($i%10);
printf STDERR "\e[2K %d/%d eta: $eta secs \r", $i, $size;
}
|