chkrootkit

On this page 7

chkrootkit is an open-source rootkit scanner for Unix-like systems that inspects a host for the signatures, hidden files and kernel tricks left behind by known rootkits. In Linux security it serves as a lightweight detection tool: it does not prevent compromise, but it helps an administrator decide whether a machine shows the typical traces of an attacker who has gained root access.

The tool consists of a POSIX shell script plus a few small C programs, which makes it portable and easy to run on servers without extra dependencies. It is packaged by Debian, Ubuntu and most other distributions and is often used next to rkhunter as a second opinion during incident triage.

How chkrootkit detects rootkit traces

chkrootkit combines signature matching with a set of anomaly checks. The main script examines common system binaries such as ls, ps, netstat, login and sshd for strings and patterns known to appear in trojanized versions, and it searches the file system for files and directories that specific rootkits are known to create.

The compiled helpers look for inconsistencies that rootkits try to hide. Comparing different views of the same system state is the core idea: if /proc lists a process that ps does not show, or a directory link count does not match its visible entries, something may be concealing data.

The following table summarizes the bundled helper programs and what each one checks.

HelperWhat it checksIndicator of compromise
chkprocProcess list in /proc against ps outputHidden processes from kernel modules
chkdirsDirectory link counts against entriesHidden directories
ifpromiscNetwork interface flagsInterfaces in promiscuous mode for sniffing
chklastlogConsistency of lastlog recordsDeleted login records
chkwtmpGaps in the wtmp login fileErased session entries
chkutmpCurrent sessions against processesHidden logged-in users
Helper programs bundled with chkrootkit

Running chkrootkit and reading its output

chkrootkit must run as root, because many of its checks read protected files and kernel interfaces. A plain run executes every test in sequence and prints one result line per test, which can be several hundred lines on a typical server.

Several command-line options change the scope or the trust model of a scan, as the next table shows.

OptionEffectWhen to use it
-qQuiet mode that prints only findingsScheduled scans and email reports
-xExpert mode with raw string outputManual analysis of suspicious binaries
-r directoryUses another directory as the rootScanning a mounted disk from rescue media
-p pathTakes external commands from a trusted pathAvoiding possibly trojanized tools
-lLists the available testsSelecting individual checks
-nSkips NFS-mounted directoriesHosts with large network shares
Useful chkrootkit options

Each result line uses a small vocabulary. not infected and nothing found mean that the test saw no known pattern, not found means that the inspected command does not exist on the system, and INFECTED means that a signature matched. Lines such as Searching for suspicious files list paths for manual review rather than confirmed threats.

chkrootkit among Linux security tools

chkrootkit is a post-compromise detector, and it is most useful when its role is clear relative to neighboring tools. It answers a narrow question about known rootkits, whereas integrity checkers, malware scanners and audit tools address broader questions.

ToolDetection methodMain strength
chkrootkitSignatures and anomaly checksFast, dependency-free rootkit triage
rkhunterSignatures plus file property checksBaseline comparison of system binaries
AIDECryptographic file integrity databaseDetects any unauthorized file change
ClamAVAntivirus signature databaseMalware in files and mail attachments
LynisConfiguration auditHardening recommendations, not detection
chkrootkit compared with related tools

A sound design uses these tools in layers: AIDE or IMA for integrity, auditd for event logging, and chkrootkit and rkhunter as periodic rootkit-specific checks. No single scanner covers all attacker techniques.

Scheduling and operational practice

On Debian-based systems the package can run a daily scan through cron, configured in /etc/chkrootkit.conf or a related file depending on the release. A useful setting compares each run with the previous output and reports only differences, which keeps known false positives from flooding the inbox.

  • Record a clean baseline right after installation, before the host is exposed.
  • Send quiet-mode output to a central log or mailbox that an attacker on the host cannot edit.
  • Investigate every new INFECTED line promptly, even if earlier alerts were false.
  • Keep the package updated, because signatures only cover known rootkits.

For a real investigation, the most reliable method is an offline scan: boot the machine from trusted rescue media, mount its disk and run chkrootkit with -r and -p pointing to clean binaries. This avoids relying on a kernel and tools that may already be under attacker control.

Limitations and false positives

chkrootkit has clear structural limits. It detects only rootkits whose traces are in its signature set, so a new or custom rootkit, an eBPF-based implant or a well-designed kernel module can pass unnoticed. A clean report therefore means no known indicators, not a proven clean system.

False positives are common and well documented. The table below lists typical cases.

Reported findingCommon benign causeVerification step
Bindshell on a portLegitimate service on a listed portCheck the owning process with ss -tlnp
Suspicious hidden filesPackage metadata or language cachesConfirm ownership with dpkg -S
Promiscuous interfacePacket capture or bridge in useCheck for tcpdump or a Linux bridge
Hidden process warningShort-lived processes during the scanRepeat the test and compare
Typical false positives and how to verify them

The key operational warning is that a compromised host can lie to any tool running on it. Treat chkrootkit as an early warning signal and confirm any serious finding with offline analysis and independent integrity data.

The simple explanation

A rootkit is hidden software that lets an intruder control a computer while concealing that it is there. chkrootkit is a checklist-driven inspector: it looks for the fingerprints that well-known rootkits usually leave behind and for places where the system seems to be hiding something.

It is like a security guard comparing two guest lists. If one list shows a person the other list leaves out, the guard raises a flag. The guard only recognizes familiar tricks, so a quiet result is reassuring but not a guarantee.

How it is used in practice

A hosting administrator notices that a Linux web server sends unusual outbound traffic at night, while ps and netstat show nothing out of place. Instead of trusting the running system, the administrator schedules a maintenance window, boots the server from a trusted rescue image and mounts its root file system under /mnt/target.

Running chkrootkit with -r /mnt/target and clean binaries from the rescue image reports a trojanized ps binary and a hidden directory under /usr/lib. The administrator preserves a disk image for forensic analysis, rotates all credentials and rebuilds the server from scratch, because a host with a confirmed rootkit cannot be trusted even after the visible files are removed. The rebuilt server is back in service within one working day.