Lesson 65 — Hunting Persistence Techniques
Investigate how suspicious access may survive a reboot or user sign-out by hunting changes to scheduled tasks, services and local accounts in Microsoft Sentinel.

What you will learn
Look for persistence mechanisms, validate the evidence and avoid assuming every new task is malicious.
Agent Foskett case file — The task that survived the reboot
A workstation is restarted after a suspicious sign-in investigation. Hours later, a scheduled task executes again. Is it an authorized software updater, an IT maintenance job or an unauthorized persistence mechanism? Agent Foskett searches for the original change, its creator and the command it launched before reaching a conclusion.
Learning objectives
- Explain persistence as an adversary objective rather than a verdict about a single event.
- Check relevant Windows event ingestion and audit policy.
- Hunt new scheduled tasks and services using KQL.
- Investigate local account creation and group membership changes.
- Correlate event times with approved changes and host evidence.
- Document confidence, gaps and escalation criteria.
What is persistence?
Persistence describes methods that allow an adversary to retain access after a reboot, credential change or session interruption. Common Windows mechanisms include scheduled tasks, services, startup entries and unauthorized accounts. These mechanisms are also used legitimately by software and administrators.
A hypothesis, not an accusation
Hypothesis: a newly created scheduled task on a sensitive workstation may be an unauthorized persistence mechanism. Alternatives: an application update, enterprise management tooling, a maintenance task or a deployment script. Your hunt should be designed to distinguish these possibilities.
Telemetry and schema boundaries
The following queries use SecurityEvent in Microsoft Sentinel Logs, assuming Windows Security Events are ingested into that table. Depending on your connector and collection configuration, events may instead be available in WindowsEvent with different field structures. Defender XDR DeviceRegistryEvents and DeviceProcessEvents are separate advanced-hunting sources unless explicitly integrated into your environment.
Windows events worth collecting
| Event | Typical significance | Important qualification |
|---|---|---|
| 4698 | Scheduled task created | Requires relevant auditing and collection |
| 4702 | Scheduled task updated | Task details may vary by OS and event version |
| 4697 | Service installed | Audit coverage differs from System event 7045 |
| 4720 | User account created | Account scope and reporting host matter |
| 4732 | Member added to a security-enabled local group | Requires group and actor context |
System event 7045 is commonly useful for service installation but is not the same as SecurityEvent ID 4697. Confirm its table and channel before querying.
Audit policy and collection matter
Scheduled task and service creation events may not be present unless auditing is configured and the collector includes them. A quiet query is not proof that no persistence mechanism exists. Confirm event sources, collection rules, reporting hosts and retention first.
KQL hunt 1 — Check persistence event coverage
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
SecurityEvent
| where TimeGenerated >= ago(7d)
| where EventID in (4698, 4702, 4697, 4720, 4732)
| summarize Events = count(),
ReportingHosts = dcount(Computer),
LastSeen = max(TimeGenerated)
by EventID, bin(TimeGenerated, 1d)
| order by TimeGenerated asc, EventID ascThis reports what was collected, not everything that happened. Check expected host coverage and confirm audit settings for any missing event types.
Start with the change, then the command
For a scheduled task, identify its creation or modification time, reporting computer, task name, action, account context and initiating user where available. Some details are embedded in event payloads and may not appear as normalized columns. Inspect a sample record before extracting fields.
Why scheduled tasks are useful to hunt
Tasks can run at startup, at logon or on a timer. Their mere existence is normal. A suspicious lead might involve an unfamiliar task created shortly after an unusual sign-in, especially if it launches an unexpected binary from a user-writable directory.
KQL hunt 2 — Find newly created or updated tasks
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
SecurityEvent
| where TimeGenerated >= ago(72h)
| where EventID in (4698, 4702)
| project TimeGenerated, Computer, EventID,
Account, Activity, EventData
| order by TimeGenerated desc
| take 250Review the actual EventData payload and its available structure before extracting task names or actions. The row limit can truncate busy environments.
Interpret task action carefully
Inspect the executable path, arguments, triggering conditions and user context where available. Compare against authorized software inventories, known management tasks and the original change ticket. A script host or command interpreter is not inherently malicious.
Service installation as a persistence lead
New Windows services can run with elevated privileges and may start automatically. Investigate unexpected service installations, binary paths, signing information and the account used. Check whether your environment collects Security event 4697, System event 7045, or both.
KQL hunt 3 — Investigate service and account changes
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
SecurityEvent
| where TimeGenerated >= ago(7d)
| where EventID in (4697, 4720, 4732)
| project TimeGenerated, Computer, EventID,
Account, Activity, EventData
| order by TimeGenerated desc
| take 300This query is a triage list, not a correlated proof of persistence. Verify each event’s meaning and field values against raw event data.
New accounts and group changes
An unexpected local account or new local administrator can support a persistence hypothesis. Confirm whether the change was approved, who initiated it, whether the account has logged on and whether its permissions exceed business needs. Account creation alone does not establish attacker intent.
Registry run keys and startup folders
Windows registry Run keys and startup folders are additional persistence locations. If you have Defender for Endpoint telemetry, investigate relevant registry and file changes using the Defender XDR advanced-hunting schema. Do not assume those tables exist in Sentinel Logs without checking integration and permissions.
Map to MITRE ATT&CK
Relevant hypotheses include Scheduled Task/Job (T1053), Create or Modify System Process: Windows Service (T1543.003), and Create Account (T1136). Map a technique only when the observed behavior supports it; a matching event ID is not enough to label the activity malicious.
Build a persistence timeline
Record the first suspicious sign-in, task or service creation, subsequent modifications, any execution evidence and the next observed access. Correlate using host, account, event identifiers and timestamps. Be explicit about uncertainty and collection gaps.
Cross-check execution evidence
Task creation does not prove task execution. Where available, use task operational logs, process creation auditing or endpoint telemetry to confirm whether the action ran, what it launched and under which identity. Preserve process identifiers and command lines through approved evidence-handling procedures.
False positives and expected change
Operating system updates, endpoint agents, installers and remote management platforms create tasks and services frequently. Check change calendars, signed binaries, approved deployment systems and software ownership before escalating.
Performance and hunting scope
Begin with a narrow window and a defined set of event IDs. Expand only after validating data coverage. Project relevant fields and cap exploratory result sets, while documenting any limits that might omit important activity.
Agent Foskett investigation workflow
When should the analyst escalate?
Escalate through the organization’s incident process when changes are unexplained and corroborated by suspicious execution, unauthorized access or privilege misuse. Avoid disabling a production service or deleting a task based solely on a hunting query.
Case file resolution — The task that survived the reboot
The task was created by a legitimate software deployment agent during an approved maintenance window. Its executable path and signing details matched the deployment package. Agent Foskett records the evidence and closes the initial hypothesis as unsupported. The hunt also exposes a documentation gap: the deployment team had not registered its task naming convention.
Finding: the task persisted, but unauthorized persistence was not established.
Hands-on lab — Hunt persistence changes
- Check event coverage for IDs 4698, 4702, 4697, 4720 and 4732.
- Choose an approved lab host and identify recent task changes.
- Inspect a sample event payload and note the available fields.
- Check for service or account changes in the same window.
- Correlate candidate changes with approved maintenance.
- Record two alternative explanations and one evidence gap.
- Write a conclusion supported by the observed records.
Knowledge check
- Why is a scheduled task not automatically suspicious?
- What does a zero-row result prove about audit coverage?
- How do Security event 4697 and System event 7045 differ?
- What evidence distinguishes task creation from execution?
- Why should task changes be compared against maintenance records?
Operational quality checklist
- Confirm collection and retention before interpreting absence.
- Use the correct table for Windows Security and System events.
- Inspect raw event payloads rather than assuming extracted columns.
- Keep KQL read-only and time bounded.
- Preserve analyst notes and alternative explanations.
- Do not link to unpublished Lesson 66.
Agent Foskett takeaway
Persistence is a question of intent, context and execution—not simply the presence of a task or service. Find the change, trace its origin and verify what actually happened.
The Logs Already Knew.
