Thursday, 10 September 2015

Rootkit Hunter (rkhunter) Installation on CentOS

Rootkit Hunter (rkhunter) is a Unix-based tool that scans for rootkits, backdoors and possible local exploits.

Rootkits are self-hiding toolkits secretly installed by a malicious intruder to allow that user to gain access to the server. Rootkit Hunter offers protection by comparing SHA-1 hashes of important files with known good ones in a online database as well as:

*MD5 hash compare.
*Look for default files used by rootkits.
*Wrong file permissions for binaries.
*Look for suspected strings in LKM and KLD modules.
*Look for hidden files.
*Optional scan within plaintext and binary files.

1. Installation

Download Rootkit Hunter

Begin by downloading the latest stable version of Rkhunter by using the wget command. The /usr/local/src folder is where you should put any programs (source or binary) you've downloaded before installing them.

Make sure to check for the latest available version here, and append the instructions below accordingly.

cd /usr/local/src
wget http://dfn.dl.sourceforge.net/sourceforge/rkhunter/rkhunter-1.4.2.tar.gz
wget http://dfn.dl.sourceforge.net/sourceforge/rkhunter/rkhunter-1.4.2.tar.gz.sha1.txt
sha1sum -c rkhunter-1.4.2.tar.gz.sha1.txt

2. Installation Rootkit Hunter.

Once you have downloaded the latest version of Rootkit Hunter, issue the following commands as root to start the installation routine.

tar -zxvf rkhunter-1.4.2.tar.gz
cd rkhunter-1.4.2
./installer.sh --layout default --install
/usr/local/bin/rkhunter --update
/usr/local/bin/rkhunter --propupd
rm -Rf /usr/local/src/rkhunter*

3. Automate Rootkit Hunter.

Rkhunter can be setup to run checks every day so that we always have up-to-date information about intrusions. This can be accomplished by creating a cronjob.

4. Rootkit Hunter configuration.

The configuration file for rkhunter can be found at:

/etc/rkhunter.conf

5. SSHD Root Logon.

The parameter ALLOW_SSH_ROOT_USER tells rkhunter whether or not the root user is allowed to ssh into the system. This is unset by default in the rkhunter.conf file. Rkhunter will complain about this on every run. If you have disabled root login, you should set this parameter to "no".

ALLOW_SSH_ROOT_USER=no

If you need root login over SSH, you should change this parameter to "yes" so that rkhunter can check this and will mark this setting as valid:

ALLOW_SSH_ROOT_USER=yes

Security practices recommend disabling root login.

6. Update rkhunter.

To check the currently installed version enter the following:

# /usr/local/bin/rkhunter --versioncheck

Run the updater by issuing the following command:

# /usr/local/bin/rkhunter --update

With our database files refreshed, we need to tell rkhunter to check the current values and store them as known-good values:

# /usr/local/bin/rkhunter --propupd

6. Manual Scan.

You can initiate a manual scan by issuing the following command:

/usr/local/bin/rkhunter -c

Which runs rkhunter in interactive mode. In other words, when it gets to the end of a particular scan, you need to press 'enter' to continue. If you want to "auto skip" interactive mode, add the -sk option at the end:

/usr/local/bin/rkhunter -c -sk

To scan the entire file system enter:

rkhunter --check

Your scan results should look as follows:

---------------------------- Scan results ----------------------------
MD5 scan
Scanned files: 0
Incorrect MD5 checksums: 0

File scan
Scanned files: 412
Possible infected files: 0

Application scan
Vulnerable applications: 0

Scanning took 39 seconds
-----------------------------------------------------------------------

For more information and options please run the following command.

# rkhunter --help

No comments:

Post a Comment