一、调试器检测
1.1 IsDebuggerPresent
使用IsDebuggerPresent函数检测PEB的BeingDebugged标志位
BOOL IsDebuggerPresent();
代码
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
// Function to check if a debugger is present
bool IsDebuggerPresentCheck() {
return IsDebuggerPresent() == TRUE;
}
// Function that simulates the main functionality
void hack() {
MessageBox(NULL, "Meow!", "=^..^=", MB_OK);
}
int main() {
// Check if a debugger is present
if (IsDebuggerPresentCheck()) {
MessageBox(NULL, "Debugger detected!", "=^..^=", MB_OK);
return 1; // exit if a debugger is present
}
// Main functionality
hack();
return 0;
}
编译
x86_64-w64-mingw32-g++ -O2 hack.c -o hack.exe -I/usr/share/mingw-w64/include/ -s -ffunction-sections -fdata-sections -Wno-write-strings -fno-exceptions -fmerge-all-constants -static-libstdc++ -static-libgcc -fpermissive
windows10上用用x64dbg打开,检测到调试器
1.2 CheckRemoteDebuggerPresent
还有一个函数可以监测调试器附加进程
CheckRemoteDebuggerPresent()
代码
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
// Function to check if a debugger is present
bool DebuggerCheck() {
BOOL result;
CheckRemoteDebuggerPresent(GetCurrentProcess(), &result);
return result;
}
// Function that simulates the main functionality
void hack() {
MessageBox(NULL, "Meow!", "=^..^=", MB_OK);
}
int main() {
// Check if a debugger is present
if (DebuggerCheck()) {
MessageBox(NULL, "Bow-wow!", "=^..^=", MB_OK);
return 1; // exit if a debugger is present
}
// Main functionality
hack();
return 0;
}
编译
x86_64-w64-mingw32-g++ -O2 hack2.c -o hack2.exe -I/usr/share/mingw-w64/include/ -s -ffunction-sections -fdata-sections -Wno-write-strings -fno-exceptions -fmerge-all-constants -static-libstdc++ -static-libgcc -fpermissive
windows10上使用x64dbg打开,检测出调试器
标签:Debugging,return,免杀,调试器,Anti,hack,include,present,debugger From: https://www.cnblogs.com/o-O-oO/p/18594635