IncidentResponsev2

4.45 Check for Unauthorized Scheduled Tasks and Services

Task Identify and Remove Unauthorized Scheduled Tasks and Services

Conditions

Given access to impacted systems and elevated permissions, the operator will enumerate, review, and remove attacker-created or unauthorized scheduled tasks and services designed to maintain persistence or execute malicious code.

Operator Note: Scheduled tasks and unauthorized services are often used by attackers for persistence. Thorough review and cleanup of these artifacts is critical during eradication.

Standards

End State

All unauthorized and attacker-created scheduled tasks and services have been identified, validated, removed, and documented. No malicious persistence mechanisms remain.


Notes


Manual Steps

Step 1: Enumerate Scheduled Tasks

Windows

Get-ScheduledTask | Where-Object {$_.State -ne "Disabled"} | Format-Table TaskName, State, LastRunTime
schtasks /query /fo LIST /v

Linux (cron jobs)

crontab -l
ls /etc/cron.*
cat /etc/crontab
systemctl list-timers

macOS (launchd and cron)

launchctl list
crontab -l

Operator Note: Pay attention to tasks with non-standard user names, random file names, or unusual execution paths (AppData, Temp folders).


Step 2: Enumerate Services

Windows

Get-Service | Where-Object {$_.Status -eq "Running"} | Format-Table Name, DisplayName, Status
Get-WmiObject win32_service | Select-Object Name, StartMode, State, PathName

Linux

systemctl list-units --type=service --state=running
chkconfig --list

macOS

launchctl list
sudo launchctl print system

Step 3: Investigate Suspicious Tasks and Services

Criteria for suspicious tasks/services:

Operator Note: Coordinate findings with IR and system/application owners.


Step 4: Disable and Remove Unauthorized Entries

Windows (Disable and Remove Scheduled Task)

Disable-ScheduledTask -TaskName "MaliciousTask"
Unregister-ScheduledTask -TaskName "MaliciousTask" -Confirm:$false

Windows (Disable and Remove Service)

Stop-Service -Name "MaliciousService"
sc.exe delete "MaliciousService"

Linux (Remove Cron Jobs)

crontab -r -u attackeruser
sudo rm /etc/cron.d/maliciouscron
sudo systemctl disable malicious.service
sudo systemctl stop malicious.service
sudo rm /etc/systemd/system/malicious.service

macOS (Remove Launch Agent/Daemon)

sudo launchctl bootout system /Library/LaunchDaemons/malicious.plist
sudo rm /Library/LaunchDaemons/malicious.plist

Step 5: Validate Removal


Running Script (Windows - Find Non-Microsoft Running Services)

Get-WmiObject win32_service | Where-Object {$_.PathName -notlike "*Microsoft*"} | Format-Table Name, State, PathName

Operator Note: Focus on non-standard service paths and names during eradication validation.


Dependencies


Other Available Tools

Tool Platform Installation Usage
Autoruns (Sysinternals) Windows Download from Sysinternals View all scheduled tasks, services, and persistence
PowerShell Windows Built-in View, disable, remove scheduled tasks/services
systemctl / crontab Linux Built-in Manage services and scheduled tasks
launchctl macOS Built-in Manage launch daemons and agents

Operator Note: Autoruns is highly recommended for full Windows persistence review during eradication.


Operator Recommendations and Additional Tools

Operator Checklist

Best Practices


References

Microsoft Sysinternals Autoruns
systemd - Linux Services
Apple macOS launchctl Reference


Revision History

Date Version Description Author
2025-05-02 1.0 Fully generated operator guide for checking/removing unauthorized scheduled tasks and services with platform guidance Leo