chkrootkit là gì? Local Rootkit Checker Chi Tiết

chkrootkit là open-source rootkit scanner cho Linux systems. Nó kiểm tra system cho signs of rootkits bằng cách look for suspicious files, processes, và network connections mà typical rootkits use to hide themselves.

chkrootkit được phát triển bởi Nelson Murilo và Klaus Steding-Jessen, là một trong những tools lâu đời nhất và được tin cậy nhất để detect rootkits trên Unix/Linux systems.

chkrootkit vs rkhunter

Aspectchkrootkitrkhunter
ApproachScan for known rootkit patternsCheck system state và integrity
DatabaseBuilt-in rootkit signaturesMD5 hashes của system files
SpeedFast scanLonger scan vì multiple checks
UpdatesLess frequent updatesRegular updates
False PositivesFewerMore (needs whitelisting)
PlatformLinux, UnixLinux, BSD, macOS

Chúng bổ trợ nhau – use both để maximize detection coverage. Many admins run both tools as part of comprehensive security scanning.

Cài Đặt chkrootkit

Trên Ubuntu/Debian

# Cài đặt từ repo
sudo apt update
sudo apt install chkrootkit

# Kiểm tra version
chkrootkit --version

Trên CentOS/RHEL

# Cài đặt từ EPEL
sudo yum install epel-release
sudo yum install chkrootkit

Build from Source

# Download latest version
wget ftp://chkrootkit.org/chkrootkit.tar.gz
tar xzf chkrootkit.tar.gz
cd chkrootkit-0.58
make sense

# Run directly
sudo ./chkrootkit

Sử Dụng chkrootkit

Basic Scan

# Chạy scan đầy đủ
sudo chkrootkit

# Scan với output chi tiết hơn
sudo chkrootkit -v

# Silent mode (chỉ output warnings)
sudo chkrootkit -q

# Scan specific tests only
sudo chkrootkit -x -e "amd basename cut echo egrep false fgrep head id ls netstat ps sed strings su test true uname who"

# Output to file
sudo chkrootkit > /var/log/chkrootkit.log 2>&1

Scan Options

# Extended mode (more thorough)
sudo chkrootkit -x

# Exclude specific tests
sudo chkrootkit -e "promiscq"

# Test named binaries only
sudo chkrootkit -f /bin/ls /bin/ps

# Log to syslog (ngày thường dùng more)
sudo chkrootkit | logger -t chkrootkit

chkrootkit Tests

TestDescription
checktmCheck for modified system time
checklsCheck for trojaned ls binary
checkpsCheck for trojaned ps binary
checknetstatCheck for trojaned netstat binary
checkwtmpCheck for deletions in wtmp
checkutmpCheck for deletions in utmp
checklastlogCheck for deletions in lastlog
checkpromiscqCheck for promiscious mode on interfaces
checklkmCheck for suspicious LKM (kernel modules)
chkwtmpCheck wtmp for invader
chkutmpCheck utmp for invader
aliensScan for suspicious files in /dev

Understanding chkrootkit Output

Sample Output

ROOTKIT CHECK
Output from running 'cd /usr/src/rootkit/chkrootkit-0.58 && ./chkrootkit':
Checking `amd`... not found
Checking `basename`... not infected
Checking `biff`... not found
Checking `chfn`... not infected
Checking `cron`... not infected
Checking `date`... not infected
Checking `du`... not infected
Checking `echo`... not infected
Checking `egrep`... not infected
Checking `fifo`... not infected
Checking `find`... not infected
Checking `gpm`... not found
Checking `grep`... not infected
Checking `hd`... not found
Checking `su`... not infected
Checking `syslogd`... not infected

Checking `promiscq`... not infected

Checking `lkm`... not infected

Checking `rexedcs`... not found
Checking `wted`... not infected

Checking `chkwtmp`... not infected
Checking `chkutmp`... not infected

INFECTED: Nothing found

Result Indicators

OutputMeaning
not foundBinary not present on system
not infectedBinary present, no infection detected
INFECTEDRootkit signature detected – ACTION REQUIRED
not testedTest not run (disabled hoặc missing binary)

Scheduling chkrootkit Scans

Cron Job Setup

# Edit root crontab
sudo crontab -e

# Thêm dòng sau (chạy daily lúc 2 AM)
0 2 * * * /usr/sbin/chkrootkit 2>&1 | logger -t chkrootkit

# Hoặc với email notification
0 2 * * * /usr/sbin/chkrootkit 2>&1 | mail -s "chkrootkit daily scan" admin@example.com

Enhanced Security Script

