Detection of DNSExfiltrator PowerShell Activity
Adversaries utilize the DNSExfiltrator tool to tunnel file data through covert DNS requests, bypassing traditional network egress filtering.
DNSExfiltrator is a post-exploitation utility used by threat actors to exfiltrate sensitive files from a compromised host by embedding data within DNS queries. The tool leverages DNS as a covert communication channel, allowing exfiltration to occur even in highly restricted network environments where direct internet access is blocked. It supports multiple encoding schemes and DNS-over-HTTPS (DoH) for obfuscation, making it difficult to detect via standard perimeter firewalls. By breaking files into small chunks and sending them as subdomains in iterative DNS requests, the tool reconstructs the data on an attacker-controlled authoritative name server. Monitoring PowerShell Script Block Logging is essential for detecting the invocation of this tool before exfiltration traffic occurs.
Attack Chain
- Initial access is established through a previously compromised endpoint.
- PowerShell is executed to load the DNSExfiltrator framework.
- The operator specifies the target file path using the
-iparameter. - The operator defines the target malicious DNS domain using the
-dparameter. - The tool configures exfiltration parameters, such as delay and chunk size, via the
-pand-tflags. - The operator optionally specifies DNS-over-HTTPS (DoH) redirection using the
-dohparameter. - DNSExfiltrator chunks the file data and initiates recursive DNS queries.
- Data is exfiltrated to the attacker's listener, where it is reassembled.
Impact
Successful deployment of DNSExfiltrator results in the stealthy exfiltration of sensitive organizational data, including configuration files, credentials, or intellectual property. Because this technique relies on DNS, it effectively circumvents traditional DLP and proxy-based egress controls, leading to high-impact data loss that may remain undetected for extended periods.
Recommendation
- Enable Windows PowerShell Script Block Logging (Event ID 4104) across all endpoints to capture the command-line arguments used by this tool.
- Deploy the provided Sigma rule to your SIEM to monitor for 'Invoke-DNSExfiltrator' or associated command-line parameters.
- Review DNS query logs for anomalous spikes in traffic directed to unknown or high-entropy subdomains, which may indicate active exfiltration.
Immediate actions
Enable PowerShell Script Block Logging across domain
Threat Hunt
Search for DNS queries containing long, high-entropy subdomains
Data: DNS query logs
Detection coverage 1
Detect DNSExfiltrator PowerShell Usage
highDetects the use of DNSExfiltrator commandlets or specific parameter combinations indicative of covert DNS exfiltration
Detection queries are available on the platform. Get full rules →