2018-07-02 11:20:13 -04:00
|
|
|
# Reptile kernel rootkit details
|
|
|
|
|
|
|
|
https://github.com/f0rb1dd3n/Reptile
|
2018-07-02 12:14:03 -04:00
|
|
|
|
2018-07-02 12:40:41 -04:00
|
|
|
- not able to tamper file contents while reading byte-by-byte (:exclamation:)
|
|
|
|
- not able to hide all threads and children of hidden (parent) process (:exclamation:)
|
2018-07-02 12:38:28 -04:00
|
|
|
|
2018-07-02 12:14:03 -04:00
|
|
|
## Environment
|
|
|
|
|
|
|
|
- Linux kernel 2.6.x/3.x/4.x
|
|
|
|
- x86 (`sys_call_table` search method is x86-only)
|
|
|
|
|
|
|
|
## Persistency
|
|
|
|
|
|
|
|
Boot-time module loading using OS-specific startup files:
|
2018-07-02 12:17:31 -04:00
|
|
|
- /etc/modules (debian/ubuntu)
|
|
|
|
- /etc/rc.modules (redhat/centos/fedora)
|
2018-07-02 12:14:03 -04:00
|
|
|
|
|
|
|
## Detection evasion
|
|
|
|
|
|
|
|
Rootkit is trying to evade from detection by:
|
2018-07-02 12:17:31 -04:00
|
|
|
- hiding files by name
|
2018-07-02 12:14:03 -04:00
|
|
|
- tampering contents of startup files while reading
|
2018-07-02 12:17:31 -04:00
|
|
|
- hiding kernel module by unlinking from `module_list`
|
2018-07-02 12:14:03 -04:00
|
|
|
|
|
|
|
## Management interface
|
|
|
|
|
|
|
|
Implemented via `kill(2)` by hooking `sys_call_table[__NR_kill]` entry. Supported commands are:
|
|
|
|
- hiding/unhiding processes
|
|
|
|
- hiding/unhiding rootkit's module
|
|
|
|
- enabling/disabling of tampering file content function
|
|
|
|
- gaining root priveleges to calling process
|
|
|
|
|
2018-07-02 12:17:54 -04:00
|
|
|
## Altering system behaviour
|
2018-07-02 12:14:03 -04:00
|
|
|
|
2018-07-02 12:17:31 -04:00
|
|
|
Hooking of system calls by patching syscall-handlers in `sys_call_table[]`:
|
|
|
|
- to write to read-only page `CR0/WP` technique used (x86-only)
|
2018-07-02 12:32:29 -04:00
|
|
|
- netfilter hook (`NF_IP_PRI_FIRST`)
|
2018-07-02 12:14:03 -04:00
|
|
|
|
|
|
|
## Hiding (tampering) of file contents
|
|
|
|
|
2018-07-02 12:40:41 -04:00
|
|
|
Filtering of file content while reading:
|
|
|
|
- hook `sys_call_table[__NR_read]`
|
2018-07-02 12:14:03 -04:00
|
|
|
|
|
|
|
## Hiding of files and directories
|
|
|
|
|
2018-07-02 12:40:41 -04:00
|
|
|
Filtering of directory entries:
|
|
|
|
- hook `sys_call_table[__NR_getdents]`
|
|
|
|
- hook `sys_call_table[__NR_getdents64]`
|
2018-07-02 12:14:03 -04:00
|
|
|
|
|
|
|
## Hiding of processes and process trees
|
|
|
|
|
2018-07-02 12:18:51 -04:00
|
|
|
Filtering PID-like numeric entries while listing `/proc`:
|
|
|
|
- getdents/getdents64 hook used
|
2018-07-02 12:22:48 -04:00
|
|
|
- hidden tasks are marked using `task->flags` (bit `0x10000000`)
|
2018-07-02 12:14:03 -04:00
|
|
|
|
2018-07-02 12:38:46 -04:00
|
|
|
## Backdoor/shell
|
2018-07-02 12:32:29 -04:00
|
|
|
|
|
|
|
Reverse shell spawning by port-knocking-like technique:
|
2018-07-02 12:40:41 -04:00
|
|
|
- magic packet with token used (`ICMP/UDP/TCP`)
|
2018-07-02 12:32:29 -04:00
|
|
|
- spawning root-shell connection to remote host
|