NtQueryInformationProcess (反调试)

0x01 NtQueryInformationProcess ()

一、NtQueryInformationProcess ()

​ 函数原型:

NTSYSAPI NTSTATUS NTAPI NtQueryInformationProcess (
  IN HANDLE         ProcessHandle,       // 进程句柄
  IN PROCESSINFOCLASS   InformationClass,      // 信息类型
  OUT PVOID         ProcessInformation,     // 缓冲指针
  IN ULONG          ProcessInformationLength, // 以字节为单位的缓冲大小
  OUT PULONG         ReturnLength OPTIONAL     // 写入缓冲的字节数
);

​ 第二个参数是一个枚举类型,其中与反调试有关的成员有ProcessDebugPort(0x7)、ProcessDebugObjectHandle(0x1E)和ProcessDebugFlags(0x1F)三种

ProcessDebugPort(0x7)
进程处于调试状态时,操作系统会为他分配1个调试端口(debug port) , InformationClass设为ProcessDebugPort(0x07) 时,调用NtQueryInformationProcess()函数就可以获取调试端口。若处于调试状态 , 第三个参数会被置为0xFFFFFFFF(-1);若处于非调试状态,第三个参数值会被设置为0

ProcessDebugObjectHandle(0x1E)
调试进程时,会生成一个调试对象(Debug Obiect)。 NtQueryInformationProcess() 第二个参数值为0x1E时 , 函数的第三个参数就能获取到调试对象句柄 ,进程处于调试状态->调试句柄存在->返回值不为 NULL ;处于非调试状态 , 返回值为 NULL。

ProcessDebugFlags(0x1F)
调试标志:Debug Flags 。检测调试标志的值也可以判断进程是否处于被调试状态。当 NtQueryInformationProcess() 第二个参数为0x1F时,第三个参数:调试状态:0;非调试状态:1

破解方法:直接 HOOK API;修改返回值;利用 OD 插件 strong OD 中 KernelMode 可以绕过。

二、CheckRemoteDebuggerPresent()

​ 该函数可以与 IsdebuggerPresent()类似,可以检测进程是否处于调试状态,且其不仅仅可以检测自身是否处于调试状态,还可以检测其他程序是否处于调试状态。如果调试器存在 (通常是检测自己是否正在被调试),该函数会将pbDebuggerPresent指向的值设为0xffffffff。其函数实际上是利用了前面的 NtQueryInformationProcess () 函数中的 ProcessDebugPort 实现的。函数原型为:

BOOL WINAPI CheckRemoteDebuggerPresent(
  _In_    HANDLE hProcess,
  _Inout_ PBOOL  pbDebuggerPresent
);

破解方法:利用 NtQueryInformationProcess () 的破解方法即可。

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
## Features ### Anti-debugging attacks - IsDebuggerPresent - CheckRemoteDebuggerPresent - Process Environement Block (BeingDebugged) - Process Environement Block (NtGlobalFlag) - ProcessHeap (Flags) - ProcessHeap (ForceFlags) - NtQueryInformationProcess (ProcessDebugPort) - NtQueryInformationProcess (ProcessDebugFlags) - NtQueryInformationProcess (ProcessDebugObject) - NtSetInformationThread (HideThreadFromDebugger) - NtQueryObject (ObjectTypeInformation) - NtQueryObject (ObjectAllTypesInformation) - CloseHanlde (NtClose) Invalide Handle - SetHandleInformation (Protected Handle) - UnhandledExceptionFilter - OutputDebugString (GetLastError()) - Hardware Breakpoints (SEH / GetThreadContext) - Software Breakpoints (INT3 / 0xCC) - Memory Breakpoints (PAGE_GUARD) - Interrupt 0x2d - Interrupt 1 - Parent Process (Explorer.exe) - SeDebugPrivilege (Csrss.exe) - NtYieldExecution / SwitchToThread - TLS callbacks ### Anti-Dumping - Erase PE header from memory - SizeOfImage ### Timing Attacks [Anti-Sandbox] - RDTSC (with CPUID to force a VM Exit) - RDTSC (Locky version with GetProcessHeap & CloseHandle) - Sleep -> SleepEx -> NtDelayExecution - Sleep (in a loop a small delay) - Sleep and check if time was accelerated (GetTickCount) - SetTimer (Standard Windows Timers) - timeSetEvent (Multimedia Timers) - WaitForSingleObject -> WaitForSingleObjectEx -> NtWaitForSingleObject - WaitForMultipleObjects -> WaitForMultipleObjectsEx -> NtWaitForMultipleObjects (todo) - IcmpSendEcho (CCleaner Malware) - CreateWaitableTimer (todo) - CreateTimerQueueTimer (todo) - Big crypto loops (todo) ### Human Interaction / Generic [Anti-Sandbox] - Mouse movement - Total Physical memory (GlobalMemoryStatusEx) - Disk size using DeviceIoControl (IOCTL_DISK_GET_LENGTH_INFO) - Disk size using GetDiskFreeSpaceEx (TotalNumberOfBytes) - Mouse (Single click / Double click) (todo) - DialogBox (todo) - Scrolling (todo) - Execution after reboot (todo) - Count of processors (Win32/Tinba - Win32/Dyre) - Sandbox k

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值