反调试学习

本文深入探讨了多种反调试技术,包括PEB反调试、IsDebuggerPresent函数检测、CheckRemoteDebuggerPresent、NtQuerySystemInformation、NtClose函数等,并介绍了如何绕过这些检测。此外,还涉及窗口、菜单、进程和文件检测,硬件断点检测以及自实现内存CRC等反调试策略。
摘要由CSDN通过智能技术生成

1、PEB反调试

	BeingDebugged :1
	NtGlobalFlag :0x70

```cpp
#include "..//ntdll//ntdll.h"//导入ntdll.h头文件
#pragma comment(lib, "..//ntdll//ntdll_x86.lib")//静态链接库
#define OUTMESSAGE(a,b) printf("%-36s %s\n",a,b ? "Being debuged":"Running Normal!")//定义一个宏显示调试信息
void test()
{
	PEB *peb;
	BOOL bl = FALSE;
	_asm
	{//FS:[0x30]获取peb的地址
		mov eax, dword ptr fs : [0x30]
		mov peb,eax
	}

	if (peb->BeingDebugged)
	{
		bl = TRUE;
	}
	if (peb->NtGlobalFlag & 0x70)
	{
		bl = TRUE;
		
	}
	OUTMESSAGE(__FUNCTION__, bl);
}

2 IsDebuggerPresent

IsDebuggerPresent函数检测,被调试时返回1

void _IsDebugPresent()
{
   
	BOOL bl = FALSE;
	if (IsDebuggerPresent())
	{
   
		bl = TRUE;

	}
		OUTMESSAGE(__FUNCTION__, bl);
}

3 CheckRemoteDebuggerPresent

CheckRemoteDebuggerPresent检测是通过ZwQueryInformationProcess实现的
NTSTATUS NtQueryInformationProcess (
__in HANDLE ProcessHandle,
__in PROCESSINFOCLASS ProcessInformationClass,
__out_bcount(ProcessInformationLength) PVOID ProcessInformation,
__in ULONG ProcessInformationLength,
__out_opt PULONG ReturnLength
);
这里第二个参数是7,实际上被定义为ProcessDebugPort
过掉方法:Hook住CheckRemoteDebuggerPresent,调用了ZwQueryInformationProcess之前的je改成jmp来跳过Zw这个函数~~OD还会在ZwQueryInformationProcess这个函数的调用地址强行改了,去调用作者的一个函数,该函数中根据是否查询的是7来决定时候调用ZwQueryInformationProcess:
在这里插入图片描述

4、NtQuerySystemInformation

NtQuerySystemInformation是检测有没有系统内核调试器

void _NtQuerySystemInformation()
{
   
	BOOL bl = FALSE;
	NTSTATUS status;
	SYSTEM_KERNEL_DEBUGGER_INFORMATION pKerDbgInfo;
	ULONG returnlen;
	status = NtQuerySystemInformation(SystemKernelDebuggerInformation,
		&p
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值