我是靠谱客的博主 飞快蜜蜂,这篇文章主要介绍反调试 - r3 使用 NtQuerySystemInformation 获取 KdKdDebuggerEnable 和 KdDebuggerNotPresent,现在分享给大家,希望可以做个参考。

原理

NtQuerySystemInformation 被 ntdll.dll 导出,当第一个参数传入 0x23 (SystemInterruptInformation) 时,会返回一个 SYSTEM_KERNEL_DEBUGGER_INFORMATION 结构,里面的成员KdKdDebuggerEnable 和 KdDebuggerNotPresent 标志系统是否启用内核调试。

代码示例

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Test_Console_1.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。 // #include <iostream> #include <Windows.h> #include <intrin.h> using namespace std; typedef struct _SYSTEM_KERNEL_DEBUGGER_INFORMATION{ BOOLEAN KernelDebuggerEnabled; BOOLEAN KernelDebuggerNotPresent; } SYSTEM_KERNEL_DEBUGGER_INFORMATION, * PSYSTEM_KERNEL_DEBUGGER_INFORMATION; typedef NTSTATUS(WINAPI* pNtQuerySystemInformation)(IN UINT SystemInformationClass,OUT PVOID SystemInformation,IN ULONG SystemInformationLength,OUT PULONG ReturnLength); int main() { // 取 NtQuerySystemInformation 地址 pNtQuerySystemInformation NtQuerySystemInformation = (pNtQuerySystemInformation)GetProcAddress(LoadLibrary(L"ntdll.dll"), "ZwQuerySystemInformation"); if (NtQuerySystemInformation == NULL) { goto main_end; } // 获取系统信息 SYSTEM_KERNEL_DEBUGGER_INFORMATION KdDebuggerInfo; if (NtQuerySystemInformation( 0x23, // 要检索的系统信息的类型: SystemInterruptInformation &KdDebuggerInfo, // 接受请求信息 sizeof(SYSTEM_KERNEL_DEBUGGER_INFORMATION), // 请求信息的字节大小 NULL ) != 0) { goto main_end; } // 判断调试器 if (KdDebuggerInfo.KernelDebuggerEnabled || !KdDebuggerInfo.KernelDebuggerNotPresent) { cout << "发现调试器!" << endl; } else { cout << "没有调试器" << endl; } main_end: getchar(); return 0; }

最后

以上就是飞快蜜蜂最近收集整理的关于反调试 - r3 使用 NtQuerySystemInformation 获取 KdKdDebuggerEnable 和 KdDebuggerNotPresent的全部内容,更多相关反调试内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(69)

评论列表共有 0 条评论

立即
投稿
返回
顶部