hunting-for-suspicious-scheduled-tasks skill (Anthropic-Cybersecurity-Skills)

From Public Agent Wiki

What it does. Hunts for adversary persistence and execution via Windows scheduled tasks (T1053.005) by analyzing Security Event ID 4698 task-creation events, suspicious task properties, and unusual execution patterns from schtasks.exe/at.exe. Use after detecting schtasks or at.exe in process creation logs, during incident response to enumerate persistence on compromised hosts, or when Event ID 4698 fires for an unusual task. Part of mukul975/Anthropic-Cybersecurity-Skills (817 security skills) (mukul975/Anthropic-Cybersecurity-Skills).

Upstream mukul975/Anthropic-Cybersecurity-Skills
Skill file skills/hunting-for-suspicious-scheduled-tasks/SKILL.md
License Apache-2.0 (skill folder LICENSE)
Author mukul975
Fetched 2026-09-10

Install

  • npx skills add mukul975/Anthropic-Cybersecurity-Skills --skill hunting-for-suspicious-scheduled-tasks, or copy the skill folder into ~/.claude/skills/hunting-for-suspicious-scheduled-tasks/.
  • Raw file: curl -sL https://raw.githubusercontent.com/mukul975/Anthropic-Cybersecurity-Skills/HEAD/skills/hunting-for-suspicious-scheduled-tasks/SKILL.md

SKILL.md (verbatim)

name: hunting-for-suspicious-scheduled-tasks
description: Hunts for adversary persistence and execution via Windows scheduled tasks (T1053.005) by analyzing Security Event ID 4698 task-creation events, suspicious task properties, and unusual execution patterns from schtasks.exe/at.exe. Use after detecting schtasks or at.exe in process creation logs, during incident response to enumerate persistence on compromised hosts, or when Event ID 4698 fires for an unusual task.
domain: cybersecurity
subdomain: threat-hunting
tags:
- threat-hunting
- scheduled-tasks
- persistence
- mitre-t1053-005
- windows
- endpoint-detection
version: '1.0'
author: mahipal
license: Apache-2.0
nist_csf:
- DE.CM-01
- DE.AE-02
- DE.AE-07
- ID.RA-05
mitre_attack:
- T1046
- T1057
- T1082
- T1083
- T1547

Hunting for Suspicious Scheduled Tasks

When to Use

  • When proactively hunting for persistence mechanisms in Windows environments
  • After detecting schtasks.exe or at.exe usage in process creation logs
  • When investigating malware that survives reboots and user logoffs
  • During incident response to enumerate all persistence on compromised systems
  • When Windows Security Event ID 4698 (Scheduled Task Created) fires for unusual tasks

Prerequisites

  • Windows Security Event ID 4698/4699/4702 (Task Created/Deleted/Updated)
  • Sysmon Event ID 1 for schtasks.exe process creation with command lines
  • Windows Task Scheduler operational log (Microsoft-Windows-TaskScheduler/Operational)
  • PowerShell logging for Register-ScheduledTask cmdlet usage
  • Access to Task Scheduler XML definitions on endpoints

Workflow

  1. Enumerate All Scheduled Tasks: Collect complete task inventory from target systems using schtasks /query /fo CSV /v or Get-ScheduledTask PowerShell cmdlet.
  2. Monitor Task Creation Events: Track Event ID 4698 for new task creation, correlating with the creating process and user account context.
  3. Analyze Task Actions: Examine what each task executes. Flag tasks running scripts (PowerShell, cmd, wscript), binaries from user-writable paths (TEMP, AppData, Downloads), or encoded/obfuscated commands.
  4. Check Task Triggers: Review trigger conditions. Tasks triggered by system startup, user logon, or short intervals (1-5 minutes) warrant investigation.
  5. Identify Hidden or Disguised Tasks: Hunt for tasks with names mimicking legitimate Windows tasks, tasks with Security Descriptor modifications hiding them from standard enumeration, or tasks stored in non-standard registry locations.
  6. Correlate with Process Execution: Match scheduled task execution events with process creation logs to confirm what actually runs.
  7. Baseline and Diff: Compare current task inventory against known-good baselines to identify new, modified, or unexpected tasks.

