Chapter 12. Rootkits

Rootkit technology is not really new; it began back in the Unix world as a group of Trojan applications that replaced the standard ones for hiding files and providing higher access. While detection technique evolved using integrity detection and other means, the rootkit also evolved by moving from the user space to the more powerful kernel space, usually as kernel modules and using different techniques to stay hidden. Contrary to the backdoor that offers more functionally to the remote administrator, the role of the rootkit is mainly to hide itself and other applications. Usually the race between the detector and the rootkit is won by the first one to be installed on the system. Therefore it is important to be ready and plan ahead before putting any system into production. Trying to detect and remove a rootkit after it is installed, if nothing was done previously, could end up being a very difficult task—the best time-saving solution might be to format and re-install the whole system.

There are several rootkits available. We'll peer into the best ones for each platform and note their strengths and weaknesses. If you want more information on rootkit technology and more specific "under the hood" documentation of how they work and interact with the various operating systems they can be used against, a great resource is the web site http://www.rootkit.com. In addition, the book RootKits: Subverting the Windows Kernel by Jamie Butler and Greg Hoglund (Addison-Wesley) is a great resource.

Hacker Defender (hxdef) is an open source Windows NT/2000/XP rootkit. It is not just a proof of concept (like most rootkits); it is a full-fledged rootkit with multiple features. hxdef is able to hide its process, port, registry entries, and files by hooking multiple Windows APIs. Since it is based on hooking (replacing valid system calls or DLLs by Trojaned ones), it can bypass multiple detection systems except for some, such as IceSword (see Windows Rootkit Detectors), Backlight, or Kaspersky. Note that other antivirus apps might also detect hxdef.

The following piece of code is a configuration file (the .ini file) for Hacker Defender 1.00. You must modify this file to fit your needs.

[Hidden Table]  # table to be hidden
hxdef*
rcmd.exe
[Root Processes]  # Process to be hidden
hxdef*
rcmd.exe
[Hidden Services] #Service name to be hidden
HackerDefender*
[Hidden RegKeys]  # Registry keys to be hidden
HackerDefender100
LEGACY_HACKERDEFENDER100
HackerDefenderDrv100
LEGACY_HACKERDEFENDERDRV100
[Hidden RegValues]   # Registry values to be hidden
[Startup Run] # software to start when the rootkit is loaded
[Free Space] # fake free space to be added to the hard drive, is useful if you use the
 host as a file server
[Hidden Ports]  #port to be hidden
TCP: 8080, 1234
UDP: 12,13,14,15
[Settings]
Password=hxdef-rulez
BackdoorShell=hxdef.exe
FileMappingName=_-=[Hacker Defender]=-_
ServiceName=HackerDefender100
ServiceDisplayName=HXD Service 100
ServiceDescription=powerful NT rootkit
DriverName=HackerDefenderDrv100
DriverFileName=hxdefdrv.sys

By default, Hacker Defender hides itself. Even though it does provide a basic backdoor (cmd.exe), it is usually better to use the stealth capacity of Hacker Defender to hide more appropriate tools for your personal tasks, whether it is an exploitation agent from Core Impact (see Running an Exploit and Core Impact Overview ), a Python shell, a botnet client, or a user-monitoring system. Hacker Defender hides stuff (e.g., process, port, registry, service) and does it well. If you're trying to use Hacker Defender for anything more, it's best to rely on a different tool.

Hacker Defender offers a small utility to connect to its rookit from a remote system. The cool part is its ability to use ports already opened by other applications. Since the rootkit can watch any incoming communication, the backdoor integrated in the system uses a 256-byte key to connect to the rootkit over a port already open by another application, such as IIS. So any open port receiving over 256 bytes on the target system could be used to communicate with the backdoor (this includes HTTP, SMTP, Telnet, SMB, and RPC). The backdoor provided in Hacker Defender is a simple command prompt. While it might not be as powerful as other backdoors, it provides the basic functions to install and run a full-fledged remote administration application.