On Mon, 2 May 2011 17:50:48 -0400 (EDT)
Dave Anderson <[email protected]> wrote:

> Sorry to bother you all, but I'm failing miserably at searching for a
> tool to help analyze the structure of arbitrary files (prefereably one
> which runs on OpenBSD).
> 
> I've got a device which exports data in a undocumented format and the
> only program available to use that data doesn't do what I need, so I
> need to figure out the file formats so I can communicate with the device
> the way I need to.
> 
> What I'm looking for is an interactive program which makes it easy to
> look at selected parts of a file (individual items, sets of items
> located at regular intervals, sets of items linked by pointers or
> offsets, etc) in any of many formats (ascii, unicode, int, double float,
> etc) and either endianness, store comments about items or sets of items
> in an aux file, store names for various values in particular items and
> display those items values using those names, search for patterns at
> regular intervals or linked by pointers or offsets, etc, etc, etc; all
> those things which make it easier to discover and keep track of the
> structure of an unknown file.
> 
> It's hard to believe that nobody has ever written such a program, but
> I've been unable to find one.  Any suggestions for effective searches or
> for suitable programs would be appreciated.
> 
> Thanks,
> 
>       Dave
> 
> -- 
> Dave Anderson
> <[email protected]>
> 

Never heard of such a program.
I would use /usr/ports/editors/bvi, a hex editor, and Python, a very
high-level scripting language in which you can perform various
operations on data pretty easily.
 f = open('myfile.dat', 'rb')
 bytes = f.read(4)
 msg = 'first 4 bytes in hex: '
 for x in bytes:
     msg += hex(ord(x))[2:].upper()
 print msg
You could create a .py file with various useful functions, then start
up Python interpreter, import this file and explore the file
interactively by calling functions.
Conceive a theory by trying to think how would you create a file for
these purposes and by trying to see patterns in the file, test the
theory by changing the file one thing at a time, observe behavior,
repeat.

Reply via email to