Detect Netsh Helper DLL in Splunk
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.
MITRE ATT&CK
- Tactic
- Privilege Escalation Persistence
- Technique
- T1546 Event Triggered Execution
- Sub-technique
- T1546.007 Netsh Helper DLL
- Canonical reference
- https://attack.mitre.org/techniques/T1546/007/
SPL Detection Query
index=wineventlog (sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" OR sourcetype="WinEventLog:Security")
| eval IsNetshReg=case(
(EventCode=12 OR EventCode=13) AND match(TargetObject, "SOFTWARE\\\\Microsoft\\\\NetSh"), 1,
1=1, 0
)
| eval IsNetshExec=case(
EventCode=1 AND match(Image, "netsh\.exe"), 1,
EventCode=4688 AND match(NewProcessName, "netsh\.exe"), 1,
1=1, 0
)
| eval IsSuspiciousDll=if(
IsNetshReg=1 AND NOT match(Details, "(?i)(windows\\\\system32|syswow64)"), 1, 0
)
| where IsNetshReg=1 OR IsNetshExec=1
| eval DetectionType=case(
IsSuspiciousDll=1, "NETSH_SUSPICIOUS_DLL_REGISTERED",
IsNetshReg=1, "NETSH_DLL_REGISTERED",
IsNetshExec=1, "NETSH_EXECUTED",
1=1, "UNKNOWN"
)
| table _time, host, User, EventCode, DetectionType, TargetObject, Details, Image, CommandLine
| sort - _time Detects Netsh helper DLL registration and execution using Sysmon Registry events and process creation logs. Monitors HKLM\SOFTWARE\Microsoft\NetSh for any new DLL path additions. Correlates DLL registration events with subsequent netsh.exe executions on the same host to identify when the persisted DLL would load. Non-system DLL paths in the NetSh registry key are flagged as highest priority.
Data Sources
Required Sourcetypes
False Positives & Tuning
- Third-party network management software with custom netsh helpers
- Windows network configuration components during system updates
- Security monitoring products hooking netsh
- VPN/network filter software adding netsh helpers
Other platforms for T1546.007
Testing Methodology
Validate this detection against 3 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1Register Malicious Helper DLL in NetSh Registry
Expected signal: Sysmon Event ID 13 (Registry Value Set): TargetObject=HKLM\SOFTWARE\Microsoft\NetSh\ArgusTestHelper, Details=C:\Users\Public\argus_helper.dll. Security Event ID 4657 if registry auditing enabled. Process creation for reg.exe with add arguments.
- Test 2Register Helper via netsh Command
Expected signal: Process creation for netsh.exe with 'add helper' arguments. Sysmon Event ID 13 for the resulting registry modification to HKLM\SOFTWARE\Microsoft\NetSh. The netsh.exe itself making the registry change is a valid detection path.
- Test 3Create and Register Functional Helper DLL
Expected signal: Process creation for powershell.exe using Add-Type. File creation event for netsh_test_helper.dll in Public folder. Sysmon Event ID 13 for NetSh registry key modification. The DLL in a user-writable path (Public) registered in NetSh is the highest-confidence indicator.
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.