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








Flag: Tornado! Hurricane!

 Forums >>  IDA Pro  >>  MIPS disassembling - Simple script to jump to offset

Topic created on: August 5, 2008 07:45 CDT by bramp .

Hi, I have been disassembling a MIPS program I pulled off a linux router. IDA Pro disassembles a lot of it correctly; however there are a couple of problems. One of the problems I�ve been fixing by hand, but it�s going to take a long time, and I thought I might try and write a IDC script to fix it for me. So if anyone could provide me with a sample solution, or just some hints, that would be great.

So the code looks like this:

.text:0040985C                 lw      $a0, (base_420000 - 0x100087D0)($gp)
.text:00409860                 nop
.text:00409864                 addiu   $a0, 0x8414      
.text:00409868                 lw      $a1, (base_420000 - 0x100087D0)($gp)
.text:0040986C                 nop
.text:00409870                 addiu   $a1, 0x8468      
.text:00409874                 lw      $t9, (nvram_set_ptr - 0x100087D0)($gp)
.text:00409878                 nop
.text:0040987C                 jalr    $t9


The problem is line 00409864, and 00409870. I want to know what $a0 and $a1 are set to. Now the location base_420000 is always set to 0x420000, and then the 0x8414 and 0x8468 are offset from this base. Both $a0 and $a1 eventually point to strings at the locations 0x428414 and 0x428468. So what I�ve been doing is going through the code and commenting every time base_42... is loaded and then added to, finding that location in the file, then placing a comment on the addiu line to say which string/int it has loaded.

I basically want a script which can do this for me manually. I could easily write a script in another language which parsed the ASM code, but I want to keep this inside IDA so I can maintain the interactive features.

I�d be grateful if anyone could help.

Thanks

Andrew

  abuse007     August 6, 2008 23:32.25 CDT
Hi Bramp,

I recommend IDAPython over IDC. It gives you Pythonized IDC and the full power of the Pythonized IDA Plugin API. Plus it comes with the higher level of Python and enables RAD (no recompiling, restarting).

What you want to do is Data Flow Analysis, where you track the state of the registers and check for cross references.

MIPS, being a RISC architecture, has only a handful of instructions that will modify the register contents. Your code will need to identify the basic blocks (BB), walk the Control Flow Graph (CFG), and apply Data Flow Analysis (DFA). On instructions like LW, etc you can check for cross-references, and if so add the xref and comments etc.

I've written some similar code, but its incomplete and needs a clean up before release.

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