反调试专题丨反调试之NtGlobaFlag-当前视点
一、32位系统
nt!_PEB +0x000 InheritedAddressSpace : UChar +0x001 ReadImageFileExecOptions : UChar +0x002 BeingDebugged : UChar isDbg值,8字节 +0x003 BitField : UChar +0x003 ImageUsesLargePages : Pos 0, 1 Bit +0x003 IsProtectedProcess : Pos 1, 1 Bit +0x003 IsLegacyProcess : Pos 2, 1 Bit +0x003 IsImageDynamicallyRelocated : Pos 3, 1 Bit +0x003 SkipPatchingUser32Forwarders : Pos 4, 1 Bit +0x003 SpareBits : Pos 5, 3 Bits +0x004 Mutant : Ptr32 Void +0x008 ImageBaseAddress : Ptr32 Void 镜像基址 +0x00c Ldr : Ptr32 _PEB_LDR_DATA _PEB_LDR_DATA结构 +0x010 ProcessParameters : Ptr32 _RTL_USER_PROCESS_PARAMETERS +0x014 SubSystemData : Ptr32 Void +0x018 ProcessHeap : Ptr32 Void +0x01c FastPebLock : Ptr32 _RTL_CRITICAL_SECTION +0x020 AtlThunkSListPtr : Ptr32 Void +0x024 IFEOKey : Ptr32 Void +0x028 CrossProcessFlags : Uint4B +0x028 ProcessInJob : Pos 0, 1 Bit +0x028 ProcessInitializing : Pos 1, 1 Bit +0x028 ProcessUsingVEH : Pos 2, 1 Bit +0x028 ProcessUsingVCH : Pos 3, 1 Bit +0x028 ProcessUsingFTH : Pos 4, 1 Bit +0x028 ReservedBits0 : Pos 5, 27 Bits +0x02c KernelCallbackTable : Ptr32 Void +0x02c UserSharedInfoPtr : Ptr32 Void +0x030 SystemReserved : [1] Uint4B +0x034 AtlThunkSListPtr32 : Uint4B +0x038 ApiSetMap : Ptr32 Void +0x03c TlsExpansionCounter : Uint4B +0x040 TlsBitmap : Ptr32 Void +0x044 TlsBitmapBits : [2] Uint4B +0x04c ReadOnlySharedMemoryBase : Ptr32 Void +0x050 HotpatchInformation : Ptr32 Void +0x054 ReadOnlyStaticServerData : Ptr32 Ptr32 Void +0x058 AnsiCodePageData : Ptr32 Void +0x05c OemCodePageData : Ptr32 Void +0x060 UnicodeCaseTableData : Ptr32 Void +0x064 NumberOfProcessors : Uint4B CPU的个数 +0x068 NtGlobalFlag : Uint4B . . .
PEB 有一个名为NtGlobalFlag(32位系统下偏移量0x68)的字段,程序可以挑战该字段以确定它们是否正在被调试。通常,当进程未被调试时,NtGlobalFlag字段包含值0x0。调试进程时,该字段通常包含值0x70,表示设置了以下标志:
(相关资料图)
标志
FLG_HEAP_ENABLE_TAIL_CHECK
FLG_HEAP_ENABLE_FREE_CHECK
FLG_HEAP_VALIDATE_PARAMETERS
其余
所以可以通过检测此标志位来检测是否被调试。实现代码可以通过汇编或者通过C++实现,汇编实现如下:
DWORD MyIsDebug1(){ DWORD Flag = 0; __asm { mov eax,fs:[30h] mov eax,[eax+68h] mov Flag,eax} return Flag;}
完整代码如下:
// : 此文件包含 "main" 函数。程序执行将在此处开始并结束。//#include #include DWORD MyIsDebug1(){ DWORD Flag = 0; __asm { mov eax,fs:[30h] mov eax,[eax+68h] mov Flag,eax} return Flag;}DWORD WINAPI MyIsDebug( LPVOID lpThreadParameter){ DWORD myFlag = 0; while (1) { myFlag = MyIsDebug1(); if (myFlag == 0x70) { MessageBox(NULL, L"警告", L"调试中", MB_OK); } } return 1;}int main(){ //IsDebuggerPresent(); CreateThread(NULL, NULL, MyIsDebug, NULL, NULL, NULL); std::cout << "Hello World!\n"; system("pause"); return 0;}
二、64位系统
ntdll!_PEB +0x000 InheritedAddressSpace : UChar +0x001 ReadImageFileExecOptions : UChar +0x002 BeingDebugged : UChar +0x003 BitField : UChar +0x003 ImageUsesLargePages : Pos 0, 1 Bit +0x003 IsProtectedProcess : Pos 1, 1 Bit +0x003 IsImageDynamicallyRelocated : Pos 2, 1 Bit +0x003 SkipPatchingUser32Forwarders : Pos 3, 1 Bit +0x003 IsPackagedProcess : Pos 4, 1 Bit +0x003 IsAppContainer : Pos 5, 1 Bit +0x003 IsProtectedProcessLight : Pos 6, 1 Bit +0x003 IsLongPathAwareProcess : Pos 7, 1 Bit +0x004 Padding0 : [4] UChar +0x008 Mutant : Ptr64 Void +0x010 ImageBaseAddress : Ptr64 Void +0x018 Ldr : Ptr64 _PEB_LDR_DATA +0x020 ProcessParameters : Ptr64 _RTL_USER_PROCESS_PARAMETERS +0x028 SubSystemData : Ptr64 Void +0x030 ProcessHeap : Ptr64 Void +0x038 FastPebLock : Ptr64 _RTL_CRITICAL_SECTION +0x040 AtlThunkSListPtr : Ptr64 _SLIST_HEADER +0x048 IFEOKey : Ptr64 Void +0x050 CrossProcessFlags : Uint4B +0x050 ProcessInJob : Pos 0, 1 Bit +0x050 ProcessInitializing : Pos 1, 1 Bit +0x050 ProcessUsingVEH : Pos 2, 1 Bit +0x050 ProcessUsingVCH : Pos 3, 1 Bit +0x050 ProcessUsingFTH : Pos 4, 1 Bit +0x050 ProcessPreviouslyThrottled : Pos 5, 1 Bit +0x050 ProcessCurrentlyThrottled : Pos 6, 1 Bit +0x050 ReservedBits0 : Pos 7, 25 Bits +0x054 Padding1 : [4] UChar +0x058 KernelCallbackTable : Ptr64 Void +0x058 UserSharedInfoPtr : Ptr64 Void +0x060 SystemReserved : Uint4B +0x064 AtlThunkSListPtr32 : Uint4B +0x068 ApiSetMap : Ptr64 Void +0x070 TlsExpansionCounter : Uint4B +0x074 Padding2 : [4] UChar +0x078 TlsBitmap : Ptr64 Void +0x080 TlsBitmapBits : [2] Uint4B +0x088 ReadOnlySharedMemoryBase : Ptr64 Void +0x090 SharedData : Ptr64 Void +0x098 ReadOnlyStaticServerData : Ptr64 Ptr64 Void +0x0a0 AnsiCodePageData : Ptr64 Void +0x0a8 OemCodePageData : Ptr64 Void +0x0b0 UnicodeCaseTableData : Ptr64 Void +0x0b8 NumberOfProcessors : Uint4B +0x0bc NtGlobalFlag : Uint4B
可以看到64位系统下面,NtGlobalFlag标志位有所不同,位于PEB偏移0xbc。其余和x86没有区别。可以通过readgsqword(60h)获取到PED地址,再检查偏移0xbc位置标志位达到反调试效果。
三、反反调试
1. 手动修改标志位
2. 使用OD插件
3. 在WinDbg中,在禁用调试堆的情况下启动程序 ( windbg -hd )
标签:
- 反调试专题丨反调试之NtGlobaFlag-当前视点
- 俄军方高层:不排除西方情报机构参与挑唆军事叛乱 环球观速讯
- 今晚中超联赛重燃战火 天津津门虎队将在主场迎战青岛海牛队|每日观察
- 国台办:《关于支持福建探索海峡两岸融合发展新路 建设两岸融合发展示范区的意见...
- 每日速递:国际足联官宣:2023年国际足联世俱杯赛将在沙特吉达举办
- 世界速读:2023广州天河区中考成绩在哪查?(附入口)
- 西游释厄传有哪些版本?西游记释厄传如何安装?
- 《梦幻西游》69满强壮多少钱?强身和强壮点哪个划算?
- 天天时讯:水泥的规格型号(水泥规格型号有哪些)
- 说说跨年夜_浅浅聊聊:跨年夜氛围感拉满
- 国网息县供电公司:炎炎中考日 保电正当时 微动态
- 盗贼换武器宏命令_盗贼换武器宏
- 环球即时看!信阳市清欠办对罗山县开展保障农民工工资支付专项调研
- 焦点!pt950铂金回收价格今日多少钱一克(2023年06月28日)
- 要闻速递:息县举行建党102周年暨“七一”表彰大会
- 当前观察:西平县二郎镇新时代文明实践所深入小王庄小学开展“扫黄打非”宣传活动
- 世界球精选!邓州市彭桥镇行政审批服务中心:持续优化营商环境 提高群众办事效率
- 环球热门:西平县应急管理局持续开展法治教育培训轮训
- 世界热门:笔记本电脑坐上过山车 下半年或复苏
- 铁路暑运7月1日启动 郑州铁路预计发送旅客3300万人次_世界热头条
- 环球新动态:恢复出厂设置是什么意思 手机恢复出厂设置后怎么还原数据?
- 世界通讯!ipo审核是什么意思?ipo审核通过后多久发行?
- 酒驾和醉驾的分界线是多少?酒驾和醉驾哪个严重? 全球短讯
- 环球观天下!贫民窟军需官在哪?魔兽世界诅咒密码任务怎么做?
- 天天观点:精轧管特点有哪些?精轧管生产工艺要点有什么?
- 广东高考志愿填报6月28日开始 填报志愿要记得“五看”
- 【天天时快讯】老人为啥说被子不能横着盖 床单颜色的十大忌讳介绍
- 大众计划推出入门级ID.1车型 售价有望低于2.2万美元_当前热文
- 【热闻】信托公司管理办法原则 信托公司管理办法具体内容是什么?
- 环球新动态:有助于睡眠的颜色有哪些 卧室最旺三种颜色床分别是什么?
- 反调试专题丨反调试之NtGlobaFlag-当前视点
- 俄军方高层:不排除西方情报机构参与挑唆军
- 今晚中超联赛重燃战火 天津津门虎队将在
- 国台办:《关于支持福建探索海峡两岸融合发
- 每日速递:国际足联官宣:2023年国际足联世
- 世界速读:2023广州天河区中考成绩在哪查?
- 西游释厄传有哪些版本?西游记释厄传如何安
- 《梦幻西游》69满强壮多少钱?强身和强壮点
- 天天时讯:水泥的规格型号(水泥规格型号有
- 说说跨年夜_浅浅聊聊:跨年夜氛围感拉满
- 国网息县供电公司:炎炎中考日 保电正当
- 盗贼换武器宏命令_盗贼换武器宏
- 环球即时看!信阳市清欠办对罗山县开展保
- 焦点!pt950铂金回收价格今日多少钱一克(2
- 要闻速递:息县举行建党102周年暨“七一
- 当前观察:西平县二郎镇新时代文明实践所深
- 世界球精选!邓州市彭桥镇行政审批服务中心
- 环球热门:西平县应急管理局持续开展法治
- 世界热门:笔记本电脑坐上过山车 下半年或
- 铁路暑运7月1日启动 郑州铁路预计发送旅客
- 环球新动态:恢复出厂设置是什么意思 手机
- 世界通讯!ipo审核是什么意思?ipo审核通过
- 酒驾和醉驾的分界线是多少?酒驾和醉驾哪个
- 环球观天下!贫民窟军需官在哪?魔兽世界诅
- 天天观点:精轧管特点有哪些?精轧管生产工
- 广东高考志愿填报6月28日开始 填报志愿要
- 【天天时快讯】老人为啥说被子不能横着盖
- 大众计划推出入门级ID.1车型 售价有望低于
- 【热闻】信托公司管理办法原则 信托公司管
- 环球新动态:有助于睡眠的颜色有哪些 卧室