Detection rules › Splunk

Impacket atexec.py Scheduled Task Creation (Windows Event Log)

Group by
_time, host
Source
github.com/anvilogic-forge/armory

Impacket's atexec.py is a tool designed for executing commands on a target system via the Windows Task Scheduler to run arbitrary commands with the privileges of the account under which the scheduler is running, often providing a method for remote command execution which can be used by attackers during post-exploitation activities. This use case detects the creation of scheduled tasks matching characteristics of those created by Impacket atexec.py, notably the presence of commands in the task content and an 8 character mixed-case alphabetic task name.

MITRE ATT&CK coverage

References

Event coverage

ProviderEventTitle
Security-AuditingEvent ID 4698A scheduled task was created.

Rule body yaml

id: '29247.52789'
title: Impacket atexec.py Scheduled Task Creation
description: Impacket's atexec.py is a tool designed for executing commands on a target
  system via the Windows Task Scheduler to run arbitrary commands with the privileges
  of the account under which the scheduler is running, often providing a method for
  remote command execution which can be used by attackers during post-exploitation
  activities. This use case detects the creation of scheduled tasks matching characteristics
  of those created by Impacket atexec.py, notably the presence of commands in the
  task content and an 8 character mixed-case alphabetic task name.
logic_format: Splunk
logic: '`get_endpoint_data` `get_endpoint_data_winevent` (TERM(EventCode=4698) OR
  "<EventID>4698<") "exec" "/C" ".tmp" | where match(TaskName, "^\x5c[A-Za-z]{8}$")
  | table _time, host, user, TaskName | bin span=1s | stats values(*) as * by _time,
  host '
techniques:
- execution:scheduled task/job
- execution:command and scripting interpreter
- execution:scheduled task/job:scheduled task
- persistence:scheduled task/job:scheduled task
- privilege-escalation:scheduled task/job:scheduled task
- execution:command and scripting interpreter:windows command shell
- defense-evasion:obfuscated files or information
technique_id:
- T1053
- T1059
- T1053.005
- T1059.003
- T1027
data_category:
- Windows event logs
references:
- https://u0041.co/blog/post/1
- https://github.com/fortra/impacket/blob/master/examples/atexec.py
- https://labs.withsecure.com/content/dam/labs/docs/WithSecure-Lazarus-No-Pineapple-Threat-Intelligence-Report-2023.pdf
- https://thedfirreport.com/2023/10/30/netsupport-intrusion-results-in-domain-compromise/

Stages and Predicates

Stage 1: search

`get_endpoint_data` `get_endpoint_data_winevent` (TERM(EventCode=4698) OR "<EventID>4698<") "exec" "/C" ".tmp"

Stage 2: where

| where match(TaskName, "^\x5c[A-Za-z]{8}$")

Stage 3: table

| table _time, host, user, TaskName

Stage 4: bucket

| bin span=1s

Stage 5: stats

| stats values(*) as * by _time, host

Indicators

Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.

FieldKindValues
EventCodeeq
  • 4698 corpus 14 (splunk 14)
TaskNamematch
  • "^\x5c[A-Za-z]{8}$"

Search terms

Bare-string tokens in the SPL search body. Splunk matches each token against _raw (the untyped raw event text) anywhere it appears, not against a specific field. These don't surface in the Indicators table because they aren't predicates on a known field.

StageTerm
1TERM
1"<EventID>4698<"
1"exec"
1"/C"
1".tmp"