home >> kernelland >> syscall table

Syscall interception by directly modifying the Syscall table

The syscall table is generally an array of function pointers; these function pointers can be redirected to point to functions implemented in the rootkit, often times an LKM. This type of kernel rootkit is easy to detect compared to other kernel rootkits. A hands on approach is to analyze /proc/kcore with gdb and verify the syscalls against the System.map (A file created at kernel compilation time for debugging purposes). A simpler approach is to run a tool like ktraq, which also has the benefit of disabling this type of rootkit by resetting the syscall function pointers.

A kernel rootkit of this nature would initialize the syscall hooks by using code like the following, which assumes we want to intercept the sys_write, and sys_ioctl syscalls; perhaps we intercept sys_write so that a specific line of text is not written to stdout from /etc/passwd, and sys_getdents64 to hide files.

First define function pointers to point to the original syscalls:


 asmlinkage int (*old_write) (int, const void *, size_t);
asmlinkage int (*old_getdents64) (unsigned int, struct dirent *, unsigned int);

Next we would create new syscalls which serve evil purposes i.e.


 asmlinkage int new_write(int fd, const void *buf, size_t bytes)
 {
   ... evil code ...
   printk(KERN_INFO "This syscall has been hijacked");

   ... Call original syscall ...
   return old_write(fd, buf, bytes);
 }

We would do the same with getdents64 -- however this is not a guide on writing rootkits so I will not cover the real details involved.

To perform the actual syscall interception within a kernel module you would do:


 -- module_init() --
 /* save original */
 old_write = (void *) sys_call_table[__NR_write];
 /* redirect pointer to new code */
 sys_call_table[__NR_write] = (void *) new_write;

 /* same thing */
 old_getdents64 = (void *) sys_call_table[__NR_getdents64];
 sys_call_table[__NR_getdents64] = (void *) new_getdents64;

Now future calls to sys_write and sys_getdents64 are going to be executing the code located at new_write and new_getdents64, which will transfer execution over to the original syscall code once finished.

Once the kernel module is removed the syscalls should be reset:


 -- module_exit() --
 sys_call_table[__NR_write] = (void *)old_write;
 sys_call_table[__NR_getdents64] = (void *)old_getdents64;

This type of kernel rootkit is still common, but is not as stealth as certain newer methods. There are several tools which can detect this type of kernel rootkit, and even one that can disable them like ktraq which is featured on http://www.bitlackeys.com -- there are however times when a tool like this may not be available etc. Here is a method that is useful for detecting this type of infection:


 # grep sys_call_table /boot/System.map 

(or /proc/kallsyms if the option for all kernel symbols is enabled)
Assuming the result is: c048d720


 # gdb /usr/src/linux/vmlinux

Then within gdb you could do

(gdb) x/10 0xc048d720 0xc048d720 : 0xc0127460 0xc011f950 0xc01021a0 0xc01646f0 0xc048d730 : 0xc0164760 0xc0162340 0xc0163320 0xc011f1c0 0xc048d740 : 0xc0162380 0xc016d4b0 (gdb)

Although instead of doing x/10 you would want to do x/N whereas N is the number of syscalls which you can find in /usr/include/asm/unistd.h generally.
In another console you will want to open up /proc/kcore, you can do this by doing


 # gdb /usr/src/linux/vmlinux /proc/kcore

You would have to follow the same steps :

