Lateral movement
Remote scheduled task execution
schtasks /sImpacket atexec.pyScheduledTasks module
Creating a task on a remote host to run a command, then deleting it. atexec pairs a 4698 with a 4699 for a random task name.
Artifacts by host
Every place this technique leaves a trace. Collect all three sides; each one fills gaps the others leave.
Source
Where the operator ran the tool
Destination
The machine being accessed
- Security4624
Network logon, LogonType 3, for the account creating the task.
- Security4698
Scheduled task created; the task XML carries the command the task will run.
- Security4699
Scheduled task deleted, usually seconds after creation for a transient execution task.
- Task Scheduler106
Task registered in the Task Scheduler operational log.
- Task Scheduler200
Task action started, showing the executable the task ran.
- Task Scheduler141
Task deleted in the operational log, completing the create-run-delete cycle.
- Sysmon1
The task action process as a child of svchost.exe hosting the Task Scheduler service.
- File: output .tmp under %windir%\Temp (atexec), and the task XML under %windir%\System32\Tasks
The redirected command output and the on-disk task definition for the created task.
- Registry: HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\<task>
Task registration record; the Tree and Tasks subkeys hold the task GUID and definition.
Domain controller
Authentication records
- Security4769
Kerberos service ticket for the destination: ServiceName is the destination computer account (DEST$) for the cifs/<dest> or HOST/<dest> SPN, and IpAddress is the source host. The DC-side record that ties source, account and destination together.
- Security4768
TGT request for the account from the source IP, when it had no valid TGT yet (for example right after runas or an explicit-credential logon on the source).
- Security4776
NTLM credential validation with Workstation set to the source name, when NTLM was used instead of Kerberos (destination addressed by IP, or pass-the-hash). Domain accounts only; local accounts are validated on the destination.
Fingerprints
Strings and values specific enough to search for directly.
- 014698 followed within seconds by 4699 for the same randomly named task (atexec)
- 02Task output redirected to a .tmp file under %windir%\Temp
- 03ATSVC named pipe \atsvc used by atexec over SMB
- 04Task action cmd.exe /C with output redirection
- 05A task whose name is a random string rather than a product or admin name
How it works
An operator can execute remotely by registering a scheduled task on the target and letting Task Scheduler run it. schtasks.exe /s creates the task over RPC, and Impacket's atexec.py does the same through the ATSVC named pipe (\atsvc) over SMB. atexec creates a task with a randomly generated name, sets its action to run a command, redirects the output to a temporary file under %windir%\Temp, runs it immediately, reads the output back, and deletes the task. The create-then-delete pattern is the signature: Security 4698 for the task creation followed shortly by 4699 for its deletion, both naming the same random task. On the destination this also produces a network logon and Task Scheduler operational events for the registration and execution.
Hunt queries
Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4698,4699}Benign look-alikes
- Administrators and deployment tools that create tasks remotely for legitimate jobs.
- Backup and patching systems that schedule one-off tasks.
- Named, long-lived tasks created once; the suspicious pattern is a random name created and deleted immediately.