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

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

SSDTHook的原理

2019-11-10 17:24:14
字體:
供稿:網(wǎng)友

前言

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

記錄

/** // SSDT的原理 // 假設(shè)要Hook ZwQueryDirectoryFile, 用Windbg看看SSDT原理 kd> uf ZwQueryDirectoryFile nt!ZwQueryDirectoryFile: 804ff8ec b891000000 mov eax,91h // 91h是指KeServiceDescriptorTable的數(shù)組下標(biāo)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]的內(nèi)容 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]內(nèi)容換成R0的自己函數(shù)的地址, 就實(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ù)組下標(biāo)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ā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 方山县| 溧阳市| 广汉市| 正宁县| 齐齐哈尔市| 靖西县| 磐石市| 德保县| 凤山市| 宜兴市| 登封市| 曲靖市| 南川市| 大悟县| 临洮县| 封丘县| 张家港市| 兴宁市| 平山县| 垦利县| 义马市| 孟州市| 疏勒县| 平乐县| 丹凤县| 长海县| 高唐县| 防城港市| 娱乐| 泽库县| 仪陇县| 陆良县| 绥棱县| 运城市| 榆中县| 巍山| 正安县| 冷水江市| 平罗县| 香河县| 兴隆县|