|
发表于 2013-10-28 00:04:26
|
显示全部楼层
本帖最后由 ramonliu 于 2013-10-30 12:41 编辑
不知道這是 Ring0 還是 Ring3 上來對 SSDT 處理,
回覆一下, 看看內容... {:soso_e121:}
嗯... include <ntddk.h> Ring0 的 {:soso_e149:}
疑, 我在網上扒到的鬼佬, 特徵碼 14個 BYTE {:soso_e122:}
char KiSystemServiceStart_pattern[14] = "\x8B\xF8\xC1\xEF\x07\x83\xE7\x20\x25\xFF\x0F\x00\x00";
不過我用 WinDbg 找了一下位置...
kd> db nt!KiSystemServiceStart
fffff800`03ccfcde 48 89 a3 d8 01 00 00 8b-f8 c1 ef 07 83 e7 20 25
唔... 不一樣... {:soso_e134:}
後來發現, nt!xxx 的API, 跟 nt!KeServiceDescriptorTable 的位置是固定相對, 然而 nt!KeServiceDescriptorTable 的位置
卻不一定每次相同, 所以找 nt!KeServiceDescriptorTable 的方式, 可以這麼寫:- ULONG_PTR GetKeServiceDescriptorTable64()
- {
- //Pattern
- ULONG kiServiceTable_patten[8] = {
- 0x04134b00, 0x02f53600, 0xfff6f000, 0x02e80205,
- 0x031c3b06, 0x0312ba05, 0x02bacc01, 0x02b49200
- };
- /*
- kd> dd nt!KeServiceDescriptorTable
- fffff800`03f15940 03cde800 fffff800 00000000 00000000
- fffff800`03f15950 00000191 00000000 03cdf48c fffff800
- */
-
- //Scan boundaries
- ULONG_PTR CodeScanStart = (ULONG_PTR)KdDebuggerNotPresent;
- /*
- kd> dd nt!KdDebuggerNotPresent
- fffff800`03edf391 00000000 00000000 bb000000 00db1dbb
- fffff800`03edf3a1 00000000 14000000 00000000 00000000
- */
- // offset: (fffff800`03f15940-fffff800`03edf391=0x365AF)
- PULONG64 ptrSDT = (PULONG64) (CodeScanStart + 0x365AF);
- ULONG_PTR ptrST = (ULONG_PTR) *ptrSDT;
- if (!memcmp((char*)ptrST, (char*)&kiServiceTable_patten[0], sizeof(ULONG)*8))
- {
- return (ULONG_PTR)ptrSDT;
- }
- return 0;
- }
复制代码 不知道換了 VISTA/8/8.1 X64, 相對位置是否有變化沒? {:soso_e132:}
哈哈, 這二天玩內核, VBOX 被我弄死好多次... {:soso_e117:}
不過也因為如此, 才知道, 位置不是固定的, 這次的偏差值在 0x36C8F
看來還是得用區間找尋法了... {:soso_e135:}
整理一下研究結果:
鬼佬的CODE, 主要是要找出 nt!KiSystemServiceStart 的位置, 再由它裡面的匯編 (0x4c8d)
fffff800`03c80ff2 4c8d1547782300 lea r10,[nt!KeServiceDescriptorTable (fffff800`03eb8840)]
fffff800`03c80ff9 4c8d1d80782300 lea r11,[nt!KeServiceDescriptorTableShadow (fffff800`03eb8880)]
算出 nt!KeServiceDescriptorTable 的位置, 而尋找位置, 搜尋範圍,
&_strnicmp ~ &KdDebuggerNotPresent, 然而不知道是不是 VS2012的問題,
_strnicmp 的位置, 不是 nt!strnicmp 或 nt!_ascii_strnicmp, 而是 (your driver)!strnicmp
也因為如此會造成讀取錯過而重開機... 我重新找了2個點, 對於目前來說是正確...
如果有人用了, 失效了, 請跟我說喲~ {:soso_e113:}
ULONGLONG ptrStart = (ULONGLONG)KeSynchronizeExecution;
ULONGLONG ptrEnd = (ULONGLONG)KeBugCheck; |
|