在那个只有零和一的世界里,对零的向往,终究是一的执着。

正在下载:anti-unpackers.pdf 两种常见的反调试判断


 
#include "antidebug.h"
 
#include <iostream>
 
void printmsg_ok()
{
    std::cout << "Enter code." << std::endl;
}
 
void printmsg_quit()
{
    std::cout << "Quit." << std::endl;
}
 
void antidebug()
{
    //_PEB=>ZwQueryInformationProcess
    __asm
    {
        mov eax,    dword ptr fs:[0x18]    ;_TEB Self
        mov eax,    dword ptr ds:[eax+0x30]    ;_PEB
        cmp byte ptr ds:[eax+0x02], 1    ;_PEB+0x02, BeingDebugged, #IsDebuggerPresent()
        je quit
        mov eax,    dword ptr fs:[0x30]    ;_PEB
        mov al,    byte ptr ds:[eax+0x68]    ;_PEB+0x68, NtGlobalFlag
        and al,    0x70
        cmp al,    0x70
        je quit
        call printmsg_ok
quit:
        call printmsg_quit
    }
}
 

小结:还是在那个 vb木马程序里面看见的,其实这两种反调试判断很常见,原理就是进程环境块的BeingDebugged字段和NtGlobalFlag标志在正常调试状态都会被设置成特定值。于是要绕过这种反调试也很容易,就是找到这两个内存位置清零即可,OD反调试插件的两种选项就是这么干的。此外,定位TEB和PEB的两种方法也在这里体现,当作复习留存。以下附件为收藏的反调试文章,还不错。