naides
December 22nd, 2005, 15:16
This is sort of a long story:
I have been tracing some protected application that stores its state of non-registered (01) or registered (00) in a global long flag variable lets say [006BB976].
I tried to find the code that WRITES the registered state to that location, so I placed a BPMD 006BB976 W in softice while I was at the code entry point.
SoftIce did not break. I examined this area of the memory and it is initiallized to a 01 state. I manually changed to 00 and let softice run again: It did not break and somehow, the flag was set to 01: Someone had accessed that piece of memory, set the flag and escaped Sice hardware breakpoint! How??
I changed the break point to BPMD 006BB976 RW and found that early in the course of the program Sice breaks See picture:
Softice is deep into the NTOSKRNL.DLL and actually the call stack goes through NTIce itself (!?)
If I trace back into the appication itself it is writing into the adjacent dword to my flag.
The application protection did not look very sophisticated to me. I tried the same approach, same breakpoint in Olly and got
Right where it belongs, catching the app setting the badboy flag
What is the deal? Why SoftIce does not catch the write to memory BP?? What are these ReadAheadGRanularity APIs and why Sice gets sidetracked into tracing the kernel and tracing itself when I try to detect the access to this innocent variable?? Olly has no problem.
I have been tracing some protected application that stores its state of non-registered (01) or registered (00) in a global long flag variable lets say [006BB976].
I tried to find the code that WRITES the registered state to that location, so I placed a BPMD 006BB976 W in softice while I was at the code entry point.
SoftIce did not break. I examined this area of the memory and it is initiallized to a 01 state. I manually changed to 00 and let softice run again: It did not break and somehow, the flag was set to 01: Someone had accessed that piece of memory, set the flag and escaped Sice hardware breakpoint! How??
I changed the break point to BPMD 006BB976 RW and found that early in the course of the program Sice breaks See picture:
Softice is deep into the NTOSKRNL.DLL and actually the call stack goes through NTIce itself (!?)
If I trace back into the appication itself it is writing into the adjacent dword to my flag.
The application protection did not look very sophisticated to me. I tried the same approach, same breakpoint in Olly and got
Code:
0051F171 |. 83C4 08 ADD ESP,8
0051F174 |. 83E8 01 SUB EAX,1
0051F177 |. F7D8 NEG EAX
0051F179 |. 1BC0 SBB EAX,EAX
0051F17B |. F7D8 NEG EAX
0051F17D |. A3 76B96B00 MOV DWORD PTR DS:[6BB976],EAX; <- Break here: Writes 01 to the flag
0051F182 |. 833D 76B96B00 >CMP DWORD PTR DS:[6BB976],0
0051F189 |. 75 1E JNZ SHORT XXXXXXX.0051F1A9
0051F18B |. 33C0 XOR EAX,EAX
0051F18D |. 837D E8 00 CMP DWORD PTR SS:[EBP-18],0
0051F191 |. 0F95C0 SETNE AL
0051F194 |. 83C0 03 ADD EAX,3
0051F197 |. A3 74A75C00 MOV DWORD PTR DS:[5CA774],EAX
0051F19C |. E8 CF4C0300 CALL XXXXXXXXX.00553E70
0051F1A1 |. 66:A3 70A75C00 MOV WORD PTR DS:[5CA770],AX
Right where it belongs, catching the app setting the badboy flag
What is the deal? Why SoftIce does not catch the write to memory BP?? What are these ReadAheadGRanularity APIs and why Sice gets sidetracked into tracing the kernel and tracing itself when I try to detect the access to this innocent variable?? Olly has no problem.