|
|
||
|
|
SIG^2 Secure Code Study Project Tool Release ApiHookCheck Version 1.01 (API Hook Check)by Tan Chew Keong15 April 2004 Introduction API hooking is a useful technique that can be used to monitor API calls used by Win32 programs. This allows understanding of the programs' functionalities based on the APIs that are called and their input parameters. However, API hooking is also used by rootkits and other malicious code to modify the behaviour of certain APIs to hide files, network ports, processes or services. This tool can help to detect the presence of system-wide API hooks that are implemented based on import/export table modifications and insertion of JMP instructions at the start of the real API. API Hooking Techniques The idea behind API hooking is to allow an API call to be redirected to a replacement function. This replacement function will usually perform some manipulation of the input parameters before transferring control back to the called API. The replacement function could also manipulate the API's return results before passing them back to the caller. This simple idea has been used by rootkits and trojans to hide files, processes and network ports. For example, by hooking FindFirstFileA and FindNextFileA, it is possible to manipulate the list of filenames returned, thus allowing certain files to be hidden from the directory listing. This tool can detect the presence of system-wide API hooks that are implemented based on the following techniques.
Overwriting the start of the hooked API with a JMP instruction Another technique that can be used to implement API hooking involves overwriting the start of the hooked API with a JMP instruction that cause execution to be transferred to the replacement function. This technique requires less modifications within the memory space of the hooked process as compared to the previous technique.ApiHookCheck Algorithm The IAT of ApiHookCheck.exe contains the entry-point address of API imports from kernel32.dll, advapi32.dll, psapi.dll, iphlpapi.dll, snmpapi.dll and netapi32.dll. These DLL entry-point addresses are checked to ensure that they point within the memory space of their respectively DLLs. Any discrepancies (i.e. an API with entry-point address that points outside the memory space of the DLL that it belongs to) will be reported. The EAT entries of the DLLs are also checked to ensure that all API entry-points are within the address space of their respectively DLLs. To detect API hooking based on the second method, this tool checks for the presence of JMP instruction at the start of any APIs that could cause execution to be transferred out of the memory space of the DLL. Usage ApiHookCheck.exe > result.html This output of this tool is a HTML report that should be redirected to a file so that it could be viewed using a browser. A sample report is shown in the link below.
Contacts For further enquries or to submit malicious code for our analysis, email them to the following. Overall-in-charge: Tan Chew Keong
|
|||