Jump to content
Tuts 4 You

Recommended Posts

Posted (edited)

I have recently found a weird behavior in OllyDbg, which can further be used as an anti-debugging / anti-attaching trick. The problem occurs when enumerating the running processes if the "Select a process to attach" dialog box is opened.

The psapi "EnumProcesses" function is called to get the list of process identifiers (PIDs). For each PID, the psapi "EnumProcessModules" and "GetModuleFileNameExA" functions are called to extract the image base and full name of the main executable.

As i have shown in previous posts, the values in PEB.LoaderData can easily be manipulated. In this case i will manipulate only the full name of the main executable to be of an existing but malformed file. Surprisingly, OllyDbg trusts the new file name and starts to extract essential information from it. Information extracted includes MZ signature, optional header values, section table data, etc.

The interesting thing about the forged executable is that it is rejected by the OS loader but still used by OllyDbg.

To create a one-file demo for this bug, i had to embed the malformed executable into the original one as a binary resource.

Untitled.png

As you can see in the image below, the number of sections is set to 0xFFFF (malformed executable).

Untitled_.png

The demo can be found here.

http://ollytlscatch....ttach_to_me.exe

The virustotal report can be found here.

https://www.virustot...sis/1329795141/

N.B. This has been tested on OllyDbg v1.10 only.

Update:

Another demo, that crashes OllyDbg upon debugging or attaching, has been created. You can find it here.

http://ollytlscatch....es/Debug_me.exe

Edited by waliedassar

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...