当前位置: 首页 > news >正文

反调试防护-API

IsDebuggerPresent()
CheckRemoteDebuggerPresent()

其内部实际调用NtQueryInformationProcess()

bool _stdcall ThreadCall()
{while (true){BOOL  pbDebuggerPresent = FALSE;CheckRemoteDebuggerPresent(GetCurrentProcess(), &pbDebuggerPresent);if (pbDebuggerPresent !=0){printf("debug\n");system("pause");exit(-1);}if (IsDebuggerPresent()!=0){printf("debug\n");system("pause");exit(-1);}}
}int main()
{CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)ThreadCall, NULL, 0, NULL);system("pause");return 0;
}

FS/GS寄存器

debug标志:

X86:FS:0x30

FS指向TEB,FS:30指向PEB,PEB+2指向debug标志。

X64:  GS:0x60

GS指向TEB,GS:60指向PEB,PEB+2指向debug标志。


NtGlobalFlag标志:

在PEB里面


—raedfsdword():
bool _stdcall ThreadCall()
{while (true){//	DWORD dwPeb = __readfsdword(0x30);//	UCHAR BeingDebugged = *(UCHAR *)(dwPeb + 2);//	ULONGLONG ullPeb = __readgsqword(0x60);//	UCHAR BeingDebugged = *(UCHAR *)(ullPeb + 2);//	DWORD dwPeb = __readfsdword(0x30);//	DWORD NtGlobalFlag = *(DWORD *)(dwPeb + 0x68);//  if (NtGlobalFlag == 0x70) printf("debug");//	ULONGLONG dwPeb = __readgsqword(0x60);//	DWORD NtGlobalFlag = *(DWORD *)(dwPeb + 0xbc);//  if (NtGlobalFlag == 0x70) printf("debug");}
}int main()
{CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)ThreadCall, NULL, 0, NULL);system("pause");return 0;
}

Heap标志:

bool _stdcall ThreadCall()
{while (true){/*DWORD dwPeb = __readfsdword(0x30);DWORD ProcessHeap = *(DWORD*)(dwPeb + 0x18);DWORD dwFlags = *(DWORD*)(ProcessHeap + 0x40);DWORD dwForceFlags = *(DWORD*)(ProcessHeap + 0x44);if (dwFlags != 0x2 || dwForceFlags != 0){printf("debug\n");system("pause");exit(0);}*/UINT64 dwPeb = __readgsqword(0x60);UINT64 ProcessHeap = *(PUINT64)(dwPeb + 0x30);DWORD dwFlags = *(DWORD*)(ProcessHeap + 0x70);DWORD dwForceFlags = *(DWORD*)(ProcessHeap + 0x74);if (dwFlags != 0x2 || dwForceFlags != 0){printf("debug\n");system("pause");exit(0);}}
}int main()
{CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)ThreadCall, NULL, 0, NULL);system("pause");return 0;
}

上面有些都是依靠api,如果对方挂钩了,api就失效,只有手动实现标志位检查

ZwQueryInformationProcess手动实现

拿PEB:
bool _stdcall ThreadCall()
{MyZwQueryInformationProcess Func = (MyZwQueryInformationProcess)GetProcAddress(GetModuleHandleA("ntdll.dll"), "ZwQueryInformationProcess");PROCESS_BASIC_INFORMATION pbi = { 0 };while (true){Func(GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), NULL);CHAR flag = *((PCHAR)(pbi.PebBaseAddress) + 2);if (flag == TRUE){printf("debug\n");system("pause");exit(0);}}
}int main()
{CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)ThreadCall, NULL, 0, NULL);system("pause");return 0;
}
调试端口:
bool _stdcall ThreadCall()
{MyZwQueryInformationProcess Func = (MyZwQueryInformationProcess)GetProcAddress(GetModuleHandleA("ntdll.dll"), "ZwQueryInformationProcess");DWORD isDebugPort = 0;while (true){Func(GetCurrentProcess(), ProcessDebugPort, &isDebugPort, sizeof(isDebugPort), NULL);if (isDebugPort == TRUE){printf("debug\n");system("pause");exit(0);}}
}int main()
{CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)ThreadCall, NULL, 0, NULL);system("pause");return 0;
}
隐藏端口:
    DWORD isProcessDebugFlags = 0;func(GetCurrentProcess(), (PROCESSINFOCLASS)0x1F, &isProcessDebugFlags,             sizeof(isProcessDebugFlags), NULL);if (isProcessDebugFlags == 0){printf("debug\n");system("pause");exit(0);}DWORD isProcessDebugObjectHandle = 0;func(GetCurrentProcess(), (PROCESSINFOCLASS)0x1E, &isProcessDebugObjectHandle, sizeof(isProcessDebugObjectHandle), NULL);if (isProcessDebugObjectHandle != 0){printf("debug\n");system("pause");exit(0);}

http://www.lryc.cn/news/449214.html

相关文章:

  • 【视频讲解】非参数重采样bootstrap逻辑回归Logistic应用及模型差异Python实现
  • Linux系统中命令wc
  • redis集群部署
  • VUE条件树查询
  • vue框架学习 -- 日历控件 FullCalendar 使用总结
  • [数据集][目标检测]猪数据集VOC-2856张
  • 工业制造场景中的设备管理深度解析
  • OpenCV图像文件读写(3)统计多页图像文件中的页面数量函数imcount()的使用
  • 【数据治理-构建数据标准体系】
  • AI新方向:OpenAI o1是一个更擅长思考的模型系列:高级推理+逻辑严密+更广泛的知识,用于解决复杂的逻辑问题,慢思考
  • Laravel部署后,CPU 使用率过高
  • Rust调用tree-sitter支持自定义语言解析
  • 如何解决跨域请求中的 CORS 错误
  • 计算机知识科普问答--20(96-100)
  • 济南站活动回顾|IvorySQL中的Oracle XML函数使用示例及技术实现原理
  • 【电商搜索】现代工业级电商搜索技术-Facebook语义搜索技术QueSearch
  • 海滨体育馆管理系统:SpringBoot实现技巧与案例
  • 个人计算机与网络的安全
  • AIGC教程:如何用Stable Diffusion+ControlNet做角色设计?
  • 5V继电器模块详解(STM32)
  • 探究Spring的单例设计模式--单例Bean
  • js基础速成-Set、Map
  • 手机软件何时统一——桥接模式
  • 【Nacos 架构 原理】服务发现模块之Nacos注册中心服务数据模型
  • 基于微信小程序爱心领养小程序设计与实现(源码+参考文档+定制开发)
  • 【数据库】 MongoDB 用户分配新的角色和权限
  • 加速 Python for 循环
  • 计算机毕业设计 基于Python国潮男装微博评论数据分析系统的设计与实现 Django+Vue 前后端分离 附源码 讲解 文档
  • React 表单与事件
  • Appium独立测试自动化初始化脚本