Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Web Server
  • Search

[HowTo] 3 Best Tools to protect your VestaCP server from Malware and Rootkit Attacks

Questions regarding the Web Server
Apache + Nginx, Nginx + PHP5-FPM
Post Reply
  • Print view
Advanced search
1 post • Page 1 of 1
xorro
Posts: 87
Joined: Sun Nov 13, 2016 3:11 pm
Contact:
Contact xorro
Website Skype

Os: CentOS 6x
Web: apache + nginx
[HowTo] 3 Best Tools to protect your VestaCP server from Malware and Rootkit Attacks
  • Quote

Post by xorro » Fri Sep 07, 2018 8:02 pm

Servers connected to the internet are seeing a constant level of attacks and scans all day. While a firewall and regular system updates are a good first defense to keep the system safe, you should also check regularly that no attacker got in. The tools described in this tutorial are made for these sanity checks, they scan for malware, viruses, and rootkits. They should be run regularly, e.g. every night and send reports to you by email. You can also use Chkrootkit, Rkhunter, and ISPProtect to scan a system when you see suspicious activity like high load, suspicious processes or when the server suddenly starts to send malware.

All these scanners have to be run as root user. Login as root before you continue or run "sudo su" on Ubuntu to become root user.

chkrootkit - Linux Rootkit Scanner

Chkrootkit is a classic rootkit scanner. It checks your server for suspicious rootkit processes and checks for a list of known rootkit files.

