其他
由一道CTF对10种反调试的探究
https://blog.csdn.net/hgy413/article/details/7996652 https://blog.csdn.net/yiyefangzhou24/article/details/6242459 https://www.52pojie.cn/thread-883664-1-1.html https://bbs.pediy.com/thread-223857.htm http://bbs.pediy.com/showthread.php?t=31447 https://blog.csdn.net/qq_32400847/article/details/52798050
import base64
str1 = "LKd8gPYWS["
str2 = "2TVBnx0lnn"
cipher = [0] * 20
for i in range(10):
cipher[2*i] = (ord(str1[i]) ^ 3) - 2
cipher[2*i+1] = ord(str2[i])
print''.join(map(chr,cipher))
#M2FTeV9BbnQxX0RlNnVn
end_cipher = 'M2FTeV9BbnQxX0RlNnVn'
print"D0g3{"+end_cipher.decode("base64")+"}"
#D0g3{3aSy_Ant1_De6ug}
1. IsDebuggerPresent
kernel32!IsDebuggerPresent:
7c813133 64a118000000 mov eax,dword ptr fs:[00000018h]// fs寄存器在3环的时候指向TEB,而+18h偏移处指向teb的开头fs:003b:00000018=7ffdf000
7c813139 8b4030 mov eax,dword ptr [eax+30h]//+30h指向PEB
7c81313c 0fb64002 movzx eax,byte ptr [eax+2]//peb->BeingDebugged位来判断是否有调试器。
2. CheckRemoteDebuggerPresent
7C85AA3C 50 push eax //eax里是 hProcess
7C85AA3D 6A 07 push 7 // 这里的7定义是 ProcessDebugPort
7C85AA3F FF75 08 push dword ptr SS:[ebp+8] //hProcess
7C85AA42 FF15 AC10807C call dword ptr DS:[<&ntdll.NtQueryInform> ] //ntdll.NTQueryInformationProcess
7C85AA48 85C0 test eax,eax //判断
NtQueryInformationProcess (
IN HANDLE ProcessHandle, // 获取进程的句柄
IN PROCESSINFOCLASS InformationClass, // 信息类型
OUT PVOID ProcessInformation, // 缓冲区的指针
IN ULONG ProcessInformationLength, // 缓冲区大小
OUT PULONG ReturnLength OPTIONAL // 写入缓冲区的字节数
);
3. SetLastError & OutputDebugStringA & GetLastError
4. NtQueryInformationProcess
6. DebugActiveProcess
BOOL WINAPI DebugActiveProcess(
__in DWORD dwProcessId//要被调试的进程标识PID
);
以下是对调试器利用DebugActiveProcess的深究。
typedef struct _DEBUG_OBJECT {
KEVENT EventsPresent;
FAST_MUTEX Mutex;
LIST_ENTRY EventList;
union
{
ULONG Flags;
struct
{
UCHAR DebuggerInactive:1;
UCHAR KillProcessOnExit:1;
};
}
} DEBUG_OBJECT, *PDEBUG_OBJECT;
7. GetStartupInfoA
还有一点 ollydbg 会向 STARTUPINFO 中的 dwFlags 设置,STARTF_FORCEOFFFEEDBACK,而 explorer 不会。
8. 检测系统留下的痕迹
BOOL WINAPI Process32First(
HANDLE hSnapshot,//_in
LPPROCESSENTRY32 lppe//_out
);
typedef struct tagPROCESSENTRY32 {
DWORD dwSize; // 结构体大小;
DWORD cntUsage; // 此进程的引用次数;
DWORD th32ProcessID; // 进程PID;
DWORD th32DefaultHeapID; // 进程默认堆ID;
DWORD th32ModuleID; // 进程模块ID;
DWORD cntThreads; // 此进程开启的线程次数;
DWORD th32ParentProcessID;// 父进程PID;
LONG pcPriClassBase; // 线程优先权;
DWORD dwFlags;
WCHAR szExeFile[MAX_PATH]; // 进程全名;
} PROCESSENTRY32;
下面是调试器在注册表中的一个常用位置。SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug(32位系统)
SOFTWARE\Wow6432Node\Microsoft\WindowsNT\CurrentVersion\AeDebug(64位系统)
该注册表项指定当应用程序发生错误时,触发哪一个调试器。默认情况下,它被设置为Dr.Watson。如果该这册表的键值被修改为OllyDbg,则恶意代码就可能确定它正在被调试。
FindWindow函数检索处理顶级窗口的类名和窗口名称匹配指定的字符串。
EnumWindows函数枚举所有屏幕上的顶层窗口,并将窗口句柄传送给应用程序定义的回调函数。
9. 时钟检测
看雪ID:0xDQ
https://bbs.pediy.com/user-885131.htm
推荐文章++++
好书推荐