国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

SSDTHook的原理

2019-11-10 17:03:40
字體:
來源:轉載
供稿:網友

前言

分析了一個cm, cm中釋放了一個驅動, 進行了SSDTHook, 用于保護cm. IDA的偽碼翻譯的真渣, 直接編譯都過不了(已經將數據類型改對了), 翻譯的和反匯編代碼也有點對不上, 從反匯編開始自己翻譯. 從反匯編層面看SSDTHook時, 先復習一下SSDT原理, 用Windbg做下試驗.

記錄

/** // SSDT的原理 // 假設要Hook ZwQueryDirectoryFile, 用Windbg看看SSDT原理 kd> uf ZwQueryDirectoryFile nt!ZwQueryDirectoryFile: 804ff8ec b891000000 mov eax,91h // 91h是指KeServiceDescriptorTable的數組下標91h 804ff8f1 8d542404 lea edx,[esp+4] 804ff8f5 9c pushfd 804ff8f6 6a08 push 8 804ff8f8 e884eb0300 call nt!KiSystemService (8053e481) 804ff8fd c22c00 ret 2Ch // 查看KeServiceDescriptorTable[91h]的內容 kd> dd KeServiceDescriptorTable 80553fa0 80502b8c 00000000 0000011c 80503000 80553fb0 00000000 00000000 00000000 00000000 80553fc0 00000000 00000000 00000000 00000000 80553fd0 00000000 00000000 00000000 00000000 80553fe0 00002710 00000000 00000000 00000000 80553ff0 80553ff0 80553ff0 806e2f40 806e2f40 80554000 00000000 00000000 00000000 00000000 80554010 00000000 00000000 00000000 00000000 kd> dd 80502b8c + 91h * 4 80502dd0 80570074 805b4de0 805703ca 806063a4 KeServiceDescriptorTable[91h] = 80570074 kd> uf 80570074 nt!NtQueryDirectoryFile: 將KeServiceDescriptorTable[91h]內容換成R0的自己函數的地址, 就實現了ZwQueryDirectoryFile的SSDTHook */// 如果函數是naked, 聲明時不能加nakedvoid DisableWritePRoctect(void);void EnableWriteProctect(void);__declspec(naked) void DisableWriteProctect(void){ // .text:0001135F push eax // .text:00011360 mov eax, cr0 // .text:00011363 and eax, 0FFFEFFFFh // .text:00011368 mov cr0, eax // .text:0001136B pop eax __asm { push eax mov eax, cr0 and eax, 0FFFEFFFFh mov cr0, eax pop eax }}__declspec(naked) void EnableWriteProctect(void){ // .text:00011387 push eax // .text:00011388 mov eax, cr0 // .text:0001138B or eax, 10000h // .text:00011390 mov cr0, eax // .text:00011393 pop eax __asm { push eax mov eax, cr0 or eax, 10000h mov cr0, eax pop eax }} DisableWriteProctect(); // .text:0001136C mov ecx, ds:ZwQueryDirectoryFile // .text:00011372 mov edx, ds:KeServiceDescriptorTable // .text:00011378 mov ecx, [ecx+1] // .text:0001137B mov edx, [edx] // get KeServiceDescriptorTable.ServiceTableBase // .text:0001137D mov eax, g_dwOrgZwQueryDirectoryFile_dWord_13090 // .text:00011382 lea ecx, [edx+ecx*4] // .text:00011385 xchg eax, [ecx] ulApiIndex = *(ULONG_PTR*)((ULONG_PTR)ZwQueryDirectoryFile + 1); // uf ZwQueryDirectoryFile // 804ff8ec b891000000 mov eax,91h // 91h是指KeServiceDescriptorTable的數組下標91h // now ulApiIndex is 0x91 ulApiAddr = (ULONG_PTR)KeServiceDescriptorTable.ServiceTableBase + ulApiIndex * sizeof(ULONG_PTR); *(ULONG_PTR*)ulApiAddr = (ULONG_PTR)g_dwOrgZwQueryDirectoryFile_dword_13090; EnableWriteProctect();
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 太仆寺旗| 莱芜市| 水富县| 建阳市| 大庆市| 麦盖提县| 高阳县| 道真| 宜昌市| 北碚区| 穆棱市| 娱乐| 朝阳县| 建始县| 内乡县| 南城县| 太和县| 弥渡县| 襄汾县| 金川县| 会宁县| 福海县| 牙克石市| 潢川县| 方城县| 宿松县| 卢龙县| 凤山县| 邵东县| 中卫市| 类乌齐县| 潍坊市| 苏州市| 西城区| 汝南县| 英吉沙县| 英吉沙县| 垫江县| 且末县| 夏邑县| 伽师县|