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








Flag: Tornado! Hurricane!

 Forums >>  Brainstorms - General  >>  Finding Nemo

Topic created on: May 17, 2006 14:16 CDT by BillyBoBob .

Often enough, I tend to come across a group of functions in this form:

int sub_448503(struc_9 *pObj, ...)
{
    if (pObj->some_ptr)
    {
    // do some heavy lifting
    }
    else
    {
      return some_error; //often E_FAIL...
    }  
}

Now, on a good day, the offset for ptr will be something nice, i.e. large and not very round. For example, if ptr is at offset 668h, life is improved. If ptr is at 4, your SOL for this technique.

So, lets say it is large and not very round. Now, one can go seaching for immediate operands of the same value. Lets say you go off and do an immediate search in IDA Pro for 668h. You will quite likely find:
a) Some functions from the same group that have a similiar if check at the beginning
b) The spot where ptr is set up (often quite handy)
c) A bunch of stuff you don't want

It is, of course, (c) that is painful. You would be amazed at how often 98h occurs as an immediate operand. So, the question becomes, how can I narrow down my search. So, for example, I might want to eliminate:
1) any place where 98 is used with ebp (I don't care about stack vars at that offset) eg
                 mov eax, [ebp+98h]
is not of interest. Well, depends if the compilier has gone made and started using ebp as a general register, but not usual.
2) any place where 98 is used as a constant. eg

   mov eax, 98h

is likely not of interest. Though I really hate it when compilers do:

   mov eax, [ebp+arg_0]
   add eax, 98h
   cmp [eax], 0
   jz  woof

but still, that is relatively rare in my experience
3) where 98h is used with cmp or test. This helps me find (a) above well
4) where 98h is used only as an offset as a destination, so we want to find things like:

   mov [ecx+98h], eax

Now I figure someone must have explored this avenue previously and might have some clever ideas. I am currently leaning towards writing some IDA script, but I have no experience so I have to get over the learning curve first, so thought I would throw it out here. As well, was wondering if people had other refinements of this technique.

  AlexIonescu     May 18, 2006 01:56.42 CDT
I don't use immediate operands, I use text search for "+98h]", which usually finds 99% of the usage, then I do a search for
", 98h" which finds most of the rest.

  BillyBoBob   May 18, 2006 08:46.49 CDT
Wow, some nice admin formatted my text. Somehow, never realized BBCode-style formatting is there.

Alex, that is altogather too obvious and would certainly help. Sigh. I still might want to tweak to get rid of ebp if the offset is getting a little small-ish, but still, good idea.

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