libredwg
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libredwg] Resources and tips on binary data reverse engineering


From: Dave Coventry
Subject: Re: [libredwg] Resources and tips on binary data reverse engineering
Date: Tue, 5 Jun 2012 22:14:14 +0200

On 5 June 2012 21:39, Felipe Castro <address@hidden> wrote:
> Hello, I just want to share this with you:
> http://www.iwriteiam.nl/Ha_HTCABFF.html
> Historical interest here: this guy worked on R12 and R13 formats of DWG.
>
> I found this searching in WotSit:
> http://www.wotsit.org/list.asp?fc=19
>
> Cheers,
> Felipe Castro.
>

Hi, thanks Felipe!

If it helps anybody I have a short app in Pascal which generates a
dump from the binary file as csv file.

procedure TForm1.Button1Click(Sender: TObject);
var
  Ifile: File;
  TeFile: TextFile;
  byteArray : array[0..1] of byte;
  savestring, s: string;
  P: PChar;
  cnt: integer;
begin
  OpenDialog1.Title:='Select the file to dump';
  if OpenDialog1.Execute then
  begin
    AssignFile(Ifile,OpenDialog1.FileName);
    P := StrRScan(PChar(OpenDialog1.FileName), '.');
    P[0]:=#0;
    SaveDialog1.FileName:=OpenDialog1.FileName;
    if SaveDialog1.Execute then
    begin
      Reset(Ifile,1);

      AssignFile(TeFile,SaveDialog1.Filename);
      Rewrite(TeFile);
      cnt:=1;
      while not EOF(Ifile)do
      begin
        BlockRead(Ifile,byteArray,1);
        if((byteArray[0]<128)and(byteArray[0]>31))then
s:=chr(byteArray[0]) else s:='';
        if byteArray[0]=34 then s:='\"';
        
savestring:=IntToHex(cnt,0)+','+IntToHex(byteArray[0],2)+','+IntToStr(byteArray[0])+','+s;
        Inc(cnt);
        WriteLn(TeFile,savestring);
      end;
      CloseFile(Ifile);
      CloseFile(TeFile);
    end;
  end;
end;

It's not elegant coding and very amateurism, but what it does is
generate a csv file with each byte given a row with the following
fields:

1. the offset of the byte in hex.
2. the value of the byte in hex
3. the value of the byte in decimal
4 the ascii of the byte.

Then I open the csv in a spreadsheet and add notes, track pointers and
colour the cells. For example, a 16 byte sentinel will be coloured in
magenta and a 4 byte raw integer might be coloured cyan.

As I say, the above code is in Pascal (compiled with Lazarus (
http://www.lazarus.freepascal.org/ ) but you could write a small
script  in Perl, Python or C that would do the same thing.

Please forgive me for posting this: I'm sure the majority of libredwg
coders already do something similar, if not a lot more advanced,
however if this helps anyone in their endeavours I'd be very pleased.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]