Core was generated by `BOOT_IMAGE=2.6.25-nosmp ro root=803 acpi=off nomsi'.


 #0  0x00000000 in ?? ()
 (gdb) x/10 0xc048d720
 0xc048d720 :  0xc0127460  0xc011f950  0xc01021a0  0xc01646f0
 0xc048d730 :  0xf897f6d0  0xf897f5d0  0xc0163320  0xc011f1c0
 0xc048d740 :  0xc0162380  0xc016d4b0
 (gdb)

Notice the 5th entry has changed from 0xc0164760 to 0xf897f6d0; that is because sys_write has been hijacked.

This type of analysis can also be useful for other types of kernel infection including syscall interception by overwriting the first several bytes of a syscall with a jmp or a push/ret. In Linux one must be careful not to mistake changes for runtime patches -- which have a very specific set of alternative instructions for memory barriers and SMP replacements.

EvilFingers Arsenal




Blogs

Update on Next Version of SpyDLLRemover
Nagareshwar Talekar
Mon, 16 Aug 2010 13:28:57 +0000


Here is the brief update on upcoming release of SpyDLLRemover.  Most of the major work highlighted in our previous blog post has been completed and only some final art work is left out. Below is the fresh glimpse of new banner which is going to replace old one.  Just being the old,  other reason for change [...]


Releasing Soon: New Version of SpyDLLRemover
Nagareshwar Talekar
Mon, 02 Aug 2010 08:16:44 +0000


We are vigorously working on next major version of SpyDLLRemover which will bring out the best changes that our users have been looking for since the beginning. We have received lot of feedbacks directly as well as through various forums mentioning about improvements in SpyDLLRemover. One of the most asked enhancement was the ‘Re-sizable Window feature’ [...]


Rootkit Analytics – The New Look
Nagareshwar Talekar
Mon, 28 Jun 2010 02:01:57 +0000


Rootkit Analytics has the new look and feel and not just that, we are now working on more stuff that would make it user friendly. We aren’t going to list each minute tweak, but there is a lot more to come. Hence, we would complete it all and keep you posted on any major update. [...]


StreamArmor – New Tool to Scan & Sweep Malicious Streams
Nagareshwar Talekar
Sat, 27 Mar 2010 15:59:08 +0000


StreamArmor (previously HiddenADSExplorer) is the sophisticated tool for discovering hidden alternate data streams (ADS) as well as clean them completely from the system. It’s advanced auto analysis coupled with online threat verification mechanism makes it the best tool available in the market for eradicating the evil streams. It comes with fast multi threaded [...]


Now Post Your Rootkit Queries on SpywareAnalytics Forum
Nagareshwar Talekar
Tue, 23 Mar 2010 05:06:19 +0000


Spyware Analytics Forum, the division of EvilFingers empire is released to public now. The main aim of this forum is to provide an interface for home & enterprise users to interact with security professionals. Most users do not really get a chance to directly interact with professionals who can really solve their issues. Spyware Analytics is [...]


Testimonials: Rootkit Analytics Tools
Nagareshwar Talekar
Sun, 07 Mar 2010 23:19:04 +0000


Rootkit Analytics has come up with a “Testimonials” section. This can be seen in our web portal, www.RootkitAnalytics.com: [Click on the above image to enlarge view] We welcome all our users to submit testimonials, as this would increase your visibility in our community and we provide Extended FREE Support* to these users. Enterprise Users: If you are using our [...]


HiddenADSExplorer – Update from Research Center
Nagareshwar Talekar
Mon, 01 Mar 2010 20:29:23 +0000


As our next tool, HiddenADSExplorer is moving towards the final beta stage, we bring you the latest update straight from our research center. HiddenADSExplorer is the first ever tool to not only scan for hidden streams but to explore, analyze and quickly detect hidden malicious content within the streams using the advanced analysis technique.  It is [...]


Ridgewood Cable & Rootkit Analytics – Extends Support
Nagareshwar Talekar
Mon, 22 Feb 2010 01:16:54 +0000


Hello Folks, Thank you for helping us by reading our stuff & using our tools. We are proud to say that we are extending our support to our first ISP Customer – Ridgewood Cable. Thanks to Joshua A. Coody for making this happen. We provide free support: to upgrade our tools to what you would like, if it [...]


Openings for Rootkit Analysts
Nagareshwar Talekar
Wed, 10 Feb 2010 19:34:09 +0000


Rootkit Analytics is seeking for Rootkit Analysts [volunteering] with varying skill-sets and at different levels to join our team.  As a Rootkit Analyst, you will be involved with: Detection, analysis and documentation of rootkits. What would a Rootkit Analyst do? A rootkit analyst would work on collection, research and analysis of rootkit samples. The analyst would be categorizing [...]


New SpyDLLRemover to Remove DLL from System Process
Nagareshwar Talekar
Tue, 09 Feb 2010 04:28:20 +0000


The newer version of SpyDLLRemover v3.2 now support removal malicious DLL from system processes on Vista/Win7 platforms. Starting with Vista, Windows has introduced the session separation feature which prevents processes in one session interacting with process in another session. Normally all system processes including services live in session 0. All user session starts with session 1. [...]


Socialize with RootkitAnalytics

Twitter Feed Blogspot

Links

Rootkits & Enterprise: Enterprise is a major victim to rootkits. What could rootkits do to them?[read more]

Rootkits & Home-users: Do home-users know the seriousness of rootkits? What should a home-user know about rootkits?[read more]

Rootkits & Information Warfare: What does the silent war of intelligence and national security, got to do with rootkit analysis?[read more]

Userland Rootkits: What should one know about userland rootkits?[read more]

Spy DLL Remover: Were you looking for a tool to detect userland rootkits in your Windows box?[read more]

Kernelland Rootkits: What should one know about kernelland rootkits?[read more]

ElfStat: ElfStat is a tool designed for detecting any kernel malware that modifies the text segment of the kernel in memory...[read more]

Syscall/Kernel function interception: This is a more stealth method of syscall hijacking without having to directly modify the syscall table; instead the first several bytes of the syscall are overwritten with a jump to the new code...[read more]

Syscall Interception: What should you know about Syscall interception by directly modifying the Syscall table?[read more]

KsiD [Kernel Symbol Interception Detection]: This tool is designed to detect kernel rootkits and kernel malware which hijack syscalls and kernel functions ...[read more]

IDT /dev/kmem rootkit method: This can be done using several methods including overwriting the first several bytes of the syscall with a jump to other code, or modifying the function pointers.[read more]

Hidden Process Detection: Hidden Process Detection [HPD] using Direct NT System Call Implemenation, PIDB (Process ID Bruteforce) method, CSRSS Process Handle Enumeration and other methods...[read more]

Hidden Registry Detection: Reason for Hiding the Registry Entries, Rootkit techniques to hide, and Detecting Hidden Registry Entries Using Direct NT System Call Method and Directly Reading Hives Method...[read more]

Hidden Service Detection: Hidden Rootkit Services Detection Methods...Enumerating Processes with 'NtControlPipe', Hook Bypass Method through Mapped Image, Services Enumerating Child Processes of Services.exe, Enumerating Services Registry Key...[read more]

Syscall Handler Checker [SHC]: This tool simply verifies whether or not the system call handler system_call() has been patched to call a phony sys_call_table. If a phony sys_call_table appears to be in use, a tool like elfstat can be used for further analysis...[read more]

Firmware Rootkits: Firmware is a small static code that runs on devices ranging from consumer electronics to anything that controls heavy machinery...[read more]

Hypervisor Rootkits: This comes under both firmware and hardware rootkits. The reason being, hypervisor is a virtual environment that runs on the hardware, but basically it is a firmware. Hence, we have drawn the line and dropped this rootkit in the firmware category of rootkits...[read more]

Publications: In this section, we are planning to list all the papers that we have published so far that are rootkit related.

Backdoor Ultimate Defender: In this paper (Backdoor.Win32.UltimateDefender.gtz - Reversing) we analyze install.exe that presents the typical structure of an Medium Evoluted Malware, with basical Obfuscated-Dummy Code...[read more]

Socialize: You could socialize with us by many ways...[read more]

About: Learn about rootkit analytics here...[read more]

Contact us: How can you reach us...[read more]

Our Team: Read more about the rootkit analytics team...[read more]

dwtf v1.0 dwtf is a DLL copying engine ... [read more]

StreamArmor StreamArmor is the sophisticated tool for discovering hidden alternate data streams (ADS)...[read more]

Exploring ADS Alternate Data Stream (ADS) is the lesser known feature of Windows NTFS file system which...[read more]

Installations [from RootkitAnalytics.com]

ToolsCount
~~~~~~~~~~~~~~~~~~~
Spy DLL Remover61316
Stream Armor8531
Elfstat1680
KsiD1127
dwtf1033
SHC862

NOTE: Our tools are listed in many sites and torrents, which makes it hard for us to track all downloads. Hence, we are listing only the total installations from our website.

Socialize with EvilFingers

Twitter Feed Blogspot LinkedIn Delicious Google

Tweets


@EvilFingers Anytime! Have a good week!

Thanks to @EvilFingers for the Spark & @hdmoore for paving the path with his auditkit for DllHijackAuditor http://bit.ly/a3gW1X

Thanks to @EvilFingers for the Spark & @hdmoore for paving the path with his auditkit for DllHijackAuditor http://bit.ly/a3gW1X

Thanks to @EvilFingers for the Spark & @hdmoore for paving the path with his auditkit for DllHijackAuditor http://bit.ly/a3gW1X