Detection rules › Elastic

Command Shell Activity Started via RunDLL32

Source
github.com/elastic/protections-artifacts

Identifies command shell activity started via RunDLL32, which is commonly abused by attackers to host malicious code.

MITRE ATT&CK coverage

Rule body

[rule]
description = "Identifies command shell activity started via RunDLL32, which is commonly abused by attackers to host malicious code."
id = "b8a0a3aa-0345-4035-b41d-f758a6c59a78"
license = "Elastic License v2"
name = "Command Shell Activity Started via RunDLL32"
os_list = ["windows"]
reference = ["https://www.elastic.co/security-labs/spring-cleaning-with-latrodectus"]
version = "1.0.34"

query = '''
process where event.type == "start" and
  process.name : ("cmd.exe", "powershell.exe") and
    process.parent.name : "rundll32.exe" and process.parent.command_line != null and
    not process.parent.command_line :
                    ("*:\\Windows\\System32\\SHELL32.dll,RunAsNewUser_RunDLL*",
                     "*zzzzInvokeManagedCustomActionOutOfProc*", 
                     "\"C:\\WINDOWS\\system32\\rundll32.exe\" C:\\WINDOWS\\system32\\PcaSvc.dll,PcaPatchSdbTask") and
    not (process.parent.args : "aepdu.dll,AePduRunUpdate" and process.args : "osloader" and process.args : "%windir%\\system32\\bcdedit") and
    not (process.parent.args : ("?:\\Windows\\System32\\LogiLDA.dll,LogiFetch", "?:\\WINDOWS\\system32\\PcaSvc.dll,PcaPatchSdbTask") and
         process.name : "powershell.exe" and process.command_line : "*install*") and
    not process.parent.args : "C:\\Program Files\\NVIDIA Corporation\\*\\NVI2.DLL,ResumeAsync" and
    not (process.args : "dellpointstick://Mainpage/*" and process.parent.args : "Vxd_launch_UI") and
    not (process.parent.args : "?:\\Windows\\system32\\davclnt.dll,DavSetCookie" and process.name : "powershell.exe") and
    not process.parent.args : "AppXDeploymentExtensions.OneCore.dll,ShellRefresh" and
    not (process.args : ("launchalpsdelltouchpad://Mainpage/path2?param=start", "alpsdelltouchpadsettings://Mainpage/path2?param=start") and
         process.parent.args : "?:\\WINDOWS\\System32\\main.cpl") and
    not (process.command_line : "*REG QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography*" and
         process.parent.args : "?:\\WINDOWS\\system32\\PcaSvc.dll,PcaPatchSdbTask") and
    not (process.args : "launchalpsdelltouchpad://Mainpage/path2?param=start" and process.parent.args : "Vxd_launch_UI") and 
    not (process.working_directory : "C:\\Program Files (x86)\\Windows Kits\\*\\Assessment and Deployment Kit\\Windows Assessment Toolkit\\Energy\\" and 
         process.args : "axecore.dll,RunJob_RunDll") and
    not process.parent.command_line :  "rundll32.exe \"C:\\Program Files (x86)\\Windows Shell\\fx_ws_main.dll\",ProcessDll s=hidedialog" and
    not (process.parent.command_line : "C:\\Windows\\system32\\rundll32.exe iernonce.dll,RunOnceExProcess" and
         process.working_directory : "C:\\Windows\\system32\\") and
    not (process.parent.command_line : "\"C:\\WINDOWS\\System32\\rundll32.exe\" C:\\WINDOWS\\Lvgic10u.dll,Execute" and
         process.command_line : "cmd /c C:\\WINDOWS\\System32\\rundll32.exe C:\\WINDOWS\\Lvgic10u.dll,ExecuteQuick")
'''

min_endpoint_version = "7.15.0"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1059"
name = "Command and Scripting Interpreter"
reference = "https://attack.mitre.org/techniques/T1059/"
[[threat.technique.subtechnique]]
id = "T1059.001"
name = "PowerShell"
reference = "https://attack.mitre.org/techniques/T1059/001/"

[[threat.technique.subtechnique]]
id = "T1059.003"
name = "Windows Command Shell"
reference = "https://attack.mitre.org/techniques/T1059/003/"



