Perl Parser

June 8, 2008 1:42 pm

I love perl. Its great for parsing files, even binary files. The ParseBin.zip zip file contains a perl script I wrote (releasing under GPL 2.0).

The script file basically attempts to parse the binary file, looking for sections. It will keep track of section location and size, print out information on the section, print individual section types and even dump or ignore sections at a given location. The command line arguments to the script are:

./parsebin.pl [-h -s [-i Location] [-p Section] [-d Location]] BINFILE  SECFILE
        -s: Print Strings as well
        -i [Location]: Ignore (dont print) the section at [Location]. Can be used multiple times.
        -p [Section]: print a section. ALL for all. Can be used multiple times
        -d [Location]: Dump the section at location to a new file. 

Its not pretty but it works for now. This will evolve to allow individual sections to be diffed between different firmware versions. For now, its a tool to investigate the firmware sections. The sections.txt file I use contains CMbP, CMbT, CMbM and CMbH, each on their own line.

The Section Info zip file contains the dumps of the script when ran against the s14v101.bin and s14v102.bin files. The sections look pretty smiliar. There are a couple large sections that I’ll want to look at closer. The -d option to the script will help here.

No Responses to “Perl Parser”

Care to comment?