Either install the package that comes with your distribution (on Debian and Ubuntu you would run

Code: Select all

apt-get install chkrootkit
Image

or download the sources from www.chkrootkit.org and install manually:

Code: Select all

wget --passive-ftp ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz
tar xvfz chkrootkit.tar.gz
cd chkrootkit-*/
make sense
Image

Afterwards, you can move the chkrootkit directory somewhere else, e.g. to /usr/local/chkrootkit:

Code: Select all

cd ..
mv chkrootkit-<version>/ /usr/local/chkrootkit
and create a symlink for easy access:

Code: Select all

ln -s /usr/local/chkrootkit/chkrootkit /usr/local/bin/chkrootkit
To check your server with chkrootkit, run the command:

Code: Select all

chkrootkit
A common false positive report is:
ReportShow
Checking `bindshell'... INFECTED (PORTS: 465)
Don't worry when you get this message on an email server, this is the SMTPS (Secure SMTP) port of your mail system and a well known false positive.

You can even run chkrootkit by a cron job and get the results emailed to you. First, find out the path where chkrootkit is installed on your server with:

Code: Select all

which chkrootkit
Example:
ExampleShow
root@server1:/tmp/chkrootkit-0.50# which chkrootkit
/usr/sbin/chkrootkit
Chkrootkit is installed in the path /usr/sbin/chkrootkit, we need this path in the cron line below:

Run:

Code: Select all

crontab -e
To create a cron job like this:

Code: Select all

0 3 * * * /usr/sbin/chkrootkit 2>&1 | mail -s "chkrootkit output of my server" [email protected])
That would run chkrootkit every night a 3:00h. Replace the path to chkrootkit with the one that you got from which command above and exchange the email address with your real address.

Lynis - Universal Security Auditing Tool and Rootkit Scanner

Lynis (formerly rkhunter) is a security auditing tool for Linux and BSD based systems. It performs a detailed auditing of many security aspects and configurations of your system. Download the latest Lynis sources from https://cisofy.com/download/lynis/:

Code: Select all

cd /tmp
wget https://cisofy.com/files/lynis-2.6.4.tar.gz
tar xvfz lynis-2.6.4.tar.gz
mv lynis /usr/local/
ln -s /usr/local/lynis/lynis /usr/local/bin/lynis
Image

This will install Lynis to the directory /usr/local/lynis and creates a symlink for easy access. Now run

Code: Select all

lynis update info
to check if you use the latest version.

Now you can scan your system for rootkits by running:

Code: Select all

lynis audit system
Lynis will perform a few checks and then stops to give you some time to read the results. Press [ENTER] to continue with the scan.

Image

At the end, it will show you a summary of the scan.

Image

To run Lynis non-interactively, start it with the --quick option:

Code: Select all

lynis --quick
To run Lynis automatically at night, create a cron job like this:

Code: Select all

0 3 * * * /usr/local/bin/lynis --quick 2>&1 | mail -s "lynis output of my server" [email protected])
This will run Lynis every night a 3:00h. Replace the email address with your real address.

ISPProtect - Website Malware Scanner

ISPProtect is a malware scanner for web servers, it scans for malware in website files and CMS systems like Wordpress, Joomla, Drupal etc. If you run a web hosting server, then the hosted websites are the most attacked part of your server and it is recommended to do sanity checks on them regularly. ISPProtect contains 5 scanning engines:

Signature-based malware scanner.
Heuristic malware scanner.
A scanner to show the installation directories of outdated CMS systems.
A scanner that shows you all outdated WordPress plugins of the whole server.
A database content scanner which checks MySQL databases for potentially malicious content.

ISPProtect is not free software, but there is a free trial that can be used without registration to test it or clean an infected system.

ISPProtect requires PHP and ClamAV to be installed on the server, this should be the case on most hosting systems. ClamAV is used by ISPProtect in the first scan level with ISPProtect's own Malware signature set. In case you don't have a command line PHP installed yet, execute:

Code: Select all

apt-get install php7.0-cli clamav
on Debian 9 or:

Code: Select all

yum install php
on Fedora and CentOS.

Run the following commands to install ISPProtect.

Code: Select all

mkdir -p /usr/local/ispprotect
chown -R root:root /usr/local/ispprotect
chmod -R 750 /usr/local/ispprotect
cd /usr/local/ispprotect
wget http://www.ispprotect.com/download/ispp_scan.tar.gz
tar xzf ispp_scan.tar.gz
rm -f ispp_scan.tar.gz
ln -s /usr/local/ispprotect/ispp_scan /usr/local/bin/ispp_scan
To start ISPProtect, run:

Code: Select all

ispp_scan
The scanner automatically checks for updates, then asks for the key (enter the word "trial" here) and then asks for the path of the websites, normally that's /var/www.

Image
ConfigShow
Please enter scan key: <-- trial
Please enter path to scan: <-- /var/www
The scanner will now start the scan. The scanning progress is shown. The names of the infected files are shown on the screen at the end of the scan and the results are stored in file sin the ISPProtect install directory for later use:

After the scan is completed, you will find the results also in the following files:
FilesShow
Malware => /usr/local/ispprotect/found_malware_20180605115005.txt
Wordpress => /usr/local/ispprotect/software_wordpress_20180605115005.txt
Joomla => /usr/local/ispprotect/software_joomla_20180605115005.txt
Drupal => /usr/local/ispprotect/software_drupal_20180605115005.txt
Mediawiki => /usr/local/ispprotect/software_mediawiki_20180605115005.txt
Contao => /usr/local/ispprotect/software_contao_20180605115005.txt
Magentocommerce => /usr/local/ispprotect/software_magentocommerce_20180605115005.txt
Woltlab Burning Board => /usr/local/ispprotect/software_woltlab_burning_board_20180605115005.txt
Cms Made Simple => /usr/local/ispprotect/software_cms_made_simple_20180605115005.txt
Phpmyadmin => /usr/local/ispprotect/software_phpmyadmin_20180605115005.txt
Typo3 => /usr/local/ispprotect/software_typo3_20180605115005.txt
Roundcube => /usr/local/ispprotect/software_roundcube_20180605115005.txt
Shopware => /usr/local/ispprotect/software_shopware_20180605115005.txt
Mysqldumper => /usr/local/ispprotect/software_mysqldumper_20180605115005.txt
Starting scan level 1 ...
Scanning 3471 files now ...
To run ISPProtect automatically as a nightly cronjob, create a cron file with nano:

Code: Select all

nano /etc/cron.d/ispprotect
and insert the following line:

Code: Select all

0 3  * * *   root	/usr/local/ispprotect/ispp_scan --update && /usr/local/ispprotect/ispp_scan --path=/var/www --email-results=root@localhost --non-interactive --scan-key=AAA-BBB-CCC-DDD
Replace "root@localhost" with your email address, the scan report is sent to this address. Then exchange "AAA-BBB-CCC-DDD" with your license key. You can get a license key here.
Top


Post Reply
  • Print view
1 post • Page 1 of 1

Return to “Web Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

cron

Login  •  Register

I forgot my password