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








Flag: Tornado! Hurricane!

Blogs >> JasonGeffner's Blog

Created: Thursday, June 30 2005 17:26.00 CDT Modified: Thursday, June 30 2005 17:26.00 CDT
This is an imported entry. View original. Printer Friendly ...
Getting around anti-debugger code
Author: JasonGeffner # Views: 1711

Malicious software will often contain anti-debugger code to make it more difficult to analyze the target. One of the many common anti-debugger tricks is breakpoint-searching. This involves scanning areas of memory for breakpoints set by the analyst via their debugger. We can easily defeat this with our own anti-anti-debugger trick.

When setting a software-breakpoint (as opposed to a hardware-breakpoint) in a program, the debugger overwrites the first byte of the instruction at the breakpoint with a 0xCC byte. This byte corresponds to the x86 instruction int 3. When this instruction is hit during execution, a software interrupt generates an exception and is caught by the debugger, at which point the debugger will automatically replace the 0xCC byte with the original byte from the original instruction and notify the analyst that their breakpoint was hit.

Why dont we ever see these int 3 instructions in memory after we set breakpoints? Because the debugger hides them from us to simplify analysis. But rest assured, theyre there.

So why does any of this matter? Because breakpoint-searching is done by searching for 0xCC bytes. Thus, if we can create a breakpoint without using 0xCC bytes, then we can defeat this anti-debugger trick. Instead of using your debuggers Set-Breakpoint command, try overwriting the instruction that you want to break on with something else that will cause an exception, such as the ud2 instruction (0xF0 0x0B)icebp instruction (0xF1), or a good ol divide-by-zero such as xor eax, eax (0x33 0xC0) followed by div eax (0xF7 0xF0). Any of these will cause your debugger to break and return control to you (assuming your debugger isnt set to ignore such exceptions). Of course, the only downside is that once your debugger breaks at these custom-breakpoints, youll have to restore the original instructions yourself (and set EIP to point to them) as opposed to having the debugger automatically do it.



If you wish to comment on this blog entry, please do so on the original site it was imported from.

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