Win + SSDT HOOK

Source: Internet
Author: User
Tags ssdt

The following refer to the hacker line of defense 2012 bound No. 294 page

In fact, nothing to say, directly on the code:

SSDT's structure, similar to Win32, but note that the pointer type here can not be substituted with ulong, if you want to replace should be used ulonglong, the reason is not said.

// Structure of SSDT struct _systemservicedescriptortable{    PVOID    servicetablebase;    PVOID    servicecountertablebase;    Ulonglong    Numberofservice;    PVOID    *psystemservicetable; Psystemservicetable keservicedescriptortable;

Gets the code for the address of the structure above;

ulonglong GetKeSeviceDescriptorTable64 () {/*The idea is to read 0xc0000082 the value of this register is the KISYSTEMCALL64 function address, and then through the signature search the SSDT signature is 0x4c8d15 and then the address value of SSDT is offset, and then through the formula: Real address = Current address + current instruction length + offset get SSDT address looks like shadow SSDT address*/Puchar startsearchaddress= (Puchar) __READMSR (0xc0000082); Puchar endsearchaddress= Startsearchaddress +0x500; Puchar I=0; UCHAR B1=0, b2 =0, B3 =0; ULONG Temp=0; Ulonglong Addr=0;  for(i = startsearchaddress; i < endsearchaddress; i++)    {        if(Mmisaddressvalid (i) && mmisaddressvalid (i +1) && Mmisaddressvalid (i +2) ) {B1= *i; B2= * (i +1); B3= * (i +2); if(B1 = =0x4c&& B2 = =0x8d&& B3 = =0x15) {memcpy (&temp, i +3,4); Addr= (ulonglong) temp + (ULONGLONG) i +7;//Plus instruction lengthKdprint (("Find SSDT is%p\n", addr)); returnaddr; }}} kdprint (("Find SSDT error\n")); return 0;}

Traverse all native API addresses:

voidthrougnallservicefuncaddr () {ULONG dwtemp=0; Pulong Servicetablebase=0; ULONG I=0;  for(i =0; I < keservicedescriptortable->numberofservice; i++)    {        if(Mmisaddressvalid (keservicedescriptortable->servicetablebase)) {Servicetablebase= (Pulong) keservicedescriptortable->servicetablebase; Dwtemp=Servicetablebase[i]; Dwtemp= Dwtemp >>4; Dbgprint ("The %dth func addr is%p!\n", I, ((ulonglong) dwtemp+ (ULONGLONG) servicetablebase) &0xffffffff0fffffff); }        Else{dbgprint ("Servicetablebase is fault!\n"); return 0; }    }}

Test results:

WinDbg View Results:

Take zwopenprocess as an example:

Ida found his ID to be 0x23, which is 35. The test result is fffff8000419b038

WinDbg results:

The test is correct.

Finally, if you want to hook it, it's easy.

Win + SSDT HOOK

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.