Detection rules › Splunk

Windows Powershell Commands from DNS TXT

Status
production
Severity
low
Group by
Guid, Name, Opcode, Path, ScriptBlockId, ScriptBlockText, dest, process_id, signature, signature_id, user_id, vendor_product
Author
Raven Tait, Splunk
Source
github.com/splunk/security_content

The following analytic detects execution of powershell commands retrieved from a remote DNS TXT query response. The use of the DNS TXT record for C2 is an uncommon method for malware that is resilient due to the need for DNS in normal networking activities. This can ensure that their C2 is not blocked by any firewalls.

Known false positives

  • While false positives should be unlikely given the uncommon combination of PowerShell execution and DNS TXT query responses. Due to the nature of Script Block Logging, it is possible that legitimate strings or unrelated commands might all match at once. Apply appropriate exclusions for those edge cases.

MITRE ATT&CK coverage

Telemetry coverage

Rule body

name: Windows Powershell Commands from DNS TXT
id: b61353cd-5b09-4699-8b86-6517a9038043
version: 1
creation_date: '2026-07-30'
modification_date: '2026-07-30'
author: Raven Tait, Splunk
status: production
type: Anomaly
description: |-
    The following analytic detects execution of powershell commands retrieved from a remote DNS TXT query response.
    The use of the DNS TXT record for C2 is an uncommon method for malware that is resilient due to the need for DNS in normal networking
    activities.
    This can ensure that their C2 is not blocked by any firewalls.
data_source:
    - Powershell Script Block Logging 4104
search: |-
    `powershell`
    EventCode=4104
    ScriptBlockText IN ("*resolve-dnsname *", "*nslookup *", "*dig *")
    ScriptBlockText IN ("*-Type TXT*", "*type=txt*", "* TXT*")
    ScriptBlockText IN ("*. (*", "*IEX*")
    
    | fillnull
    | stats count min(_time) as firstTime
                  max(_time) as lastTime
    
    by dest signature signature_id
       user_id vendor_product EventID
       Guid Opcode Name
       Path ProcessID ScriptBlockId
       ScriptBlockText
    
    | `security_content_ctime(firstTime)`
    | `security_content_ctime(lastTime)`
    | `windows_powershell_commands_from_dns_txt_filter`
how_to_implement: |-
    To successfully implement this analytic, you will need to enable PowerShell Script Block Logging on some or all endpoints. Additional setup instructions are available at https://docs.splunk.com/Documentation/ES/latest/Admin/Configurepowershelllogging.
known_false_positives: |-
    While false positives should be unlikely given the uncommon combination of PowerShell execution and DNS TXT query responses.
    Due to the nature of Script Block Logging, it is possible that legitimate strings or unrelated commands might all match at once.
    Apply appropriate exclusions for those edge cases.
intermediate_findings:
    entities:
        - field: dest
          type: system
          score: 20
          message: A suspicious PowerShell script with the ScriptBlockId [$ScriptBlockId$] containing DNS TXT query commands was executed on host $dest$
        - field: user_id
          type: user
          score: 20
          message: A suspicious PowerShell script with the ScriptBlockId [$ScriptBlockId$] containing DNS TXT query commands was executed on host $dest$ by user $user_id$
analytic_story:
    - Malicious PowerShell
    - Command And Control
    - Suspicious DNS Traffic
asset_type: Endpoint
mitre_attack_id:
    - T1071.004
    - T1059.001
product:
    - Splunk Enterprise
    - Splunk Enterprise Security
    - Splunk Cloud
security_domain: endpoint
category: endpoint

Stages and Predicates

Stage 1: search

`powershell`
EventCode=4104
ScriptBlockText IN ("*resolve-dnsname *", "*nslookup *", "*dig *")
ScriptBlockText IN ("*-Type TXT*", "*type=txt*", "* TXT*")
ScriptBlockText IN ("*. (*", "*IEX*")

Stage 2: fillnull

| fillnull

Stage 3: stats

| stats count min(_time) as firstTime
              max(_time) as lastTime

by dest signature signature_id
   user_id vendor_product EventID
   Guid Opcode Name
   Path ProcessID ScriptBlockId
   ScriptBlockText

Stage 4: search

| `security_content_ctime(firstTime)`

Stage 5: search

| `security_content_ctime(lastTime)`

Stage 6: search

| `windows_powershell_commands_from_dns_txt_filter`

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
EventCodeeq
  • 4104 corpus 269 (splunk 269)
field:"EventID" kind:eq value:"4104"
ScriptBlockTextin
  • "* TXT*"
  • "*-Type TXT*"
  • "*. (*"
  • "*IEX*" corpus 2 (sigma 2)
  • "*dig *"
  • "*nslookup *"
  • "*resolve-dnsname *"
  • "*type=txt*"
field:"ScriptBlockText" kind:in