awesome-linux-rootkits/details/reptile.md

87 lines
3.3 KiB
Markdown
Raw Permalink Normal View History

2018-07-02 19:55:36 +00:00
# Reptile rootkit details
2018-07-02 15:20:13 +00:00
https://github.com/f0rb1dd3n/Reptile
2018-07-02 16:14:03 +00:00
## Environment
2018-07-02 19:49:15 +00:00
- x86, x86_64
2018-07-02 16:14:03 +00:00
- Linux kernel 2.6.x/3.x/4.x
2018-07-02 19:58:19 +00:00
- Debian/Ubuntu, RHEL/CentOS/Fedora
2018-07-02 16:14:03 +00:00
## Persistency
Boot-time module loading using OS-specific startup files:
2018-07-02 16:17:31 +00:00
- /etc/modules (debian/ubuntu)
2018-07-02 19:55:36 +00:00
- https://github.com/linux-rootkits/Reptile/blob/master/setup.sh#L296
2018-07-02 16:17:31 +00:00
- /etc/rc.modules (redhat/centos/fedora)
2018-07-02 19:55:36 +00:00
- https://github.com/linux-rootkits/Reptile/blob/master/setup.sh#L298
2018-07-02 19:49:15 +00:00
2018-07-02 16:14:03 +00:00
## Detection evasion
Rootkit is trying to evade from detection by:
2018-07-02 16:17:31 +00:00
- hiding files by name
2018-07-02 19:49:15 +00: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 16:14:03 +00:00
- tampering contents of startup files while reading
2018-07-02 19:49:15 +00: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 16:14:03 +00:00
## Management interface
2018-07-02 19:57:33 +00: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 19:49:15 +00:00
2018-07-03 20:35:29 +00:00
Supported commands are:
2018-07-02 16:14:03 +00:00
- hiding/unhiding processes
2018-07-02 19:49:15 +00:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L518
2018-07-02 16:14:03 +00:00
- hiding/unhiding rootkit's module
2018-07-02 19:49:15 +00:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L514
2018-07-02 16:14:03 +00:00
- enabling/disabling of tampering file content function
2018-07-02 19:49:15 +00:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L524
2018-07-02 16:14:03 +00:00
- gaining root priveleges to calling process
2018-07-02 19:49:15 +00:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L528
2018-07-02 16:14:03 +00:00
2018-07-02 16:17:54 +00:00
## Altering system behaviour
2018-07-02 16:14:03 +00:00
2018-07-02 16:17:31 +00: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 19:49:15 +00:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L681
2018-07-02 16:32:29 +00:00
- netfilter hook (`NF_IP_PRI_FIRST`)
2018-07-02 19:49:15 +00: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 16:14:03 +00:00
## Hiding (tampering) of file contents
2018-07-02 16:40:41 +00:00
Filtering of file content while reading:
- hook `sys_call_table[__NR_read]`
2018-07-02 19:52:43 +00:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L282
2018-07-02 19:49:15 +00:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L638
2018-07-02 16:14:03 +00:00
## Hiding of files and directories
2018-07-02 16:40:41 +00:00
Filtering of directory entries:
- hook `sys_call_table[__NR_getdents]`
2018-07-02 19:49:15 +00:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L594
2018-07-02 16:40:41 +00:00
- hook `sys_call_table[__NR_getdents64]`
2018-07-02 19:49:15 +00:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L550
2018-07-02 16:14:03 +00:00
## Hiding of processes and process trees
2018-07-02 16:18:51 +00:00
Filtering PID-like numeric entries while listing `/proc`:
- getdents/getdents64 hook used
2018-07-02 19:49:15 +00:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L619
2018-07-02 16:22:48 +00:00
- hidden tasks are marked using `task->flags` (bit `0x10000000`)
2018-07-02 19:49:15 +00:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L189
2018-07-02 16:14:03 +00:00
2018-07-02 16:38:46 +00:00
## Backdoor/shell
2018-07-02 16:32:29 +00:00
Reverse shell spawning by port-knocking-like technique:
2018-07-02 16:40:41 +00:00
- magic packet with token used (`ICMP/UDP/TCP`)
2018-07-02 19:49:15 +00:00
- https://github.com/linux-rootkits/Reptile/blob/master/rep_mod.c#L356
2018-07-02 16:32:29 +00:00
- spawning root-shell connection to remote host
2018-07-02 19:49:15 +00: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