只要让 IsDebuggerPresent() 方法一直返回 false,那我们就可以成功破解反调试,首先用 x 命令找到 IsDebuggerPresent() 的汇编代码,输出如下:
0:007> x KernelBase!IsDebuggerPresent
00007ffb`0fe468a0 KERNELBASE!IsDebuggerPresent (IsDebuggerPresent)0:007> u 00007ffb`0fe468a0
KERNELBASE!IsDebuggerPresent:00007ffb`0fe468a0 65488b042560000000 mov rax,qword ptr gs:[60h]00007ffb`0fe468a9 0fb64002 movzx eax,byte ptr [rax+2]00007ffb`0fe468ad c3 ret
00007ffb`0fe468ae cc int300007ffb`0fe468af cc int300007ffb`0fe468b0 cc int300007ffb`0fe468b1 cc int300007ffb`0fe468b2 cc int3
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
按照 stdcall 协定, eax 会作为方法的返回值,接下来使用 WinDbg 的 a 命令修改 00007ffb0fe468a0 处的汇编代码,键入完汇编代码之后,按 Enter 即可,输出如下:
0:007> a 00007ffb`0fe468a0
00007ffb`0fe468a0 mov eax ,000007ffb`0fe468a5 ret
00007ffb`0fe468a6
0:007> u 00007ffb`0fe468a0
KERNELBASE!IsDebuggerPresent:00007ffb`0fe468a0 b800000000 mov eax,000007ffb`0fe468a5 c3 ret
00007ffb`0fe468a6 0000 add byte ptr [rax],al
00007ffb`0fe468a8 000f add byte ptr [rdi],cl
00007ffb`0fe468aa b640 mov dh,40h
00007ffb`0fe468ac 02c3 add al,bl
00007ffb`0fe468ae cc int300007ffb`0fe468af cc int3