awesome-linux-rootkits/details/reptile.md

87 lines
3.3 KiB
Markdown
Raw Normal View History

2018-07-02 15:55:36 -04:00
# Reptile rootkit details
2018-07-02 11:20:13 -04:00
https://github.com/f0rb1dd3n/Reptile
2018-07-02 12:14:03 -04:00
## Environment
2018-07-02 15:49:15 -04:00
- x86, x86_64
2018-07-02 12:14:03 -04:00
- Linux kernel 2.6.x/3.x/4.x
2018-07-02 15:58:19 -04:00
- Debian/Ubuntu, RHEL/CentOS/Fedora
2018-07-02 12:14:03 -04:00
## Persistency
Boot-time module loading using OS-specific startup files:
2018-07-02 12:17:31 -04:00
- /etc/modules (debian/ubuntu)
2018-07-02 15:55:36 -04:00
- https://github.com/linux-rootkits/Reptile/blob/master/setup.sh#L296
2018-07-02 12:17:31 -04:00
- /etc/rc.modules (redhat/centos/fedora)
2018-07-02 15:55:36 -04:00
- https://github.com/linux-rootkits/Reptile/blob/master/setup.sh#L298
2018-07-02 15:49:15 -04:00
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 15:49:15 -04:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L575
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L619
2018-07-02 12:14:03 -04:00
- tampering contents of startup files while reading
2018-07-02 15:49:15 -04:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L638
- hiding kernel module by unlinking from `modules`-list
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L145
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L157
2018-07-02 12:14:03 -04:00
## Management interface
2018-07-02 15:57:33 -04:00
Implemented via `kill(2)`:
- hook`sys_call_table[__NR_kill]`
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L509
2018-07-02 15:49:15 -04:00
2018-07-03 16:35:29 -04:00
Supported commands are:
2018-07-02 12:14:03 -04:00
- hiding/unhiding processes
2018-07-02 15:49:15 -04:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L518
2018-07-02 12:14:03 -04:00
- hiding/unhiding rootkit's module
2018-07-02 15:49:15 -04:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L514
2018-07-02 12:14:03 -04:00
- enabling/disabling of tampering file content function
2018-07-02 15:49:15 -04:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L524
2018-07-02 12:14:03 -04:00
- gaining root priveleges to calling process
2018-07-02 15:49:15 -04:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L528
2018-07-02 12:14:03 -04:00
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 15:49:15 -04:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L681
2018-07-02 12:32:29 -04:00
- netfilter hook (`NF_IP_PRI_FIRST`)
2018-07-02 15:49:15 -04:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L356
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L687
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 15:52:43 -04:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L282
2018-07-02 15:49:15 -04:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L638
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]`
2018-07-02 15:49:15 -04:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L594
2018-07-02 12:40:41 -04:00
- hook `sys_call_table[__NR_getdents64]`
2018-07-02 15:49:15 -04:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L550
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 15:49:15 -04:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L619
2018-07-02 12:22:48 -04:00
- hidden tasks are marked using `task->flags` (bit `0x10000000`)
2018-07-02 15:49:15 -04:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L189
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 15:49:15 -04:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L356
2018-07-02 12:32:29 -04:00
- spawning root-shell connection to remote host
2018-07-02 15:49:15 -04:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L328
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L210