Defense evasion · Windows · LOLBAS
netsh.exe
Network Shell
Configures networking. Used to add firewall rules, set up port forwarding for pivoting, reveal saved Wi-Fi keys and load helper DLLs, so several of its contexts matter for triage.
Legitimate use
Admins use it to configure firewall, interfaces, WLAN and other network settings.
Subcommands
Firewall context. Adding or disabling rules can open access or weaken defenses.
MediumLegacy firewall context. Still used to disable the firewall or add rules.
MediumSets up IPv4/IPv6 port forwarding on the host. Used to pivot and tunnel traffic.
HighInterface context, the parent of portproxy.
LowWireless context. show profiles and show profile reveal saved network details.
MediumAdds an entry, for example a firewall rule or a portproxy mapping.
MediumChanges a setting, for example turning the firewall off.
MediumDisplays settings. show commands are discovery, including saved Wi-Fi profiles.
LowA WLAN profile. show profile name=... exposes a saved network's settings.
LowWith key=clear on a WLAN profile, prints the saved Wi-Fi password in clear text.
MediumCommand lines to worry about
- High
Port forwarding set up
netsh portproxy add v4tov4 forwards a local port to another host, used to pivot through this machine. Rare in normal administration.
Detection regex
netsh(\.exe)?\s+interface\s+portproxy\s+add\s+v4tov4\b - Medium
Firewall turned off
Disabling the firewall opens the host to inbound access. Check whether it was turned back on and what connected afterwards.
Detection regex
netsh(\.exe)?\s+.*firewall\s+set\b.*state\s+off - Medium
Saved Wi-Fi key revealed
key=clear prints the stored Wi-Fi password. Used to harvest wireless credentials from a host.
Detection regex
netsh(\.exe)?\s+wlan\s+show\s+profile\b.*key=clear
Where it is recorded
- Security4688Process creation with the full command line, when command-line auditing is enabled.
- Sysmon1Process creation with command line, hashes and parent process.
- Firewall2004A firewall rule was added, when netsh adds an advfirewall rule.
- Firewall2003Firewall profile setting changed, when the firewall state is altered.
Community detections
16 SigmaHQ rules for netsh.exe. The explainer checks every pasted command line against all of them.
- HighRDP Connection Allowed Via Netsh.EXE
Detects usage of the netsh command to open and allow connections to port 3389 (RDP). As seen used by Sarwent Malware
T1686.003by Sander Wiebing
- HighRDP Port Forwarding Rule Added Via Netsh.EXE
Detects the execution of netsh to configure a port forwarding of port 3389 (RDP) rule
T1090by Florian Roth (Nextron Systems), oscd.community
- HighSuspicious Process By Web Server Process
Detects potentially suspicious processes being spawned by a web server process which could be the result of a successfully placed web shell or exploitation
T1505.003T1190by Thomas Patzke, Florian Roth (Nextron Systems), Zach Stanford @svch0st, Tim Shelton, Nasreddine Bencherchali (Nextron Systems)
- HighSuspicious Program Location Whitelisted In Firewall Via Netsh.EXE
Detects Netsh command execution that whitelists a program located in a suspicious location in the Windows Firewall
T1686.003by Sander Wiebing, Jonhnathan Ribeiro, Daniil Yugoslavskiy, oscd.community
- HighSuspicious Spool Service Child Process
Detects suspicious print spool service (spoolsv.exe) child processes.
T1203T1068by Justin C. (@endisphotic), @dreadphones (detection), Thomas Patzke (Sigma rule)
- MediumFirewall Disabled via Netsh.EXE
Detects netsh commands that turns off the Windows firewall
T1686.003by Fatih Sirin
- MediumFirewall Rule Deleted Via Netsh.EXE
Detects the removal of a port or application rule in the Windows Firewall configuration using netsh
T1686.003by frack113
- MediumFirewall Rule Update Via Netsh.EXE
Detects execution of netsh with the "advfirewall" and the "set" option in order to set new values for properties of a existing rule
by X__Junior (Nextron Systems)
- MediumHarvesting Of Wifi Credentials Via Netsh.EXE
Detect the harvesting of wifi credentials using netsh.exe
T1040by Andreas Hunkeler (@Karneades), oscd.community
- MediumNetsh Allow Group Policy on Microsoft Defender Firewall
Adversaries may modify system firewalls in order to bypass controls limiting network usage
T1686.003by frack113
- MediumNew Firewall Rule Added Via Netsh.EXE
Detects the addition of a new rule to the Windows firewall via netsh
T1686.003by Markus Neis, Sander Wiebing
- MediumNew Network Trace Capture Started Via Netsh.EXE
Detects the execution of netsh with the "trace" flag in order to start a network capture
T1040by Kutepov Anton, oscd.community
- MediumNew Port Forwarding Rule Added Via Netsh.EXE
Detects the execution of netsh commands that configure a new port forwarding (PortProxy) rule
T1090by Florian Roth (Nextron Systems), omkar72, oscd.community, Swachchhanda Shrawan Poudel
- MediumPotential Defense Evasion Via Binary Rename
Detects the execution of a renamed binary often used by attackers or malware leveraging new Sysmon OriginalFileName datapoint.
T1036.003by Matthew Green @mgreen27, Ecco, James Pemberton @4A616D6573, oscd.community, Andreas Hunkeler (@Karneades)
- MediumPotential Persistence Via Netsh Helper DLL
Detects the execution of netsh with "add helper" flag in order to add a custom helper DLL. This technique can be abused to add a malicious helper DLL that can be used as a persistence proxy that gets called when netsh.exe is executed.
T1546.007by Victor Sergeev, oscd.community
- LowFirewall Configuration Discovery Via Netsh.EXE
Adversaries may look for details about the network configuration and settings of systems they access or through information discovery of remote systems
T1016by frack113, Christopher Peacock '@securepeacock', SCYTHE '@scythe_io'
Rules from SigmaHQ (rules/windows/process_creation), Detection Rule License (DRL) 1.1. Each rule links to its source and credits its authors.