RO层挂钩SSDT

2012-08-0801:03:54

SSDT(System Services Descriptor Table),系统服务描述符表。这个表就是一个把ring3的Win32 API和ring0的内核API联系起来。SSDT并不仅仅只包含一个庞大的地址索引表,香港服务器,它还包含着一些其它有用的信息,香港服务器,诸如地址索引的基地址、服务函数个数等。

通过修改此表的函数地址可以对常用windows函数及API进行hook,从而实现对一些关心的系统动作进行过滤、监控的目的。一些HIPS、防毒软件、系统监控、注册表监控软件往往会采用此接口来实现自己的监控模块,

  目前极个别病毒确实会采用这种方法来保护自己或者破坏防毒软件,但在这种病毒进入系统前如果防毒软件能够识别并清除它将没有机会发作.

挂钩代码如下:

1 #include <ntddk.h> 2 3 typedef struct _SystemServiceDescriptorTable 4 { PULONG ServiceCounterTableBase; ULONG NumberOfService; ULONG ParamTableBase; }SystemServiceDescriptorTable,*PSystemServiceDescriptorTable; typedef NTSTATUS(*NTCREATEMUTANT)( 14 IN PUNICODE_STRING DriverServiceName 15 ); 16 17 NTCREATEMUTANT pRealNtCreateMutantAddr;NTSTATUS MyNtCreateMutant( 23 IN PUNICODE_STRING DriverServiceName 24 ){ 28 29 DriverServiceName=DriverServiceName+1;伪造一个错误的句柄 (NTSTATUS)(NTCREATEMUTANT)pRealNtCreateMutantAddr( DriverServiceName); 35 36 } 37 38 NTSTATUS Hook() 39 { 40 ULONG Address;RealServiceAddress = *(ULONG*)Address; 44 pRealNtCreateMutantAddr = (NTCREATEMUTANT)RealServiceAddress; _asm 48 { 49 cli; 50 mov eax, cr0; 51 and eax, not 10000h; 52 mov cr0, eax; 53 } 54 55 *((ULONG*)Address) = (ULONG)MyNtCreateMutant; //替换为我们自己的MyNtCreateMutant函数 _asm 58 { 59 mov eax, cr0; 60 or eax, 10000h; 61 mov cr0, eax; 62 sti; 63 } 64 65 }{ 68 ULONG Address; 69 70 Address = (ULONG)KeServiceDescriptorTable->ServiceTableBase + 97 * 4; __asm 74 { 75 cli 76 mov eax, cr0; 77 and eax, not 10000h ; 78 mov cr0, eax ; 79 } 80 81*((ULONG*)Address) = (ULONG)RealServiceAddress; 82 83 __asm 84 { 85 mov eax, cr0 ; 86 or eax, 10000h ; 87 mov cr0, eax ; 88 sti ; 89 } 90 }VOID Unload(PDRIVER_OBJECT driver) 95 { 96 UNREFERENCED_PARAMETER(driver); 97 UnHook();)); 99100 }101 NTSTATUS DriverEntry(PDRIVER_OBJECT driver, PUNICODE_STRING str)102 {103 NTSTATUS status;104 UNREFERENCED_PARAMETER(str);105 driver->DriverUnload = Unload;106 107 status = Hook();108 return STATUS_SUCCESS;109 }

本段代码摘自:

,免备案空间却又小到连一粒嫉妒的沙石也不能容纳

RO层挂钩SSDT

相关文章:

你感兴趣的文章:

标签云: