国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 介休市| 常山县| 镇康县| 上犹县| 原平市| 伽师县| 龙山县| 句容市| 文安县| 双桥区| 阳原县| 四子王旗| 巴塘县| 萨迦县| 滦平县| 五华县| 嫩江县| 阜平县| 麟游县| 新化县| 若羌县| 大庆市| 高雄县| 剑川县| 龙泉市| 南部县| 太谷县| 探索| 石家庄市| 手游| 南岸区| 北票市| 定州市| 修武县| 博罗县| 连山| 桐梓县| 福海县| 磐石市| 南乐县| 新巴尔虎左旗|