📚 OpenRCE is preserved as a read-only archive. Launched at RECon Montreal in 2005. Registration and posting are disabled.








Flag: Tornado! Hurricane!

 Forums >>  Target Specific - General  >>  Strings on ARM bootloader

Topic created on: April 2, 2007 04:18 CDT by trufae .

I'm analyzing an ARM bootloader that contain strings, but IDA seems not to find correctly the xrefs.

I've been analyzing the code with radare and I got that the four initial bytes are the offset where the code starts, defining this address as base in IDA the disassembly looks fine ( so it's 4-byte aligned ), but I'm unable to find any reference to the strings.

Is there any methodology or technique to find xrefs of strings on raw binaries? Maybe these strings are referenced with absolute addresses in memory.

Anybody experienced with bootloaders on embedded devices?

  igorsk     April 2, 2007 08:01.52 CDT
One common ARM idiom IDA currently doesn't parse properly is the following:


MOV Rx, =delta
<optional code>
ADD Ry, PC, Rx
<use Ry>


Which obviously should be interpreted as:

MOV Rx, =target-(label+8)
<optional code>
ADD Ry, PC, Rx
label:
<use Ry>


So, check if the code has anything like that. You could also upload the binary and we all could have a look at it.

  itsme     April 2, 2007 12:48.42 CDT
is it for a windows ce device?
( at offset 0x40 there will be a signature 'ECEC', followed by a ptr to a ROMHDR struct )

in that case, you can use dumpxip.pl to figure out what address the bootloader is based on.

another thing to be aware of, is that usually a part of the bootloader will execute in physical address mode, and part in virtual address mode.

  trufae   April 2, 2007 14:39.30 CDT
Hi itsme! :)

Nope, it's not htc. But I can't reveal the source.

The bootloader is splitted in three pieces, they're flashed together, but each piece is independent from each other.

I'm just reading the second one but all of them looks pretty similar:

[8 bytes] - in little endian defining the starting address.
..padding..
[initial-offset]
[code]
[strings]

How can I know what's the physical address and the virtual one? looking for hardcoded absolute addresses?

----

igorsk: I got some "LDR Rx, =delta", but no "MOV Rx, =delta", I should guess that LDR is the 32 bit safe addressing for absolute values, right? The delta offsets look like:

  LDR R0, =0x20003FF0

There'r some relative:

  LDR R0, =0xFFFFFE80

I've manually calculated the relative offset and it exactly points to a subroutine (which shifts R1->R0, R2->R1 and jumps where R0 says (PC=R0)).

IDA doesn't handles this relative offset, so AFAIK most of arm reversing must be done by hand.

I've tried to substract the higher part of the absolute offsets to get 0x3FF0, but this value points out of the file :/ (i've substracted the base address of the entry point and stills out).

Maybe the base address of the program in memory is higher than the physical one in file, so this is the second piece because the first one has no strings.. Maybe I should read the first piece to understand how it loads the rest.

Any idea?

  itsme     April 3, 2007 03:55.16 CDT
why do you think "LDR R0,=0xFFFFFE80"  is relative?
it could be an ioport address, for instance with the omap chipsets there is io mapped in the area from 0xfff00000 and up. ( the highest address i could find for omap is 0xfffffe03 )

what i would do to find the base address, is create a list of dword constants referenced in the disassembly,
sort them, calculate the differences between consecutive offsets.

then do the same with subroutine start addresses, and string addresses, also calculate the difference between consecutive offsets.

then try to find matching sequences in these difference lists.

this way you may discover non-linear mappings of the real offsets to the file offsets.
( for instance when the code you are looking at is relocated to different addresses in ram or so, or if you are looking at some not yet completely understood fileformat )

  lukealf     June 7, 2008 13:50.25 CDT
>Itsme:

Can you explain your question more specificallay?


............................
http://www.optimize-your-pc.com/

trufae: Hi itsme! :)
>
> Nope, it\'s not htc. But I can\'t reveal the source.
>
> The bootloader is splitted in three pieces, they\'re flashed together, but each piece is independent from each other.
>
> I\'m just reading the second one but all of them looks pretty similar:
>
> [8 bytes] - in little endian defining the starting address.
> ..padding..
> [initial-offset]
> [code]
> [strings]
>
> How can I know what\'s the physical address and the virtual one? looking for hardcoded absolute addresses?
>
> ----
>
> igorsk: I got some \"LDR Rx, =delta\", but no \"MOV Rx, =delta\", I should guess that LDR is the 32 bit safe addressing for absolute values, right? The delta offsets look like:
>
>   LDR R0, =0x20003FF0
>
> There\'r some relative:
>
>   LDR R0, =0xFFFFFE80
>
> I\'ve manually calculated the relative offset and it exactly points to a subroutine (which shifts R1->R0, R2->R1 and jumps where R0 says (PC=R0)).
>
> IDA doesn\'t handles this relative offset, so AFAIK most of arm reversing must be done by hand.
>
> I\'ve tried to substract the higher part of the absolute offsets to get 0x3FF0, but this value points out of the file :/ (i\'ve substracted the base address of the entry point and stills out).
>
> Maybe the base address of the program in memory is higher than the physical one in file, so this is the second piece because the first one has no strings.. Maybe I should read the first piece to understand how it loads the rest.
>
> Any idea?

  itsme     June 7, 2008 23:15.29 CDT
try my setdataofs.idc script, the 'setregofs' function.

see http://www.xs4all.nl/~itsme/projects/ida/idcscripts.html

usage:
select the entire code section, and press 'shift-V'

be sure to first make a copy of your db, in case you don't like the result.

Note: Registration is required to post to the forums.

There are 31,328 total registered users.


Recently Created Topics
[help] Unpacking VMP...
Mar/12
Reverse Engineering ...
Jul/06
let 'IDAPython' impo...
Sep/24
set 'IDAPython' as t...
Sep/24
GuessType return une...
Sep/20
About retrieving the...
Sep/07
How to find specific...
Aug/15
How to get data depe...
Jul/07
Identify RVA data in...
May/06
Question about memor...
Dec/12


Recent Forum Posts
Finding the procedur...
rolEYder
Question about debbu...
rolEYder
Identify RVA data in...
sohlow
let 'IDAPython' impo...
sohlow
How to find specific...
hackgreti
Problem with ollydbg
sh3dow
How can I write olly...
sh3dow
New LoadMAP plugin v...
mefisto...
Intel pin in loaded ...
djnemo
OOP_RE tool available?
Bl4ckm4n


Recent Blog Entries
halsten
Mar/14
Breaking IonCUBE VM

oleavr
Oct/24
Anatomy of a code tracer

hasherezade
Sep/24
IAT Patcher - new tool for ...

oleavr
Aug/27
CryptoShark: code tracer ba...

oleavr
Jun/25
Build a debugger in 5 minutes

More ...


Recent Blog Comments
nieo on:
Mar/22
IAT Patcher - new tool for ...

djnemo on:
Nov/17
Kernel debugger vs user mod...

acel on:
Nov/14
Kernel debugger vs user mod...

pedram on:
Dec/21
frida.github.io: scriptable...

capadleman on:
Jun/19
Using NtCreateThreadEx for ...

More ...


Imagery
SoySauce Blueprint
Jun 6, 2008

[+] expand

View Gallery (11) / Submit