Click here to Skip to main content
15,896,154 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How can insert menu to dialog by ce application? Pin
Patrick Tang10-Mar-10 16:01
Patrick Tang10-Mar-10 16:01 
GeneralRe: How can insert menu to dialog by ce application? Pin
KingsGambit10-Mar-10 17:52
KingsGambit10-Mar-10 17:52 
QuestionDetecting Hooks [modified] Pin
hxhl9510-Mar-10 13:01
hxhl9510-Mar-10 13:01 
AnswerRe: Detecting Hooks Pin
Baltoro10-Mar-10 13:55
Baltoro10-Mar-10 13:55 
GeneralRe: Detecting Hooks Pin
hxhl9510-Mar-10 14:25
hxhl9510-Mar-10 14:25 
GeneralRe: Detecting Hooks Pin
Baltoro11-Mar-10 9:39
Baltoro11-Mar-10 9:39 
GeneralRe: Detecting Hooks Pin
Baltoro11-Mar-10 9:49
Baltoro11-Mar-10 9:49 
GeneralLooking for Hooks Pin
Baltoro11-Mar-10 10:34
Baltoro11-Mar-10 10:34 
I have copied a brief section here about the general techniques involved in looking for User Mode IAT hooks, again, from "Rootkits: Subverting the Windows Kernel". I have left out the description of Inline Hooks, because they are implemented in assembly language and require some experience in disassembling.

Looking For Hooks
A memory-based detection method is to look for hooks within the operating system and within processes. There are many places where a hook can hide, including the following:
Import Address Table (IAT)
System Service Dispatch Table (SSDT), also known as the KeServiceDescriptorTable
Interrupt Descriptor Table (IDT) with one per CPU
Drivers' I/O Request Packet (IRP) handler
Inline function hooks
The basic algorithm for identifying a hook is to look for branches that fall outside of an acceptable range. Such branches would be produced by instructions like call or jmp. Defining an acceptable range is not difficult (for the most part). In a process Import Address Table (IAT), the name of the module containing imported functions is listed. This module has a defined start address in memory, and a size. Those numbers are all you need to define an acceptable range.
Likewise for device drivers: All legitimate I/O Request Packet (IRP) handlers should exist within a given driver's address range, and all entries in the System Service Dispatch Table (SSDT) should be within the address range of the kernel process, ntoskrnl.exe.
Finding Interrupt Discriptor Table (IDT) hooks is a bit more difficult, because you do not know what the acceptable ranges should be for most of the interrupts. The one you know for sure, however, is the INT 2E handler. It should point to the kernel, ntoskrnl.exe.
Inline hooks are the hardest to detect, because they can be located anywhere within the function—requiring a complete disassembly of the function in order to find them—and because functions can call addresses outside the module's address range under normal circumstances. In the following sections, we will explain how to detect SSDT, IAT, and some inline hooks.

Finding IAT Hooks
IAT hooks are extremely popular with current Windows rootkits. IAT hooks are in the userland portion of a process, so they are easier to program than kernel rootkits, and do not require the same level of privilege. Because of this, you should make sure your detection software looks for IAT hooks.
Finding IAT hooks is very tedious, and implementing a search for them requires many of the techniques covered in previous chapters. However, those steps are relatively straightforward. First, change contexts into the process address space of the process you want to scan for hooks. In other words, your detection code must run within the process you are scanning.
Next, your code needs a list of all the DLLs the process has loaded. For the process, and every DLL within the process, your goal is to inspect the functions imported by scanning the IAT and looking for function addresses outside the range of the DLL the function is exported from. After you have the list of DLLs and the address range for each one, you can walk each IAT of each DLL to see whether there are any hooks. Particular attention should be paid to Kernel32.dll and NTDLL.DLL. These are common targets of rootkits, because these DLLs are the userland interface into the operating system.
If the IAT is not hooked, you should still look at the function itself to determine whether an inline hook is present.
GeneralRe: Detecting Hooks Pin
hxhl9511-Mar-10 13:29
hxhl9511-Mar-10 13:29 
GeneralRe: Detecting Hooks Pin
Baltoro13-Mar-10 10:47
Baltoro13-Mar-10 10:47 
GeneralRe: Detecting Hooks Pin
hxhl9513-Mar-10 10:49
hxhl9513-Mar-10 10:49 
QuestionVS2005 & VS2008 DLL Compilation issues Pin
masnu10-Mar-10 7:56
masnu10-Mar-10 7:56 
AnswerRe: VS2005 & VS2008 DLL Compilation issues Pin
CPallini10-Mar-10 8:01
mveCPallini10-Mar-10 8:01 
GeneralRe: VS2005 & VS2008 DLL Compilation issues Pin
masnu10-Mar-10 9:19
masnu10-Mar-10 9:19 
QuestionRe: VS2005 & VS2008 DLL Compilation issues Pin
CPallini10-Mar-10 10:24
mveCPallini10-Mar-10 10:24 
AnswerRe: VS2005 & VS2008 DLL Compilation issues Pin
Chris Losinger10-Mar-10 8:13
professionalChris Losinger10-Mar-10 8:13 
GeneralRe: VS2005 & VS2008 DLL Compilation issues Pin
masnu10-Mar-10 9:21
masnu10-Mar-10 9:21 
QuestionAdministration Rights for my Application by Token Pin
Joschwenk66610-Mar-10 2:58
Joschwenk66610-Mar-10 2:58 
AnswerRe: Administration Rights for my Application by Token Pin
Eugen Podsypalnikov10-Mar-10 3:17
Eugen Podsypalnikov10-Mar-10 3:17 
QuestionWM_GETFONT returns NULL Pin
sashoalm10-Mar-10 1:53
sashoalm10-Mar-10 1:53 
AnswerRe: WM_GETFONT returns NULL Pin
Steve Thresher10-Mar-10 2:24
Steve Thresher10-Mar-10 2:24 
GeneralRe: WM_GETFONT returns NULL Pin
sashoalm10-Mar-10 2:50
sashoalm10-Mar-10 2:50 
QuestionHTML Editing Control for Win32 Pin
Steve Thresher10-Mar-10 0:08
Steve Thresher10-Mar-10 0:08 
AnswerRe: HTML Editing Control for Win32 Pin
KingsGambit10-Mar-10 0:37
KingsGambit10-Mar-10 0:37 
GeneralRe: HTML Editing Control for Win32 Pin
Steve Thresher10-Mar-10 1:07
Steve Thresher10-Mar-10 1:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.