File: bin_from_dump.pl

package info (click to toggle)
libdisasm 0.23-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 2,460 kB
  • ctags: 1,988
  • sloc: sh: 9,233; ansic: 7,971; perl: 1,915; asm: 694; makefile: 192; ruby: 3
file content (18 lines) | stat: -rw-r--r-- 348 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/perl

my $filename = shift;

open(INFILE, $filename);
open(OUTFILE, ">>bin.out");

foreach (<INFILE>) {
   if (/ [0-9a-fA-F]{7}:\s+(([0-9a-fA-F]{2}\s)+)\s+[A-z]+.*$/){
      $bytes = $1;
      $bytes =~ s/\s+$//g;
      foreach ( split(/ /, $bytes) ){
         printf OUTFILE "%c", hex($_);
      }
   }
}
close(INFILE);
close(OUTFILE);