Detect and Eradicate Hidden Linux Mining Malware – Complete Step‑by‑Step Guide
This guide explains how to identify hidden cryptocurrency mining malware on Linux servers, locate concealed processes with sysdig and unhide, terminate the malicious service, block suspicious IPs, and secure the system using tools like iptables, Safedog, and ClamAV, with full command examples.
Infection Symptoms
The server shows 100% CPU usage on half of its cores, high memory consumption, fan speed, and occasional freezes. The mining process is hidden and does not appear in htop or top. crontab -l shows no scheduled tasks.
High CPU usage without visible processes.
Abnormal IP addresses in netstat -natp output.
Severe overheating and fan noise.
Random server freezes.
Remediation Steps
1. Isolate the host and reset root credentials
Immediately disconnect the server from the network and change the root password to stop further compromise.
2. Locate hidden mining processes
Install sysdig and unhide to reveal concealed processes.
sudo apt install sysdig sudo apt install unhide sudo sysdig -c topprocs_cpu # shows CPU‑intensive processes, including hidden ones sudo unhide proc # scans /proc for hidden PIDsIdentify the PID of the mining process.
3. Stop the malicious service
Use the PID to find the responsible systemd unit and stop it.
systemctl status 3084 # replace 3084 with the actual PID systemctl stop xxxxX.service systemctl disable xxxxX.service4. Kill the mining process
kill -9 PIDCPU usage should return to normal and no hidden processes should reappear.
Prevent Future Infections
1. Block abnormal IPs
netstat -natpSearch the displayed IPs online to verify legitimacy, then block malicious ones:
sudo iptables -I INPUT -s <em>IP</em> -j DROP iptables -L INPUT -v -n # verify the rulePersist rules across reboots with iptables-persistent:
sudo apt-get install iptables-persistent sudo netfilter-persistent save systemctl enable iptables systemctl start iptables2. Remove unknown SSH keys
cat ~/.ssh/authorized_keysDelete any unfamiliar public keys.
Linux Antivirus – ClamAV
Installation
Debian/Ubuntu:
sudo apt-get update sudo apt-get install clamav clamav-daemonCentOS/RHEL:
sudo yum install epel-release sudo yum install clamav clamav-updateUpdate virus database
sudo freshclamScanning examples
# Scan a single file clamscan /path/to/your/file # Recursively scan a directory clamscan -r /path/to/directory # Remove infected files automatically clamscan --remove -r /path/to/directory # Generate a scan report clamscan -r /path/to/directory > scanreport.txt # Use the daemon client for faster scans sudo systemctl start clamav-daemon clamdscan /path/to/your/file clamdscan -r /path/to/your/directory clamdscan --multiscan --fdpass /path/to/scanAdvanced Process Inspection – Sysdig
curl -s https://s3.amazonaws.com/download.draios.com/stable/install-sysdig | sudo bashTest the installation: sysdig -pc -c topconns If connection statistics are displayed, Sysdig is installed correctly.
Resolving “No Available Package” Errors
When yum cannot find a package, enable the EPEL repository:
yum install -y epel-releaseSigned-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
