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 sysdigsudo apt install unhidesudo sysdig -c topprocs_cpu # shows CPU‑intensive processes, including hidden onessudo 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 PIDsystemctl stop xxxxX.servicesystemctl 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 DROPiptables -L INPUT -v -n # verify the rulePersist rules across reboots with iptables-persistent:
sudo apt-get install iptables-persistentsudo netfilter-persistent savesystemctl enable iptablessystemctl start iptables2. Remove unknown SSH keys
cat ~/.ssh/authorized_keysDelete any unfamiliar public keys.
Linux Antivirus – ClamAV
Installation
Debian/Ubuntu:
sudo apt-get updatesudo apt-get install clamav clamav-daemonCentOS/RHEL:
sudo yum install epel-releasesudo yum install clamav clamav-updateUpdate virus database
sudo freshclamScanning examples
# Scan a single fileclamscan /path/to/your/file# Recursively scan a directoryclamscan -r /path/to/directory# Remove infected files automaticallyclamscan --remove -r /path/to/directory# Generate a scan reportclamscan -r /path/to/directory > scanreport.txt# Use the daemon client for faster scanssudo systemctl start clamav-daemonclamdscan /path/to/your/fileclamdscan -r /path/to/your/directoryclamdscan --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.
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.
