walied
January 13th, 2012, 22:06
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.
http://3.bp.blogspot.com/-tXDCiqtvVUg/TxDeqPOgpOI/AAAAAAAAASc/cv28bGa1_H8/s1600/Untitled.jpg
Here is how the source code above looks in olly.
http://3.bp.blogspot.com/-s4Pi-QjlQzU/TxDgqISCRTI/AAAAAAAAASk/fUS8BxHPlpg/s1600/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.
http://2.bp.blogspot.com/-o6--_Ac03uA/TxDi93nnWnI/AAAAAAAAASs/-x5OoWD3yEc/s1600/Untitled2.jpg
http://2.bp.blogspot.com/-XGpx4V9cjMU/TxDjJtV_cUI/AAAAAAAAAS0/2Mu5bic8c2E/s1600/Untitled3.jpg
http://4.bp.blogspot.com/-uh3J7CVIhN8/TxDjPkEf3oI/AAAAAAAAAS8/fZlSh1Wgrlo/s1600/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.com/document/d/1BoG_WoFR2-fgSlEHkLF9YZmEhJEmQHzRch7b7nWNzSE/edit
Original topic http://waleedassar.blogspot.com/2012/01/ollydbg-bug-disables-software.html
A simple application was written to test this bug. See the image below.
http://3.bp.blogspot.com/-tXDCiqtvVUg/TxDeqPOgpOI/AAAAAAAAASc/cv28bGa1_H8/s1600/Untitled.jpg
Here is how the source code above looks in olly.
http://3.bp.blogspot.com/-s4Pi-QjlQzU/TxDgqISCRTI/AAAAAAAAASk/fUS8BxHPlpg/s1600/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.
http://2.bp.blogspot.com/-o6--_Ac03uA/TxDi93nnWnI/AAAAAAAAASs/-x5OoWD3yEc/s1600/Untitled2.jpg
http://2.bp.blogspot.com/-XGpx4V9cjMU/TxDjJtV_cUI/AAAAAAAAAS0/2Mu5bic8c2E/s1600/Untitled3.jpg
http://4.bp.blogspot.com/-uh3J7CVIhN8/TxDjPkEf3oI/AAAAAAAAAS8/fZlSh1Wgrlo/s1600/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.com/document/d/1BoG_WoFR2-fgSlEHkLF9YZmEhJEmQHzRch7b7nWNzSE/edit
Original topic http://waleedassar.blogspot.com/2012/01/ollydbg-bug-disables-software.html