Detection Queries

Splunk -- Scheduled Task Creation

index=wineventlog EventCode=4698
| spath output=TaskName path=EventData.TaskName
| spath output=TaskContent path=EventData.TaskContent
| where NOT match(TaskName, "(?i)(\\\\Microsoft\\\\|\\\\Windows\\\\)")
| table _time Computer SubjectUserName TaskName TaskContent

Splunk -- Schtasks.exe Suspicious Usage

index=sysmon EventCode=1 Image="*\\schtasks.exe"
| where match(CommandLine, "(?i)/create")
| where match(CommandLine, "(?i)(powershell|cmd|wscript|cscript|mshta|rundll32|regsvr32|http|https|\\\\temp\\\\|\\\\appdata\\\\)")
| table _time Computer User CommandLine ParentImage

KQL -- Microsoft Sentinel

SecurityEvent
| where EventID == 4698
| extend TaskName = tostring(EventData.TaskName)
| extend TaskContent = tostring(EventData.TaskContent)
| where TaskContent has_any ("powershell", "cmd.exe", "wscript", "http://", "https://", "\\Temp\\", "\\AppData\\")
| project TimeGenerated, Computer, Account, TaskName, TaskContent

Common Scenarios

  1. Cobalt Strike Persistence: Creates scheduled tasks via schtasks.exe to execute PowerShell download cradles at user logon intervals.
  2. Ransomware Staging: Task created to run encryption payload at a future time, often during off-hours for maximum impact.
  3. Hidden Task via SD Modification: Attacker modifies Security Descriptor of scheduled task to hide it from normal enumeration while maintaining execution.
  4. COM Handler Abuse: Task uses COM handler rather than direct executable path, making action inspection more complex.
  5. Lateral Movement via Tasks: Remote scheduled task creation using schtasks /create /s REMOTE_HOST for execution on other systems.

Output Format

Hunt ID: TH-SCHTASK-[DATE]-[SEQ]
Host: [Hostname]
Task Name: [Full task path]
Action: [Command/Script executed]
Trigger: [Startup/Logon/Timer/Event]
Created By: [User account]
Created From: [Local/Remote]
Creation Time: [Timestamp]
Run As: [Execution account]
Risk Level: [Critical/High/Medium/Low]

Other files in this skill

assets/template.md (verbatim)

Suspicious Scheduled Task Hunt Template

Hunt Metadata

Field Value
Hunt ID TH-SCHTASK-YYYY-MM-DD-NNN
Analyst
Date
Status [ ] In Progress / [ ] Complete

Hypothesis

Adversaries have established persistence via scheduled tasks that execute malicious payloads at system startup, user logon, or recurring intervals.

Task Findings

# Host Task Name Action Trigger Created By Created Time Risk
1

Recommendations

  1. Remove: [Malicious scheduled tasks]
  2. Investigate: [Executed payloads and their impact]
  3. Detect: [Deploy 4698 monitoring rules]
  4. Baseline: [Establish known-good task inventory]

references/api-reference.md (verbatim)

API Reference: Hunting for Suspicious Scheduled Tasks

Windows Event IDs

Event ID Source Description
4698 Security Scheduled task created
4699 Security Scheduled task deleted
4702 Security Scheduled task updated
106 TaskScheduler Task registered
200/201 TaskScheduler Task executed / completed

python-evtx

import Evtx.Evtx as evtx
import xml.etree.ElementTree as ET

with evtx.Evtx("Security.evtx") as log:
    for record in log.records():
        root = ET.fromstring(record.xml())
        ns = {"ns": "http://schemas.microsoft.com/win/2004/08/events/event"}
        eid = root.find(".//ns:EventID", ns).text
        if eid == "4698":
            data = {d.get("Name"): d.text
                    for d in root.findall(".//ns:Data", ns)}

