Intro to Sebek
Sebek came about as an answer to the desire to capture an attackers actions without them knowing they were there. Sebek is based on the concept of kernel rootkits, with it’s origins coming from linux with influence from the adore rootkit. Sebek is a data monitoring tool which provides capabilities to: record keystrokes of a session that is using encryption, recover files copied with SCP, capture passwords used to log in to remote system, recover passwords used to enable Burneye protected binaries and accomplish many other forensics related tasks. Data capture is accomplished with the use of a kernel module. With this module we gain access to the kernel space of the honeypot. Using this access, we then capture all read() activity / data. Sebek does this by replacing the stock read() function in the System Call Table with a new one. The new function simply calls the old function, copies the contents into a packet buffer, adds a header, and sends the packet to the server. The act of replacing the stock function involves changing one function pointer in the System Call Table. When a process calls the standard read() function in user space, a system call is made. This call maps to an index offset in the System Call Table array. Because Sebek modified the function pointer at the read index to point to its own implementation, the execution switches into the kernel context and begins executing the new Sebek read call. Data that remains encrypted is of little use; to view the data or act on it in some way it must be decrypted. In the case of an SSH session the keystrokes are decrypted and send to the shell to have actions performed. This act typically involves a system call. By collecting data in kernel space, we can gain access to the data within the system call, after it has been decrypted but before it has been passed to the process that is about to use it. This allows sebek to bypass encryption and capture the data without having to try to break the encryption.
Since one of the objects of Sebek is to avoid attackers knowing it’s there, its obvious that it should be hidden. In the linux version, a second kernel module is included that is called cleaner. This module manipulates the linked list of installed modules in such a way that Sebek is removed from the list. This is not a completely robust method of hiding and techniques for detecting such hidden modules do exist. In Windows, the installer hides the system driver that is in the \etc\drivers directory. It also cleans up and hides registry keys pertaining to sebek.
Once data has been recorded it needs to pass it off to a central monitor. If Sebek were to do this via normal packet transmissions it would be possible for the attacker to see the data via sniffing. Sebek sends data over UDP, but before it sends it the kernel is modified so that the attacker can not see it. First it modifies the kernel such that system is unable to see Sebek Packets, not just the packets generated by the local host, but any appropriately configured Sebek Packet. Next, when Sebek transmits data onto the network, it ensures that the system cannot block the transmission or even count the packets transmitted. For every read() request, Sebek generates one or more log packets. Each packet contains a bit of information about the context of the call made and the data that was accessed with the call. Each packet contains one Sebek record. After each packet is built, it is sent directly to the device driver, bypassing the raw socket code path as well as the packet filtering code path. Since packet sniffers are libpcap based and libpcap uses the raw socket interface to collect packets, sniffers installed on a host running Sebek are unable to see the Sebek packets generated.

