📚 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  >>  IDA Command Line Disassembly and Options

Topic created on: May 21, 2009 00:28 CDT by rwartell .

I'm attempting to do some work using IDA, and I'd like to disassemble a PE file from the command line.  Currently I'm using the command:

idaw -a -B test.exe

Which creates the test.idb and test.asm files.  I'm only really interested in the assembly that it generates in the asm file, however it is doing some interesting things that I'd like to get rid of.  

First of all, the assembly seems to do some kind of analysis that modifies movs and jmps so that they are using offsets, an example is here:

mov [esp+18h+var_18], 8

Where the variable var_18 has the value -18, essentially meaning that there is no offset.  Is there a way to get rid of this offset analysis or to just have the disassembler put in actual numeric offsets rather than using variables?  I tried modifying the ida.cfg but none of the options seemed to solve this problem.

The next thing I'd like is to be able to see the hex codes beside instructions, and the addresses that they start at.  I'm not necessarily interested in the hex codes, but they're an easy way to tell the length of an instruction.  If there is a way to print the length of the instruction beside each instruction, that would be even better.

Anyone help with this would be much appreciated, thanks a lot.

  rwartell   May 21, 2009 01:43.46 CDT
As a side note, I know that there is a way to create a dead listing for an exe via ida pro but is there any way to do that from the command line?  I can only find how to do it from an interactive interface.  Thanks.

  gera     May 21, 2009 08:20.47 CDT
Don't have the data right now, but what you should look for is a way to execute an .idc script (or maybe python script) from the command line. Once you get that (and that's documented) you can write a script that dumps the database to a file. With this, you call IDA, it opens, runs the script, and closes again.

  ero     May 21, 2009 09:55.50 CDT
Regarding your first question, if you disable, under "Kernel Options1", the options "Create stack variables" and "Trace stack pointer" IDA won't try to do any sort of analysis on the references to stack.

  ero     May 21, 2009 10:00.41 CDT
Regarding printing the instruction bytes and length. Maybe you'll be better of, as gera proposes, writing a small script that iterates, segments/functions/code and dumps it all.
Something like (I'm typing some IDAPython from memory, don't expect it to work):

for segment in Segments():
  for func in Functions(segment, SegEnd(segment):
    for head in Heads(func, FindFuncEnd(head)):
      if isCode(GetFlags(head)):
        size = ItemSize(head)
        bytes = ['%02x' % Byte(addr) for addr in range(head, head+size)]
        print '%d %s %s' % (size, bytes, GetLine(head))

Something like that should print the length, the hexbytes and the assembler for that line.
It should be improved to iterate through basic blocks instead of the raw code in order to do properly split functions...

  rwartell   May 21, 2009 13:07.39 CDT
Thanks a lot for the advice all of you, I'll work with those ideas today and let you know if I have any more trouble.

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