Splunk SPL

index=wineventlog EventCode=4698
| spath output=TaskName path=EventData.TaskName
| spath output=TaskContent path=EventData.TaskContent
| where NOT match(TaskName, "\\\\Microsoft\\\\Windows\\\\")
| where match(TaskContent, "(?i)(powershell|cmd|wscript|http)")
| table _time Computer SubjectUserName TaskName TaskContent

KQL (Microsoft Sentinel)

SecurityEvent
| where EventID == 4698
| extend TaskContent = tostring(EventData.TaskContent)
| where TaskContent has_any ("powershell", "cmd.exe", "Temp", "AppData")
| project TimeGenerated, Computer, Account, TaskContent

PowerShell Enumeration

Get-ScheduledTask | Where-Object {
    $_.Actions.Execute -match 'powershell|cmd|wscript' -or
    $_.Actions.Execute -match '\\Temp\\|\\AppData\\'
} | Select-Object TaskName, TaskPath, @{N='Action';E={$_.Actions.Execute}}

References

references/standards.md (verbatim)

Standards and References - Suspicious Scheduled Tasks

MITRE ATT&CK References

Technique Name Usage
T1053.005 Scheduled Task Primary persistence/execution technique
T1053.003 Cron (Linux) Scheduled execution on Linux
T1078 Valid Accounts Tasks running under legitimate accounts

Windows Event IDs

Event ID Source Description
4698 Security Scheduled task created
4699 Security Scheduled task deleted
4700 Security Scheduled task enabled
4701 Security Scheduled task disabled
4702 Security Scheduled task updated
106 TaskScheduler/Operational Task registered
200 TaskScheduler/Operational Action started
201 TaskScheduler/Operational Action completed

Suspicious Task Indicators

Indicator Description
User-writable paths Actions executing from TEMP, AppData, Downloads
Encoded commands Base64 or -EncodedCommand in arguments
Script interpreters PowerShell, cmd, wscript, cscript as actions
Short intervals Trigger repeating every 1-5 minutes
System startup trigger Task runs at boot for persistence
Remote creation Task created from remote system
Name mimicry Task name similar to legitimate Windows tasks
Hidden SD Security Descriptor modified to hide task

references/workflows.md (verbatim)

Detailed Hunting Workflow - Suspicious Scheduled Tasks

Phase 1: Task Enumeration

# Full task export with details
Get-ScheduledTask | Where-Object { $_.TaskPath -notmatch "\\Microsoft\\" } |
    ForEach-Object { $_ | Get-ScheduledTaskInfo; $_.Actions | Select-Object Execute, Arguments }

# Check for hidden tasks in registry
Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree" -Recurse

Phase 2: SIEM Analysis

index=wineventlog EventCode=4698
| spath output=TaskName path=EventData.TaskName
| spath output=TaskContent path=EventData.TaskContent
| rex field=TaskContent "<Command>(?<cmd>[^<]+)</Command>"
| rex field=TaskContent "<Arguments>(?<args>[^<]+)</Arguments>"
| table _time Computer SubjectUserName TaskName cmd args

Phase 3: Remote Task Creation Detection

index=sysmon EventCode=1 Image="*\\schtasks.exe"
| where match(CommandLine, "(?i)/create.*/s\s+")
| rex field=CommandLine "/s\s+(?<remote_host>\S+)"
| table _time Computer User remote_host CommandLine

Phase 4: Response

  1. Remove malicious scheduled tasks
  2. Check task XML definitions for hidden parameters
  3. Audit all non-Microsoft scheduled tasks across fleet
  4. Deploy detection rules for suspicious task creation

Back to mukul975/Anthropic-Cybersecurity-Skills (817 security skills) or Agent skills.