Scheduled Task/Job (T1053)
Running malicious code on a specific schedule (e.g., every day at 9am) or event (system boot).
1. Windows Task Scheduler
The most common Windows persistence.
Command Line (schtasks)
# Create a task named "OneDrive Update" that runs executable every boot
schtasks /create /tn "OneDrive Update" /tr "C:\Users\Public\malware.exe" /sc onstart /ru SYSTEM
- /ru SYSTEM: Runs as highest privilege (if you have admin).
- /sc onidle: Runs when user goes idle (stealthy).
COM Handler Hijacking (Advanced)
Some Tasks don't execute a binary; they call a COM Object.
- Find a Task interacting with a COM CLSID.
- Overwrite that CLSID in the Registry to point to
malware.dll. - When the Task wakes up, it loads your DLL.
2. Linux Cron
User-level and System-level scheduling.
Crontab
# Edit current user's cron
crontab -e
# Add line: Run every hour
0 * * * * /tmp/.hidden/miner.sh
Systemd Timers
More modern than cron. Harder to spot if you don't look in /etc/systemd/system.
- Service Unit:
evil.service(Defines what to run). - Timer Unit:
evil.timer(Defines when to run). - Enable:
systemctl enable --now evil.timer.
OpSec
- Blend In: Name your task
EdgeUpdateorGoogleUpdater. NeverHacked. - Hide: Windows allows "Hidden" tasks that don't show up in the basic GUI list without checking "Show Hidden Tasks".