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

yum install rkhunter

Check the version

# rkhunter --versioncheck
Rootkit Hunter version 1.4.2

Checking rkhunter version...
  This version  : 1.4.2
  Latest version: 1.4.2

Manual Scan

# rkhunter -c

Or,

# rkhunter -c -l /var/log/rkhunter.log

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.
2.1 Create Cron File

Create the run-file in the following location (RHEL based distributions only):

#nano -w /etc/cron.daily/rkhunter.sh

Install into shell script

#!/bin/sh
(
/usr/bin/rkhunter --versioncheck
/usr/bin/rkhunter --update
/usr/bin/rkhunter --cronjob --report-warnings-only
) | /bin/mail -s 'rkhunter Daily Scan Report (ServerNameHere)' your@email.here

Set Execute Permissions

Set execute permission on the file you have just created:

# chmod 755 /etc/cron.daily/rkhunter.sh

The cron utility will run once daily, and if a threat is detected, the rkhunter command itself will email our user to alert them. If no problems were found, no email will be received.

Rootkit Hunter configuration

The configuration file for rkhunter can be found at:

# /etc/rkhunter.conf

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.

Update rkhunter

To check the currently installed version enter the following:

# rkhunter --versioncheck

Run the updater by issuing the following command:

# rkhunter --update

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

# rkhunter --propupd


sudo nano /etc/network/interfaces


# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static 
address ipAddress 
netmask 255.255.255.0 
gateway gatewayIP 
dns-nameservers 69.64.66.11 69.64.66.10

Once you have entered the values correctly, press Ctrl+Enter to save it with the current filename, then press Ctrl+X to exit the editor.

Provided you entered your values correctly, verify the new settings by retyping the cat command:


cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static 
address 123.45.67.89
netmask 255.255.255.0 
gateway 123.45.67.1 
dns-nameservers 8.8.8.8 8.8.4.4

Apply setting to Interface

After you have determined the values entered are correct, restart networking with the following command:


sudo service networking restart
stop: Unknown instance: 
networking stop/waiting
administrator@ubuntu:~#

Verify it works
To verify the resolvers are working, simply ping a known domain.


ping google.com
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_req=1 ttl=45 time=42.1 ms
64 bytes from 8.8.8.8: icmp_req=2 ttl=45 time=42.2 ms
64 bytes from 8.8.8.8: icmp_req=3 ttl=45 time=42.0 ms

Checking the log shows:


# [ERROR] /usr/libexec/mysqld: Sort aborted

Check the processlist on a plesk server:

# mysqladmin -u admin -p`cat /etc/psa/.psa.shadow` processlist

+---------+----------------+----------------------+----------------+---------+------+-------+------------------+
| Id      | User           | Host                 | db             | Command | Time | State | Info             |
+---------+----------------+----------------------+----------------+---------+------+-------+------------------+
| 1926335 | user           | 108.xx.xx.xxx:17599  | databasename   | Update  | 0    | Locked| select * from..' |
|         |                |                      |                |         | 0    |       |                  |
+---------+----------------+----------------------+----------------+---------+------+-------+------------------+

Kill the process:

# mysqladmin -u admin -p`cat /etc/psa/.psa.shadow` kill [thread_id]

Create an index on the table

Error in plesk postfix email logs:

Notice: Error: EHLO not accepted from server! in /var/www/vhosts/domain.com/httpdocs/system/library/mail.php on line 237

Check postfix main and comment out non_smtpd_milters:


smtpd_milters = , inet:127.0.0.1:12768
#non_smtpd_milters = , inet:127.0.0.1:12768

Restart postfix:

# service postfix restart
Shutting down postfix:                                     [  OK  ]
Starting postfix:                                          [  OK  ]