【MalDev-07】Anti-Debugging反调试-1

admin 2024年12月3日12:31:34评论4 views字数 1807阅读6分1秒阅读模式

02-免杀逃逸

01-Anti-Debugging反调试

01-调试器检测

01-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打开,检测到调试器

【MalDev-07】Anti-Debugging反调试-1

02-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打开,检测出调试器

【MalDev-07】Anti-Debugging反调试-1

加Q群分享更多学习资料

【MalDev-07】Anti-Debugging反调试-1

原文始发于微信公众号(高级红队专家):【MalDev-07】Anti-Debugging反调试-1

免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2024年12月3日12:31:34
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   【MalDev-07】Anti-Debugging反调试-1https://cn-sec.com/archives/3462351.html
                  免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉.

发表评论

匿名网友 填写信息