Search for rootkit malware with chkrootkit
Rootkit Sleuth
Linux can be infected by rootkit malware that is hidden and hard to detect. The chkrootkit program can help find rootkit infections.
The chkrootkit package examines key system files to determine whether they have been tampered with or infected by malware known as rootkits. An infected system can leak valuable data such as user credentials, can allow hackers to steal banking information, can provide remote control capability, and can disrupt security software. The fact that rootkits can remain on a system for long periods of time undetected makes them particularly dangerous.
Changing Attitudes on Linux Malware
Contrary to popular belief, Linux does suffer from malware infections and attacks. Rootkits are one type of malware designed to infect, gain elevated access, and remain hidden from detection for long periods of time. Rootkits are especially malicious, because they not only remain hidden but also can disable or disrupt security software making them hard to remove. Once infected, often the only recourse is to re-image (wipe and reinstall) the system.Symantec has identified five types of rootkits:
- Hardware/firmware – installed in the computer’s BIOS, firmware, or other hardware components
- Bootloader – the system’s bootloader is active before the operating system loads
- Memory – RAM-based rootkits only last while the computer is powered on and generally do not persist after a reboot unless the file is set to reload on boot
- Application – application rootkits alter standard programs that appear to work normally while infected
- Kernel mode – core operating system alterations access and control the computer’s lowest operational levels
Rootkits are generally downloaded and installed by the root user, which means that the malware author now has full control of the infected computer. Malicious file attachments, social engineering, and malicious web payloads account for most of the known rootkit infections.Great care must be taken by manufacturers, suppliers, and system administrators to guard against infections of this kind. Regular updates and best practice security measures can decrease the likelihood of malware infections. But those who download, execute, and install software as the root user must ensure that this material is first tested in a non-production environment.
Installing chkrootkit
On Debian-based systems, use:
$ sudo apt install chkrootkit
On Red Hat Enterprise Linux, the procedure is more complex, because there is no chkrootkit RPM in the standard repositories. You’ll have to install from source and there are some prerequisites:
$ sudo yum –y update
I installed the minimal CentOS 7.x option, so I don’t have any development tools on my system:
$ sudo yum –y install wget gcc-c++ glibc-static
Download the latest tarball for chkrootkit:
$ sudo wget -c ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz
Unzip the tarball:
$ tar xvf chkrootkit.tar.gz $ mkdir /usr/local/chkrootkit$ sudo cp chkrootkit-0.53/* /usr/local/chkrootkit
At editorial deadline, the current version is chkrootkit v0.53, but your version and directory name might vary:
$ cd /usr/local/chkrootkit
Compile the code:
$ sudo make sense
Checking Out chkrootkit
Now you have a small collection of chkrootkit related tools.
- chkrootkit – the main script that checks system binaries for rootkit infection and modification
- ifpromisc – checks network interfaces for promiscuous mode
- chklastlog – checks lastlog for deletions
- chkwtmp – checks wtmp for deletions
- chkproc and chkdirs – check for evidence of loadable kernel module (LKM) Trojans
- strings – script for strings replacements
- chkutmp – checks for utmp deletions
Although you can run any of the scripts, the chkrootkit script runs all checks for you.To list all available options, use the code in Listing 1.
Listing 1
Listing All Available Options
$ sudo /usr/local/chkrootkit/chkrootkit –h Usage: /usr/local/chkrootkit/chkrootkit [options] [test ...] Options: -h show this help and exit -V show version information and exit -l show available tests and exit -d debug -q quiet mode -x expert mode -r dir use dir as the root directory -p dir1:dir2:dirN path for the external commands used by chkrootkit -n skip NFS mounted dirs
Searching for Rootkit InfectionsUnless you have a specific need, you can simply run chkrootkit with no options:
$ sudo /usr/local/chkrootkit/chkrootkit
Because the output is very long, you can check to see if there are any obvious infections, by filtering for the term INFECTED:
$ sudo /usr/local/chkrootkit/chkrootkit | grep INFECTED
If there is a positive (false or not), you’ll see a message similar to the following:
Searching for Linux.Xor.DDoS ... INFECTED: Possible Malicious Linux.Xor.DDoS installed
This infection notice is a false positive on my new CentOS 7 system. You should investigate each positive notification to be sure that they are either false or real. Further investigation will determine the extent of the damage and possibly how long your system has been infected and compromised. You should update and run chkrootkit on a regular basis to halt any infections before they do extensive damage to your systems or to your users.
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.