Scheduled Tasks and Cron Jobs
What you'll learn: How attackers abuse legitimate task schedulers to maintain persistent access to compromised systems and how defenders can detect these techniques.
The Persistence Mechanism
Operating systems provide built-in task schedulers to automate routine work: Windows Task Scheduler and Linux cron/systemd timers. Attackers love these because they're legitimate OS features that blend into normal activity—like hiding in a crowd.
When malware establishes persistence through scheduled tasks, it ensures malicious code runs automatically at system startup, user login, or specific intervals. This survives reboots and maintains access even after the initial infection vector closes.
Windows Task Scheduler Abuse
Attackers create scheduled tasks that execute malicious payloads disguised as system maintenance or update processes. Common triggers include:
- System startup or user login
- Idle time detection
- Specific time intervals (every hour, daily)
- Event-based triggers (like network connection)
Tasks can run with elevated privileges and may reference legitimate-looking paths while actually launching backdoors or downloading additional payloads.
Linux Cron Job Exploitation
On Linux systems, attackers modify cron configurations in /etc/crontab, user-specific crontabs, or drop files in /etc/cron.d/. They schedule scripts that establish reverse shells, download updates from command-and-control servers, or maintain backdoor access.
Detection Techniques
Baseline normal activity: Document legitimate scheduled tasks before incidents occur. New or modified tasks during investigation warrant scrutiny.
Monitor creation events: Windows Event ID 4698 (task created) and audit logs showing crontab modifications reveal suspicious scheduling activity.
Analyze task properties: Examine command lines, file paths, and execution accounts. Legitimate tasks typically use standard directories and system accounts—not random user profiles or temporary folders.
Check for obfuscation: Tasks with cryptic names, encoded commands, or unusual binaries are red flags.
Key Takeaway: Task schedulers provide attackers with reliable, low-noise persistence that survives system restarts; defenders must baseline legitimate scheduled jobs and monitor for unauthorized task creation or modification through audit logs and security tooling.