Netsh Helper DLL
Adversaries may establish persistence by executing malicious content triggered by Netsh commands. Netsh.exe (also referred to as network shell) is a Windows command-line scripting utility that interacts with the network configuration of a system. Netsh contains functionality to add helper DLLs for extending functionality of the built-in tool. The paths to registered netsh helper DLLs are entered into the Windows Registry at HKLM\SOFTWARE\Microsoft\NetSh. Adversaries can use netsh.exe helper DLLs to trigger execution of arbitrary code in a trusted process (netsh.exe) whenever netsh.exe is executed, which may also provide privilege escalation if netsh.exe runs elevated.
let NetshDllRegistration = DeviceRegistryEvents
| where Timestamp > ago(24h)
| where RegistryKey has "SOFTWARE\\Microsoft\\NetSh"
| where ActionType in ("RegistryValueSet", "RegistryKeyCreated")
| extend NewDllPath = RegistryValueData
| extend IsSystemDll = RegistryValueData has_any (
"C:\\Windows\\system32\\",
"C:\\Windows\\SysWOW64\\"
)
| where not IsSystemDll
| project RegistryTime=Timestamp, DeviceName, AccountName, RegistryKey,
RegistryValueName, NewDllPath, IsSystemDll,
InitiatingProcessFileName, InitiatingProcessCommandLine;
let NetshExecution = DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName =~ "netsh.exe"
| project NetshTime=Timestamp, DeviceName, AccountName, ProcessCommandLine,
InitiatingProcessFileName;
NetshDllRegistration
| union (NetshExecution | extend RegistryTime=NetshTime, NewDllPath="", IsSystemDll=false,
RegistryKey="netsh_execution", RegistryValueName="", RegistryValueData="")
| sort by RegistryTime desc Data Sources
Required Tables
False Positives
- Third-party network management software that legitimately extends netsh functionality with custom helper DLLs (rare but possible for enterprise network tools)
- Windows network configuration components that register helper DLLs during system updates or feature installations (these should be in System32)
- Security monitoring products that hook netsh as a monitoring mechanism
- VPN or network filter driver software that adds netsh helpers for network configuration commands
References (4)
- https://attack.mitre.org/techniques/T1546/007/
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1546.007/T1546.007.md
- https://www.fireeye.com/blog/threat-research/2017/05/fin7-shim-databases-persistence.html
- https://docs.microsoft.com/en-us/windows-server/networking/technologies/netsh/netsh-contexts
Unlock Pro Content
Get the full detection package for T1546.007 including response playbook, investigation guide, and atomic red team tests.