CodeAndData / kerokid

GNU General Public License v2.0
8 stars 5 forks source link

KEROKID: the KErnel ROotKIt Detector

Quick Start Guide

make linux-x86_64           // or linux-x86 for 32bit environments
sudo insmod kerokid.ko

Results can be accessed via dmesg (available on all kernel versions) or /proc/kerokid (requires Kernel 3.10 or newer)

The system is rescanned whenever a new kernel module is loaded.

Alternatively, you can initialize a rescan by writing to /proc/kerokid/rescan as root. (requires Kernel 3.10 or newer)

echo '1' > /proc/kerokid/rescan

This can be used for periodic automated rescans via cron jobs.

The idea of KEROKID

Kernel Level Rootkits use different techniques to hide themselves, e.g.:

Nevertheless, these rootkits need space in memory. Therefore KEROKID uses memory forensics to detect rootkits in the kernel's heap or module space. In addition, rootkits must react to user or system activity and therefore use hooks or subscribe themselves to notifiers. KEROKID detects such suspicious calls originating from:

Proc output (requires Kernel 3.10 or newer)

results and further information can be accessed through /proc/kerokid

Dmesg output (available on all kernel versions)

This is a sample output showing a hidden module that manipulated five syscall table entries. The addresses are the destinations of the manipulated syscalls.

[  421.296881] KEROKID: Started
[  421.302176] KEROKID: Check for syscall table hooks...
[  421.302176] KEROKID: ALERT: Jump to hidden module: ffffffffa0002010 
[  421.302176] KEROKID: ALERT: Jump to hidden module: ffffffffa0002050 
[  421.302176] KEROKID: ALERT: Jump to hidden module: ffffffffa0002020 
[  421.302176] KEROKID: ALERT: Jump to hidden module: ffffffffa0002040 
[  421.302176] KEROKID: ALERT: Jump to hidden module: ffffffffa0002000 
[  421.302176] KEROKID: Check for inline hooks...
[  421.304729] KEROKID: Check notifier_subscriptions...
[  421.304729] KEROKID: -> Check keyboard notifier chain... 
[  421.308363] KEROKID: -> Check module notifier chain... 
[  421.308363] KEROKID: -> Check netdevice notifier chain... 
[  421.308363] KEROKID: -> Check netevent notifier chain... 

What we can detect...

What we cannot detect at the moment...

Successfully tested with

x86

x86_64

Implementation details and development related stuff

Debugging

Debug features can be enabled by:

make linux-x86_64 DEBUG=y

Dumping loaded module

At the moment you can only dump unhidden modules. As root use the following command to get a list of loaded modules:

cat /proc/kerokid/modules_list

Pick the NUMBER of the corresponding Module and type:

echo "NUMBER" > /proc/kerokid/dump_module

The module binary can now be copied from /proc/kerokid/MODULNAME to wherever you want.

Inline hook detection