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








Flag: Tornado! Hurricane!

Blogs >> bLaCkeye's Blog

Created: Wednesday, August 15 2007 04:24.35 CDT Modified: Wednesday, August 15 2007 04:25.10 CDT
Printer Friendly ...
DeleteFiber AntiDebug
Author: bLaCkeye # Views: 2979

I was reversing a piece of malware today when its decryptor revelead a trick i haven't seen before.

The trick seems to be based on the behaviour of DeleteFiber under debugger.

After calling it with an invalid parameter, it checks last set error using GetLastError which is
- 0x00000057 if process was not debugged
- other if process was under debugger

In the malware i was analysing the return value was used to build a jump to another section of the decryptor.

Easy code to conduct your own reversing.


char lama[1024]={0};
int main(int argc, CHAR* argv[])
{
        DeleteFiber(lama);
        printf("GetLastError = %.8x", GetLastError());
        return 0;
}







Blog Comments
camus Posted: Wednesday, August 15 2007 09:58.37 CDT
Interesting, thanks ;)

jms Posted: Wednesday, August 15 2007 11:22.52 CDT
Sweet, thanks for the heads up. Is this posted in the anti-debugger portion of the site?

carib Posted: Thursday, August 16 2007 07:10.20 CDT
DeleteFiber calls RtlFreeHeap. If the process is debugged without forcing the NtGlobalFlags, the heap will have the flags FLG_HEAP_ENABLE_TAIL_CHECK, FLG_HEAP_ENABLE_FREE_CHECK and FLG_HEAP_VALIDATE_PARAMETERS enabled by default. Those flags will enforce some protections before memory chunks are freed; in this case, the fiber data is invalid and the heap routines will call ntdll!DbgBreakPoint (a simple INT3).
So, this anti-debug is one of the NtGlobalFlags class, which can be bypassed by force-setting the global flags before the program is created.

jms Posted: Thursday, August 16 2007 11:21.59 CDT
Excellent, thanks for the explanation.

bLaCkeye Posted: Thursday, August 16 2007 11:50.07 CDT
Like jms said: excellent :)



Add New Comment
Comment:









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