Netshexe Command-Line Argument Behavior: A Detection Evasion Technique

Listen to this Post

Featured Image
The Splunk Threat Research Team has uncovered a curious behavior in the Windows utility `Netsh.exe` that can be leveraged to evade detection. This utility processes command-line arguments in a way that allows users to execute firewall commands without fully typing out parameters. Attackers can abuse this feature to bypass security monitoring.

Read the full article here:

https://lnkd.in/dvjaT6jQ

You Should Know:

How Attackers Abuse Netsh.exe

`Netsh.exe` (Network Shell) is a legitimate Windows tool for network configuration, but attackers misuse it to:
– Disable firewalls (netsh advfirewall set allprofiles state off)
– Add malicious firewall rules (netsh advfirewall firewall add rule name="EvilRule" dir=in action=allow program="C:\malware.exe")

Evasion Technique

The research highlights that `netsh` allows partial parameter matching, enabling commands like:

netsh advfirewall set allprofiles state off 

to be shortened to:

netsh adv set all state off 

This obfuscation helps evade string-based detections.

Detection Strategies (Splunk SPL Examples)

To detect such misuse, blue teams can use Splunk queries like:

index=windows EventCode=4688 CommandLine="netshadvfirewallstateoff" 
| stats count by host, CommandLine 

Or for partial commands:

index=windows EventCode=4688 CommandLine="netshadvsetallstateoff" 
| table _time host CommandLine 

Mitigation & Hunting Commands

  • Audit Command-Line Logging (Enable in Group Policy):
    gpedit.msc → Computer Configuration → Administrative Templates → System → Audit Process Creation → Enable "Include command line in process creation events" 
    
  • Monitor Suspicious Netsh Usage (PowerShell):
    Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4688} | Where-Object {$_.Message -like "netshadvsetstateoff"} 
    
  • Block Unauthorized Netsh Execution via AppLocker:
    <RuleCollection Type="Exe"> 
    <FilePathRule Name="Block Netsh" Action="Deny" Description="Block unauthorized netsh usage" Path="C:\Windows\System32\netsh.exe" /> 
    </RuleCollection> 
    

What Undercode Say

The abuse of `netsh.exe` underscores the importance of monitoring legitimate tools used maliciously. Security teams should:
– Log command-line arguments in Windows Event IDs (4688).
– Use anomaly detection for unusual `netsh` invocations.
– Implement allowlisting via AppLocker or WDAC.

Additional Useful Commands for Blue Teams:

  • Check Firewall Status:
    netsh advfirewall show allprofiles 
    
  • List All Firewall Rules:
    netsh advfirewall firewall show rule name=all 
    
  • Hunt for Modified Rules (PowerShell):
    Get-NetFirewallRule | Where-Object { $_.Modified -gt (Get-Date).AddDays(-1) } 
    
  • Sysmon Configuration for Netsh Monitoring:
    <RuleGroup name="Netsh Monitoring"> 
    <ProcessCreate onmatch="include"> 
    <CommandLine condition="contains">netsh</CommandLine> 
    </ProcessCreate> 
    </RuleGroup> 
    

Expected Output:

A robust detection strategy combining command-line logging, behavioral analysis, and allowlisting can mitigate `netsh.exe` abuse. Security teams should continuously refine detections based on attacker tradecraft.

Reference:

Splunk Threat Research Team – Netsh Evasion

References:

Reported By: Teoderickc Blueteam – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

Join Our Cyber World:

💬 Whatsapp | 💬 Telegram