Skip to content

Netsh Helper DLLs: Persistence Through netsh.exe

How a DLL registered as a netsh helper runs every time netsh.exe starts, how attackers add and trigger one, and how to find and remove it without loading it.

MITRE ATT&CK
T1546.007
Tactics
Persistence, Privilege escalation
Runs
When a program starts
Set up by
Administrators
Locations
  • HKLM\SOFTWARE\Microsoft\NetSh
  • HKLM\SOFTWARE\WOW6432Node\Microsoft\NetSh
  • C:\Windows\System32
  • C:\Windows\SysWOW64

How it works

netsh.exe is the network shell. Its contexts (interface, advfirewall, wlan, http and the rest) are not built in: each comes from a helper DLL. Every time netsh.exe starts, it reads the list of helpers in HKLM\SOFTWARE\Microsoft\NetSh, loads each DLL and calls its InitHelperDll export so the helper can register its contexts. This happens before netsh looks at its command line, so netsh /? loads every helper too.

A DLL added to that list therefore runs inside every netsh.exe process, with the rights of whoever started it. The trigger is neither boot nor logon but any run of netsh: by an administrator, a login script, an installer, a VPN client, management software or a scheduled task. On many machines something runs netsh regularly as SYSTEM, which turns the helper into quiet SYSTEM persistence. On others netsh never runs and the helper waits.

Microsoft now recommends PowerShell over netsh for network management, but netsh.exe still ships with every Windows 10 and 11 release and is still called by a lot of software. ATT&CK tracks the technique as T1546.007.

Where it lives

KeyRead byStock content
HKLM\SOFTWARE\Microsoft\NetShC:\Windows\System32\netsh.exe (64-bit)About twenty values, each a bare DLL name in System32
HKLM\SOFTWARE\WOW6432Node\Microsoft\NetShC:\Windows\SysWOW64\netsh.exe (32-bit)Same idea, for 32-bit helpers

Each value's name is the helper's name and its data the DLL. On Windows 10 and 11 the data are bare file names such as ifmon.dll, rasmontr.dll, authfwcfg.dll, dhcpcmonitor.dll, dot3cfg.dll, fwcfg.dll, nshhttp.dll, nshipsec.dll, nshwfp.dll, wlancfg.dll, wshelper.dll and wwancfg.dll, resolved in System32 (or SysWOW64 for 32-bit netsh). Server roles add their own; Microsoft's netsh documentation names dhcpmon.dll for the DHCP Server role.

Which list applies depends on the caller. A 64-bit process that runs netsh gets the 64-bit program and the first key. A 32-bit program, such as an older VPN client or installer, is redirected to SysWOW64\netsh.exe, which reads the WOW6432Node key. An attacker who knows which software calls netsh can place the helper in the list that software will load.

Only administrators and SYSTEM can write either key. netsh add helper <dll> writes a value, netsh delete helper <dll> removes one and netsh show helper lists them; all three run netsh, so all three load every helper.

How attackers use it

Registration takes one command from an elevated prompt, either through netsh itself or straight into the registry:

netsh add helper C:\ProgramData\Microsoft\Network\nethlp.dll
reg add HKLM\SOFTWARE\Microsoft\NetSh /v nethlp /t REG_SZ /d nethlp.dll /f

The DLL exports InitHelperDll, starts its payload on a new thread or in a new process, and returns success so that netsh behaves normally. Public proof-of-concept helpers that start a command-and-control beacon exist; MITRE's page lists no named malware family, only netsh itself.

The helper needs a trigger, and attackers rarely leave that to chance. A common pairing is a scheduled task that runs a harmless-looking command as SYSTEM, such as netsh interface show interface every hour: the task looks like monitoring, and the payload sits in a DLL the task never names. Other triggers are already in place on many hosts: VPN clients and configuration scripts that call netsh.

Disguises: a bare file name dropped in System32 next to the real helpers, a name that reads like a network component (nshsvc.dll, netcfgh.dll), a value name copied from a stock helper with a digit added, and the 32-bit key, which fewer people check.

How to check a host

Read the registry; do not run netsh on a suspect host, since even netsh show helper loads the malicious DLL once more.

reg query HKLM\SOFTWARE\Microsoft\NetSh
reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\NetSh
Get-ItemProperty HKLM:\SOFTWARE\Microsoft\NetSh
Get-AuthenticodeSignature C:\Windows\System32\nethlp.dll
Get-ScheduledTask | Where-Object { $_.Actions.Execute -match 'netsh' } | Select-Object TaskPath, TaskName

Each value should be a bare name of a DLL signed by Microsoft or by the vendor of an installed product. A full path, a DLL outside System32 and SysWOW64, or an unsigned file is a finding.

Offline, read Microsoft\NetSh and WOW6432Node\Microsoft\NetSh from the SOFTWARE hive (C:\Windows\System32\config\SOFTWARE). The key's last-write time is the last time any value in it changed; compare it with the DLL's creation time. Prefetch shows when NETSH.EXE ran and which DLLs it loaded, and the task, service or script that started it tells you how the helper is triggered.

Telemetry: Sysmon event 7 for netsh.exe loading a DLL not signed by Microsoft, event 1 (or Security log 4688) for netsh's parent process, event 13 for a new value under NetSh, and Security log 4657 when auditing is set on the key.

What Windows Persistence flags

parseNetshHelpers reads every value of Microsoft\NetSh and WOW6432Node\Microsoft\NetSh in the SOFTWARE hive and lists one entry per value, as firing when a program (netsh) starts.

A bare name is resolved in System32 for the first key and in SysWOW64 for the WOW6432Node key, as netsh does. A value whose data is a bare file name from Windows' known helper set, which includes the DHCP Server role's dhcpmon.dll and helpers of older Windows releases, is marked as a Windows default; "Hide Windows entries" hides it unless something else flags it. Anything else, including any full path, raises Unknown netsh helper DLL (high).

The path rules run on the DLL: System-wide autostart from a writable folder, Runs from a temporary or public folder, Windows program name in the wrong place, Name one letter away from a Windows program, Machine-made name and Runs from a network share. Cross-checks add Written date (the key changed in the 7 days before the newest time seen on that host), Inside a Defender exclusion (exclusion) and program also runs from mechanisms for DLLs outside Windows' folders.

Limits: a bare name is checked against a list of names, not against the file, so a malicious ifmon.dll planted in place of the real one passes. Helpers that other server roles or vendors add are not in the list and will be flagged; confirm them against the installed roles and software. The tool cannot tell whether or how often netsh runs: check Prefetch and the scheduled tasks it lists.

Cleaning up

  1. Preserve: reg export HKLM\SOFTWARE\Microsoft\NetSh netsh.reg (and the WOW6432Node key), then copy the DLL with its timestamps and hash it.
  2. Remove the value with reg delete HKLM\SOFTWARE\Microsoft\NetSh /v nethlp /f rather than netsh delete helper, which loads the DLL one more time.
  3. End any running netsh.exe and whatever process the payload started, then delete the DLL.
  4. Remove the trigger: the scheduled task, service or script that ran netsh for the attacker. Leave software that legitimately calls netsh alone.
  5. Never delete Windows' own helper values; the matching netsh contexts disappear and scripts that use them fail.
  6. The payload ran as whoever ran netsh, often SYSTEM: look for further persistence, new accounts and credential theft, and reset exposed credentials.

See also

On Windows Forensics

The artifacts behind this technique, in the Windows Forensics reference: