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

首頁 > 學院 > 開發(fā)設計 > 正文

SSDTHook的原理

2019-11-10 17:15:23
字體:
來源:轉載
供稿:網(wǎng)友

前言

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

記錄

/** // SSDT的原理 // 假設要Hook ZwQueryDirectoryFile, 用Windbg看看SSDT原理 kd> uf ZwQueryDirectoryFile nt!ZwQueryDirectoryFile: 804ff8ec b891000000 mov eax,91h // 91h是指KeServiceDescriptorTable的數(shù)組下標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的自己函數(shù)的地址, 就實現(xiàn)了ZwQueryDirectoryFile的SSDTHook */// 如果函數(shù)是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的數(shù)組下標91h // now ulApiIndex is 0x91 ulApiAddr = (ULONG_PTR)KeServiceDescriptorTable.ServiceTableBase + ulApiIndex * sizeof(ULONG_PTR); *(ULONG_PTR*)ulApiAddr = (ULONG_PTR)g_dwOrgZwQueryDirectoryFile_dword_13090; EnableWriteProctect();
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 乐东| 肇东市| 远安县| SHOW| 伊宁县| 南华县| 灵宝市| 奉贤区| 绿春县| 且末县| 荣昌县| 崇信县| 阿拉善右旗| 灵武市| 偏关县| 武乡县| 东乡| 普安县| 宜良县| 清水河县| 金山区| 平阴县| 宁晋县| 炎陵县| 安泽县| 洪泽县| 保山市| 米林县| 本溪市| 桐乡市| 日照市| 江津市| 嘉黎县| 武冈市| 莱州市| 新巴尔虎右旗| 永修县| 葵青区| 繁昌县| 平利县| 扬中市|