Skip to content
WETNav

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.

Worst caseHigh

Subcommands

advfirewall

Firewall context. Adding or disabling rules can open access or weaken defenses.

Medium
firewall

Legacy firewall context. Still used to disable the firewall or add rules.

Medium
portproxy

Sets up IPv4/IPv6 port forwarding on the host. Used to pivot and tunnel traffic.

High
interface

Interface context, the parent of portproxy.

Low
wlan

Wireless context. show profiles and show profile reveal saved network details.

Medium
add

Adds an entry, for example a firewall rule or a portproxy mapping.

Medium
set

Changes a setting, for example turning the firewall off.

Medium
show

Displays settings. show commands are discovery, including saved Wi-Fi profiles.

Low
profile

A WLAN profile. show profile name=... exposes a saved network's settings.

Low
key

With key=clear on a WLAN profile, prints the saved Wi-Fi password in clear text.

Medium

Command 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 regexnetsh(\.exe)?\s+interface\s+portproxy\s+add\s+v4tov4\b

    T1090.001

  • 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 regexnetsh(\.exe)?\s+.*firewall\s+set\b.*state\s+off

    T1562.004

  • Medium

    Saved Wi-Fi key revealed

    key=clear prints the stored Wi-Fi password. Used to harvest wireless credentials from a host.

    Detection regexnetsh(\.exe)?\s+wlan\s+show\s+profile\b.*key=clear

    T1555.004

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.

  • High
    RDP 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

  • High
    RDP 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

  • High
    Suspicious 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)

  • High
    Suspicious 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

  • High
    Suspicious Spool Service Child Process

    Detects suspicious print spool service (spoolsv.exe) child processes.

    T1203T1068by Justin C. (@endisphotic), @dreadphones (detection), Thomas Patzke (Sigma rule)

  • Medium
    Firewall Disabled via Netsh.EXE

    Detects netsh commands that turns off the Windows firewall

    T1686.003by Fatih Sirin

  • Medium
    Firewall Rule Deleted Via Netsh.EXE

    Detects the removal of a port or application rule in the Windows Firewall configuration using netsh

    T1686.003by frack113

  • Medium
    Firewall 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)

  • Medium
    Harvesting Of Wifi Credentials Via Netsh.EXE

    Detect the harvesting of wifi credentials using netsh.exe

    T1040by Andreas Hunkeler (@Karneades), oscd.community

  • Medium
    Netsh Allow Group Policy on Microsoft Defender Firewall

    Adversaries may modify system firewalls in order to bypass controls limiting network usage

    T1686.003by frack113

  • Medium
    New 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

  • Medium
    New 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

  • Medium
    New 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

  • Medium
    Potential 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)

  • Medium
    Potential 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

  • Low
    Firewall 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.