#!/bin/bash
# /usr/local/bin/security-scan.sh

LOGFILE="/var/log/security-scan.log"
ADMIN_EMAIL="admin@example.com"

echo "=== Security Scan: $(date) ===" >> $LOGFILE

echo "Running chkrootkit..." >> $LOGFILE
/usr/sbin/chkrootkit -q 2>&1 | tee -a $LOGFILE

echo "Running rkhunter..." >> $LOGFILE
/usr/bin/rkhunter --check --skip-keypress --cronjob 2>&1 | tee -a $LOGFILE

# Check kết quả
if grep -q "INFECTED" $LOGFILE; then
    echo "ALERT: Potential rootkit detected!" | mail -s "Security Alert" $ADMIN_EMAIL
fi

echo "=== Scan Complete ===" >> $LOGFILE

Network Promiscuous Mode Detection

chkrootkit checkpromiscq kiểm tra xem network interfaces có đang ở promiscuous mode không – đây là dấu hiệu của sniffing rootkits hoặc unauthorized network monitoring.

# Check manually
chkrootkit -e checkpromiscq

# Hoặc với ip command
ip link show | grep PROMISC

# Hoặc với ifconfig
ifconfig | grep PROMISC

False Positive: Legitimate Promiscuous Mode

  • Network monitoring tools (tcpdump, wireshark)
  • Bridge interfaces
  • Some VPN configurations
  • Container networking (docker bridges)

If legitimate, add interface to ALLOWED_NETWORK_INTERFACE in config hoặc exclude checkpromiscq from scan.

Checking System Logs

wtmp và utmp

chkrootkit checkwtmp và checkutmp kiểm tra cho unauthorized deletions trong system logs (login records). Attackers thường clear logs để hide their tracks.

# Check last logins
last | head -20

# Check failed login attempts
lastb | head -20

# Check for suspicious logins
last | grep -E "(root|admin)" | grep -v " pts/"

# Check current logged in users
who

Detect Log Tampering

# Check for gaps in logs
journalctl --list-boots | head -20

# Check SSH login failures
grep "Failed password" /var/log/auth.log | tail -20

# Check for unusual timing
diff <(last | awk '{print $1,$2,$3,$4,$5,$6,$7}') <(lastlog | awk '{print $1,$2,$3}')

chkrootkit Limitations

LimitationDescription
Local-onlyCan't detect rootkits that haven't been installed yet
Signature-basedNew rootkits may evade detection
False positivesLegitimate tools may trigger warnings
Kernel-level rootkitsSome advanced rootkits can hide from chkrootkit

Best Practices

  • Run as cron job - Daily scans ensure early detection
  • Combine with rkhunter - Use both tools for coverage
  • Keep updated - Use latest version from source if possible
  • Investigate warnings - Any "INFECTED" result needs follow-up
  • Monitor scan logs - Compare results over time
  • Boot from rescue media - For thorough scan, boot from external media

When Rootkit Detected

Immediate Actions

  • Isolate system - Disconnect from network if possible
  • Don't reboot - Some rootkits activate at boot
  • Document findings - Screenshot/log all chkrootkit output
  • Identify scope - Check other systems on same network
  • Preserve evidence - Don't delete anything yet

Recovery Options

  • Reinstall - Clean install (recommended for severe infections)
  • Restore from backup - Only if backup predates infection
  • Manual cleanup - Only for experienced security professionals

Prevention

  • Keep system updated
  • Use strong passwords
  • Disable unnecessary services
  • Implement fail2ban
  • Regular security audits
  • Use intrusion detection systems

Kết Luận

chkrootkit là lightweight, fast rootkit scanner rất phù hợp để chạy regularly trên Linux servers. Kết hợp với rkhunter và ClamAV, nó cung cấp comprehensive protection against rootkits và system compromises.

Remember: chkrootkit only detects, doesn't prevent. Strong security posture involves prevention (firewall, IDS, regular updates), detection (chkrootkit, rkhunter, monitoring), và response (incident response plan).

Các Câu Hỏi Thường Gặp (FAQ)

1. chkrootkit có an toàn không?

2. Tôi nên chạy khi nào?

3. chkrootkit false positive như thế nào?

4. Boot media scan là gì?

5. So sánh với rkhunter?

Chào các bạn mình là Quốc Hùng , mình sinh ra thuộc cung song tử ,song tử luôn khẳng định chính mình ,luôn luôn phấn đấu vượt lên phía trước ,mình sinh ra và lớn lên tại vùng đất võ cổ truyền ,đam mê của mình là coder ,ngày đi học tối về viết blog ...