• Get In Touch
May 16, 2016

How To Install And Use rkhunter On Ubuntu 14.04

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.
Get a Cloud Server

Introduction

If you are using a Linux system and think that your system is 100% secure then you are wrong. Linux is still vulnerable to malware, one type of malware that you might get on Linux is a rookit.

A rootkit is a collection of malicious computer software, designed to enable access to a computer or area of its software that would not otherwise be allowed. At the same time, rookit masking its existence or the existence of other software.

Rootkit installation usually automated by leveraging a software vulnerability. An attacker can install a rootkit manually when they break-in into a system and gain root or administrator access.

Techtarget definition of rookit is :

a collection of tools (programs) that enable administrator-level access to a computer or computer network. Typically, a cracker installs a rootkit on a computer after first obtaining user-level access, either by exploiting a known vulnerability or cracking a password. Once the rootkit is installed, it allows the attacker to mask intrusion and gain root or privileged access to the computer and, possibly, other machines on the network.
In this tutorial we’ll learn how-to install and configure rkhunter on Ubuntu 14.04 Trusty Tahr so that we can scan our system for potential rootkits.

Install rkhunter

We will install rkhunter from the ubuntu repository instead of using rkhunter archive file from rkhunter website. We will update apt metadata and then install rkhunter, we can use commands below:

    $ sudo apt-get update
    $ sudo apt-get -y --no-install-recommends install rkhunter

We use -no-install-recommends options of apt so rkhunter installed in minimalist way. One of the recommended packages for rkhunter is postfix as a mail server. We assume that we already configured the server to relay mail sending to another mail server.

Updating rkhunter Data Files

After installing rkhunter we need to update the database of rkhunter by running the command below :

    $ sudo rkhunter --update
    [ Rootkit Hunter version 1.4.0 ]

    Checking rkhunter data files...
      Checking file mirrors.dat                                  [ No update ]
      Checking file programs_bad.dat                             [ Updated ]
      Checking file backdoorports.dat                            [ No update ]
      Checking file suspscan.dat                                 [ No update ]
      Checking file i18n/cn                                      [ No update ]
      Checking file i18n/de                                      [ Updated ]
      Checking file i18n/en                                      [ Updated ]
      Checking file i18n/tr                                      [ Updated ]
      Checking file i18n/tr.utf8                                 [ Updated ]
      Checking file i18n/zh                                      [ No update ]
      Checking file i18n/zh.utf8                                 [ No update ]

Rootkit Scanning Using rkhunter

After updating rkhunter data file we will run rkhunter for the first time by running command below :

    $ sudo rkhunter -c

rkhunter will run using default configuration, the output for the command above is quite long, you will need to press enter several times to continue the scanning process.

Configure Email For Warnings

We can configure rkhunter to send email to us only when there is warning on scanning. By sending email only when there is a warning we’ll make sure that we will take attention to the email compared to getting email for every scan.

To configure email on warning, let’s open

    /etc/rkhunter.conf

    MAIL-ON-WARNING=""

Put your email address between double quotes, e.g:

    MAIL-ON-WARNING="youremail@yourdomain.com"

We can add multiple email address separated by comma or you can also put a group address, so multiple people will get the email. Using email groups will make sure more than one person sees the email and at least one of the team members will take action for the warning.

After changing configuration, we can check rkhunter configuration using command below:

    $ sudo rkhunter -C
    Command cannot be found: MAIL_CMD=mail -s "[rkhunter] Warnings found for ${HOST_NAME}"

If you get no output then your configuration is OK, but if you get output similar to above it means that there is error on your configuration file. The error message above said command could not be found, the command that cannot be found here is mail. We will install msmtp and create symlink to msmtp binary as mail.

To install msmtp we can run command below:

    $ sudo apt-get install msmtp

We then create symlink for mail program to msmtp using command below :

    $ sudo ln -sf /usr/bin/msmtp /usr/sbin/mail

You can take a look at this additional tutorial on Hostpresto! entitled How to Send Email from the Command Line with MSMTP and Mutt to learn how-to configure msmtp to send email properly.
If the configuration is correct we should not get any output when running $ sudo rkhunter -C

Summary

In this tutorial we explained how-to install rkhunter to scan for rootkits on our server. We also explained how to scan and configure email for warnings. Using rkhunter we add an additional security measure to protect our server. We hope you find this tutorial useful, thank you.

Want your very own server? Get our 1GB memory, Xeon V4, 25GB SSD VPS for £10.00 / month.
Get a Cloud Server

Share this Article!

Related Posts

Node.js Authentication – A Complete Guide with Passport and JWT

Node.js Authentication – A Complete Guide with Passport and JWT

Truth be told, it’s difficult for a web application that doesn’t have some kind of identification, even if you don’t see it as a security measure in and of itself. The Internet is a kind of lawless land, and even on free services like Google’s, authentication ensures that abuses will be avoided or at least […]

Node.js and MongoDB: How to Connect MongoDB With Node

Node.js and MongoDB: How to Connect MongoDB With Node

MongoDB is a document-oriented NoSQL database, which was born in 2007 in California as a service to be used within a larger project, but which soon became an independent and open-source product. It stores documents in JSON, a format based on JavaScript and simpler than XML, but still with good expressiveness. It is the dominant […]

Using MySQL with Node.js: A Complete Tutorial

Using MySQL with Node.js: A Complete Tutorial

Although data persistence is almost always a fundamental element of applications, Node.js has no native integration with databases. Everything is delegated to third-party libraries to be included manually, in addition to the standard APIs. Although MongoDB and other non-relational databases are the most common choice with Node because if you need to scale an application, […]

Node.Js Vs Django: Which Is the Best for Your Project

Node.Js Vs Django: Which Is the Best for Your Project

Django and NodeJs are two powerful technologies for web development, both have great functionality, versatile applications, and a great user interface. Both are open source and can be used for free. But which one fits your project best? NodeJs is based on JavaScript, while Django is written in Python. These are two equally popular technologies […]

Nodejs Vs PHP:  Which Works Best?

Nodejs Vs PHP: Which Works Best?

Before getting into the “battle” between Node.js and PHP we need to understand why the issue is still ongoing. It all started with the increased demand for smartphone applications, their success forcing developers to adapt to new back-end technologies that could handle a multitude of simultaneous requests. JavaScript has always been identified as a client-side […]