Log in

View Full Version : I cannot seem to find a tools to read elf files the way I want them


handlec
December 29th, 2005, 18:02
Hello!

I have a really simple question. I disassembled a file using insight under linux, and I determined that the following location has to be modified:

0x804a4b5 <main+101>: call 0x8164b30 <c2init>

Now, the address here is the virtual address, hoever I need to lacate this in the binary elf file using emacs orsomething. How do I go about finding 0x804ab5 <main+101> in an elf file ? I know this is stupid question, but I amreally stuck. Thanks.

Admiral
December 29th, 2005, 19:54
I'm sure this is explained in several locations linked in the FAQ, but I'll provide an answer anyway.

Read up on the ELF format and how file offsets translate to RVAs and VAs (if you haven't already done so). The most accurate way to deal with this problem is to load your target up in an ELF editor, find which section's image your VA loads into, subtract (your VA from the section's base VA) to find the offset into the section, then add this to the section's 'pointer to raw data'.

However, in practice it is often quicker and/or easier to find a unique-looking byte pattern in the virtual image and search for that in the disk image. Usually eight bytes or so is enough to get you to the right spot (but of course, you should use 'Find Next' to make sure you're in the right place).

By the way. If this question belongs anywhere (other than the FAQ) it's 'The Newbies Forum' or 'Linux RCE', not 'Advanced reversing and programming' .

Admiral

handlec
December 30th, 2005, 04:18
Thanks a lot.

blabberer
December 30th, 2005, 05:50
there is a pretty neat hexeditor called HT Editor

http://hte.sourceforge.net/

it can show the image as well as file forum

for example ./ht --> alt+f --> open --> select your binary --> f6 --> selecting elf image

Code:

804863c ! call newtInit │
│ 8048641 ! call newtCls │
│ 8048646 ! sub esp, 4 │
│ 8048649 ! push strz_Some_root_text_80487e8


hit f6--> disasm.x86

Code:

│0000063c e813ffffff call 0x554 -
│00000641 e8aefeffff call 0x4f4
│00000646 83ec04 sub esp, 0x4
│00000649 68e8870408 push 080487e8


alt+l (local disasm) -->assemble
change call 554 to call 555 or whatever you want

Code:

│0000063c e814ffffff call 0x555 -
│00000641 e8aefeffff call 0x4f4



and use f2 to save

handlec
December 30th, 2005, 10:54
Thanks blabberer