TL;DR
Your VPS is getting odd HTTP requests, possibly from a previous malware infection. This guide helps you investigate and clean up any remnants.
1. Initial Investigation – Logs are Your Friend
- Access your server logs: The most common places are
/var/log/apache2/access.log(Apache) or/var/log/nginx/access.log(Nginx). Use a text editor likenanoorvim, or thetail -fcommand to view them live.sudo tail -f /var/log/apache2/access.log - Look for patterns: Identify the strange requests. Pay attention to:
- IP addresses: Are they from known bad locations? Use a website like AbuseIPDB to check.
- URLs: What are they trying to access? Malware often uses specific, hidden URLs.
- User-Agent strings: Unusual user agents can indicate bots or malicious scripts.
- HTTP methods: Are they using POST requests with strange data?
- Time of activity: When are these requests happening? Scheduled tasks might be involved.
2. Check for Suspicious Files
- Scan your home directories: Look for recently modified files, especially in user accounts that may have been compromised.
find /home -type f -mtime -7 - Look for hidden files and directories: Malware often hides its files. Use
ls -lato show all files, including those starting with a dot (.).ls -la /var/www/html - Check cron jobs: Cron jobs are scheduled tasks that could be running malicious scripts.
crontab -lAlso check system-wide cron files in
/etc/cron.d/and/etc/crontab. - Examine web server configuration: Check your Apache or Nginx config files (usually in
/etc/apache2/sites-available/or/etc/nginx/sites-available/) for any unusual directives.
3. Malware Scanning
- Install a malware scanner: Several options are available, such as:
- ClamAV: A free and open-source antivirus engine.
sudo apt update && sudo apt install clamavThen run a scan:
sudo clamscan -r /var/www/html - Rootkit Hunter (rkhunter): Detects rootkits and other hidden malware.
sudo apt install rkhunter && sudo rkhunter --checkall
- ClamAV: A free and open-source antivirus engine.
- Update the scanner database: Before scanning, make sure your scanner has the latest definitions.
sudo freshclam - Run a full system scan: Scan all critical directories and files.
4. Remove Identified Threats
- Delete malicious files: Carefully remove any files identified as malware by the scanner.
sudo rm /path/to/malicious_file - Remove suspicious cron jobs: Edit your crontab file (using
crontab -e) and delete any entries you don’t recognize or trust. - Restore from backup (if available): If you have a recent, clean backup, restoring it is the safest option.
5. Security Hardening
- Update your software: Keep your operating system and all installed packages up to date.
sudo apt update && sudo apt upgrade - Use strong passwords: For all user accounts, especially root.
- Enable a firewall: UFW (Uncomplicated Firewall) is easy to use.
sudo ufw enable && sudo ufw default deny incoming && sudo ufw allow ssh - Regularly monitor your logs: Set up log monitoring tools to alert you of suspicious activity.
- Consider two-factor authentication: For SSH and other critical services.

