Jump to content
Tuts 4 You

An OllyDbg Bug Disables Software Breakpoints


waliedassar

Recommended Posts

I have found a new bug in OllyDbg v1.10. The bug is triggered when the BaseAddress value is changed in the LDR_MODULE structure for the main executable. Any subsequent DLL loading forces Olly to call the psapi "EnumProcessModules" function in order to update the module list, and since the psapi "EnumProcessModules" function traverses and reads from the LDR_MODULE linked list, the new (fake) base address will definitely be returned.

A simple application was written to test this bug. See the image below.

Untitled.jpg

Here is how the source code above looks in olly.

Untitled1.jpg

If some breakpoints are set after the troublesome code and OllyDbg is left to run, an error message shows up once we step over the "LoadLibrary" function call and none of the breakpoints are hit.

Untitled2.jpg

Untitled3.jpg

Untitled4.jpg

The problem is that OllyDbg trusts the data retrieved from the psapi "EnumProcessModules" function call and tries to update data related to the main executable, including software breakpoints. At this point, all software breakpoints are deleted since OllyDbg thinks their addresses are no longer valid. Actually they are, but this is how it goes in OllyDbg v1.10.

N.B Software breakpoints outside the main executable e.g. in ntdll.dll are not affected by this bug.

A demo here https://docs.google....h7b7nWNzSE/edit

Original topic http://waleedassar.b...s-software.html

  • Like 1
Link to comment

This is a nice find. Olly simply resumes execution after the LoadLibrary returns (step over won't stop), so execution escapes Olly's control. Certain APIs (like MessageBox) will crash unless you change the value back afterwards, though.

It might even be possible to choose a page that does not cause the message to appear, making a very stealthy way to run. :-)

Link to comment

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...