Imported Upstream version 2.7
[ossec-hids.git] / doc / rootcheck.txt
1 Rootkit detection techniques used by the OSSEC HIDS
2 by Daniel B. Cid, daniel.cid@gmail.com
3
4
5 Starting on version 0.4, the OSSEC HIDS will perform
6 rootkit detection on every system where the agent is
7 installed. The rootcheck (rootkit detection engine) will
8 be executed every X minutes (user specified --by default
9 every 2 hours) to detect any possible rootkit installed.
10 Used witht the log analysis and the integrity checking
11 engine, it will become a very powerful monitoring solution
12 (the OSSEC HIDS performs log analysis and integrity
13 checking since version 0.1).
14
15 Other feature included on version 0.4 is that the analysis
16 server will automatically forward the rootkit detection
17 signatures to the agents, reducing the administration
18 overhead for the system admin. The agents and server will
19 keep contact every 10 minutes and if the server is
20 updated with a new signature file, it will forward them
21 to all configured agents. Take a look at the management
22 documentation for more information.
23
24 The rootcheck will perform the following steps on the
25 system trying to find rootkits:
26
27
28 1- Read the rootkit_files.txt which contains a big database
29    of rootkits and files used by them. It will try to stats,
30    fopen and opendir each specified file. We use all these
31    system calls, because some kernel-level rootkits, hide
32    files from some system calls. The more system calls we
33    try, the better the detection. This method is more like
34    an anti-virus rule that needs to be updated constantly.
35    The chances of false-positives are small, but false
36    negatives can be produced by modifying the rootkits.
37
38 2- Read the rootkit_trojans.txt which contains a database
39    of signatures of files trojaned by rootkits. This
40    technique of modifying binaries with trojaned versions
41    was commonly used by most of the popular rootkits 
42    available. This detection method will not find any
43    kernel level rootkit or any unknown rootkit.   
44    
45 3- Scan the /dev directory looking for anomalies. The /dev
46    should only have device files and the Makedev script.
47    A lot of rootkits use the /dev to hide files. This 
48    technique can detect even non-public rootkits.
49
50 4- Scan the whole filesystem looking for unusual files and
51    permission problems. Files owned by root, with written
52    permission to others are very dangerous and the rootkit
53    detection will look for them. Suid files, hidden directories
54    and files will also be inspected.
55
56 5- Look for the presence of hidden processes. We use getsid()
57    and kill() to check if any pid is being used or not. If
58    the pid is being used, but "ps" can't see it, it is the
59    indication of kernel-level rootkit or a trojaned version
60    of "ps". We also verify the output of kill and getsid that
61    should be the same.
62
63 6- Look for the presence of hidden ports. We use bind() to
64    check every tcp and udp port on the system. If we can't
65    bind to the port (it's being used), but netstat does not
66    show it, we probably have a rootkit installed.
67
68 7- Scan all interfaces on the system and look for the ones
69    with "promisc" mode enabled. If the interface is in promiscuous
70    mode, the output of "ifconfig" should show that. If not,
71    we probably have a rootkit installed.
72
73
74 EOF