IsDebuggerPresent原理及其 c++实现

时间:2023-03-09 09:44:20
IsDebuggerPresent原理及其 c++实现

在IsDebuggerPresent下断,步入得到如下代码:

750E38F0 |  A1            | mov eax,dword ptr fs:[]               | eax:std::cout
750E38F6 | 8B | mov eax,dword ptr ds:[eax+] | eax:std::cout
750E38F9 | 0F B6 | movzx eax,byte ptr ds:[eax+] | eax:std::cout
750E38FD | C3 | ret |
750E38FE | CC | int3 |
750E38FF | CC | int3 |
750E3900 | CC | int3 |
750E3901 | CC | int3 |
750E3902 | CC | int3 |

在fs:[18]下断点得出

其中fs:[18] =7EFDD000

IsDebuggerPresent原理及其 c++实现

eax+30就是这里

IsDebuggerPresent原理及其 c++实现

再来看看7EFDE000里的值

IsDebuggerPresent原理及其 c++实现

ds:[eax+2]   = 1 .所以是调试状态
那么c++一行代码直接可以修改这个值,使IsDebuggerPresent失效了
*((unsigned char *)(*(DWORD*)(__readfsdword(0x18) + 0x30)) + 0x2) = ;