[threat.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1218"
name = "System Binary Proxy Execution"
reference = "https://attack.mitre.org/techniques/T1218/"
[[threat.technique.subtechnique]]
id = "T1218.011"
name = "Rundll32"
reference = "https://attack.mitre.org/techniques/T1218/011/"



[threat.tactic]
id = "TA0005"
name = "Defense Evasion"
reference = "https://attack.mitre.org/tactics/TA0005/"

[internal]
min_endpoint_version = "7.15.0"

Stages and Predicates

Stage 1: process

process where event.type == "start" and
  process.name : ("cmd.exe", "powershell.exe") and
    process.parent.name : "rundll32.exe" and process.parent.command_line != null and
    not process.parent.command_line :
                    ("*:\\Windows\\System32\\SHELL32.dll,RunAsNewUser_RunDLL*",
                     "*zzzzInvokeManagedCustomActionOutOfProc*", 
                     "\"C:\\WINDOWS\\system32\\rundll32.exe\" C:\\WINDOWS\\system32\\PcaSvc.dll,PcaPatchSdbTask") and
    not (process.parent.args : "aepdu.dll,AePduRunUpdate" and process.args : "osloader" and process.args : "%windir%\\system32\\bcdedit") and
    not (process.parent.args : ("?:\\Windows\\System32\\LogiLDA.dll,LogiFetch", "?:\\WINDOWS\\system32\\PcaSvc.dll,PcaPatchSdbTask") and
         process.name : "powershell.exe" and process.command_line : "*install*") and
    not process.parent.args : "C:\\Program Files\\NVIDIA Corporation\\*\\NVI2.DLL,ResumeAsync" and
    not (process.args : "dellpointstick://Mainpage/*" and process.parent.args : "Vxd_launch_UI") and
    not (process.parent.args : "?:\\Windows\\system32\\davclnt.dll,DavSetCookie" and process.name : "powershell.exe") and
    not process.parent.args : "AppXDeploymentExtensions.OneCore.dll,ShellRefresh" and
    not (process.args : ("launchalpsdelltouchpad://Mainpage/path2?param=start", "alpsdelltouchpadsettings://Mainpage/path2?param=start") and
         process.parent.args : "?:\\WINDOWS\\System32\\main.cpl") and
    not (process.command_line : "*REG QUERY HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Cryptography*" and
         process.parent.args : "?:\\WINDOWS\\system32\\PcaSvc.dll,PcaPatchSdbTask") and
    not (process.args : "launchalpsdelltouchpad://Mainpage/path2?param=start" and process.parent.args : "Vxd_launch_UI") and 
    not (process.working_directory : "C:\\Program Files (x86)\\Windows Kits\\*\\Assessment and Deployment Kit\\Windows Assessment Toolkit\\Energy\\" and 
         process.args : "axecore.dll,RunJob_RunDll") and
    not process.parent.command_line :  "rundll32.exe \"C:\\Program Files (x86)\\Windows Shell\\fx_ws_main.dll\",ProcessDll s=hidedialog" and
    not (process.parent.command_line : "C:\\Windows\\system32\\rundll32.exe iernonce.dll,RunOnceExProcess" and
         process.working_directory : "C:\\Windows\\system32\\") and
    not (process.parent.command_line : "\"C:\\WINDOWS\\System32\\rundll32.exe\" C:\\WINDOWS\\Lvgic10u.dll,Execute" and
         process.command_line : "cmd /c C:\\WINDOWS\\System32\\rundll32.exe C:\\WINDOWS\\Lvgic10u.dll,ExecuteQuick")

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.argseq%windir%\system32\bcdeditexcludes:process.args field:"process.args" value:"%windir%\system32\bcdedit"
process.argseqosloaderexcludes:process.args field:"process.args" value:"osloader"
process.parent.argseqaepdu.dll,AePduRunUpdateexcludes:process.parent.args field:"process.parent.args" value:"aepdu.dll,AePduRunUpdate"
process.argseqaxecore.dll,RunJob_RunDllexcludes:process.args field:"process.args" value:"axecore.dll,RunJob_RunDll"
process.working_directorywildcardC:\Program Files (x86)\Windows Kits\*\Assessment and Deployment Kit\Windows Assessment Toolkit\Energy\excludes:process.working_directory field:"process.working_directory" value:"C:\Program Files (x86)\Windows Kits\*\Assessment and Deployment Kit\Windows Assessment Toolkit\Energy\"
process.argseqlaunchalpsdelltouchpad://Mainpage/path2?param=start, alpsdelltouchpadsettings://Mainpage/path2?param=startexcludes:process.args field:"process.args" value:"launchalpsdelltouchpad://Mainpage/path2?param=start" field:"process.args" value:"alpsdelltouchpadsettings://Mainpage/path2?param=start"
process.parent.argseq?:\WINDOWS\System32\main.cplexcludes:process.parent.args field:"process.parent.args" value:"?:\WINDOWS\System32\main.cpl"
process.argseqlaunchalpsdelltouchpad://Mainpage/path2?param=startexcludes:process.args field:"process.args" value:"launchalpsdelltouchpad://Mainpage/path2?param=start"
process.parent.argseqVxd_launch_UIexcludes:process.parent.args field:"process.parent.args" value:"Vxd_launch_UI"
process.argsstarts_withdellpointstick://Mainpage/excludes:process.args field:"process.args" value:"dellpointstick://Mainpage/"
process.command_lineeqcmd /c C:\WINDOWS\System32\rundll32.exe C:\WINDOWS\Lvgic10u.dll,ExecuteQuickexcludes:process.command_line field:"process.command_line" value:"cmd /c C:\WINDOWS\System32\rundll32.exe C:\WINDOWS\Lvgic10u.dll,ExecuteQuick"
process.parent.command_lineeq"C:\WINDOWS\System32\rundll32.exe" C:\WINDOWS\Lvgic10u.dll,Executeexcludes:process.parent.command_line
process.command_linematchREG QUERY HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptographyexcludes:process.command_line field:"process.command_line" value:"REG QUERY HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography"
process.parent.argseq?:\WINDOWS\system32\PcaSvc.dll,PcaPatchSdbTaskexcludes:process.parent.args field:"process.parent.args" value:"?:\WINDOWS\system32\PcaSvc.dll,PcaPatchSdbTask"
process.command_linematchinstallexcludes:process.command_line field:"process.command_line" value:"install"
process.nameeqpowershell.exeexcludes:process.name field:"process.name" value:"powershell.exe"
process.parent.argseq?:\Windows\System32\LogiLDA.dll,LogiFetch, ?:\WINDOWS\system32\PcaSvc.dll,PcaPatchSdbTaskexcludes:process.parent.args field:"process.parent.args" value:"?:\Windows\System32\LogiLDA.dll,LogiFetch" field:"process.parent.args" value:"?:\WINDOWS\system32\PcaSvc.dll,PcaPatchSdbTask"
process.parent.argseq?:\Windows\system32\davclnt.dll,DavSetCookieexcludes:process.parent.args field:"process.parent.args" value:"?:\Windows\system32\davclnt.dll,DavSetCookie"
process.parent.command_lineeqC:\Windows\system32\rundll32.exe iernonce.dll,RunOnceExProcessexcludes:process.parent.command_line field:"process.parent.command_line" value:"C:\Windows\system32\rundll32.exe iernonce.dll,RunOnceExProcess"
process.working_directoryeqC:\Windows\system32\excludes:process.working_directory field:"process.working_directory" value:"C:\Windows\system32\"
process.parent.argseqAppXDeploymentExtensions.OneCore.dll,ShellRefreshexcludes:process.parent.args field:"process.parent.args" value:"AppXDeploymentExtensions.OneCore.dll,ShellRefresh"
process.parent.argswildcardC:\Program Files\NVIDIA Corporation\*\NVI2.DLL,ResumeAsyncexcludes:process.parent.args field:"process.parent.args" value:"C:\Program Files\NVIDIA Corporation\*\NVI2.DLL,ResumeAsync"
process.parent.command_lineeqrundll32.exe "C:\Program Files (x86)\Windows Shell\fx_ws_main.dll",ProcessDll s=hidedialogexcludes:process.parent.command_line
process.parent.command_linewildcard*:\Windows\System32\SHELL32.dll,RunAsNewUser_RunDLL*, *zzzzInvokeManagedCustomActionOutOfProc*, "C:\WINDOWS\system32\rundll32.exe" C:\WINDOWS\system32\PcaSvc.dll,PcaPatchSdbTaskexcludes:process.parent.command_line

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.typeeq
  • start corpus 1078 (elastic 1078)
field:"event.type" kind:eq value:"start"
process.namewildcard
  • cmd.exe corpus 121 (elastic 92, splunk 29)
  • powershell.exe corpus 184 (elastic 140, splunk 44)
field:"process_name" kind:wildcard
process.parent.command_lineis_not_null
  • (no value, null check)
field:"ParentCommandLine" kind:is_not_null
process.parent.namewildcard
  • rundll32.exe corpus 20 (elastic 20)
field:"parent_process_name" kind:wildcard value:"rundll32.exe"