Detection rules › Elastic

RunDLL32/Regsvr32 Loads Dropped Executable

Time window
1m
Source
github.com/elastic/protections-artifacts

Identifies when RunDLL32 or Regsvr32 loads an executable that was dropped by commonly abused programs via phishing such as Microsoft Office or Powershell. An adversary may deliver a weaponized Office document to their target that writes and executes a malicious DLL.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies when RunDLL32 or Regsvr32 loads an executable that was dropped by commonly abused programs via phishing such
as Microsoft Office or Powershell. An adversary may deliver a weaponized Office document to their target that writes and
executes a malicious DLL.
"""
id = "901f0c30-a7c5-40a5-80e3-a50c6744632f"
license = "Elastic License v2"
name = "RunDLL32/Regsvr32 Loads Dropped Executable"
os_list = ["windows"]
reference = [
    "https://www.elastic.co/security-labs/Hunting-for-Suspicious-Windows-Libraries-for-Execution-and-Evasion",
]
version = "1.0.41"

query = '''
sequence with maxspan=1m
  [ file where event.action != "deletion" and
    not user.id : ("S-1-5-18", "S-1-5-19", "S-1-5-20") and
      process.name :
          ("WINWORD.EXE",
           "EXCEL.EXE",
           "POWERPNT.EXE",
           "MSACCESS.EXE",
           "MSHTA.EXE",
           "wscript.exe",
           "CertUtil.exe",
           "CertReq.exe",
           "Cmd.exe",
           "xcopy.exe",
           "curl.exe",
           "powershell.exe") and
      (
        file.extension : ("dll", "cpl", "ocx") or
        // Match Windows PE files by header data (MZ)
        file.Ext.header_bytes : "4d5a*"
      ) and
  not (file.path : ("?:\\oracle\\x86\\bin\\*", "?:\\oracle\\x64\\bin\\*") and process.name : "xcopy.exe") and
  not (process.name : "cmd.exe" and 
      file.path : ("?:\\PROBAS\\*", "?:\\Windows\\SysWOW64\\*", "?:\\Windows\\System32\\*",  "C:\\Development\\Components\\*.dll"))
  ] as event0
  [ library where process.name : ("rundll32.exe", "regsvr32.exe") and
    stringcontains~(dll.path, event0.file.path) and
    not dll.code_signature.trusted == true and not user.id : ("S-1-5-18", "S-1-5-19", "S-1-5-20") and
    not dll.path : ("?:\\Program Files (x86)\\*", "?:\\Program Files\\*") and
    not (dll.pe.original_file_name == "RbkVssProvider.dll" and dll.path : "?:\\Windows\\Temp\\rubrik_vmware*\\RbkVssProvider.dll") and
    not dll.pe.imphash : "7ce8b277ed3218e26a4bab54ca4af843" and
    not dll.hash.sha256 in ("2a95cf7d3189920f30bc35b0ca2ee50097d8b9d959582fee913e3f0125feec3b",
                            "3adc5ac350d41a1c29e900089b09d237374fe4e9c8887dbe75d2ba0af982c798",
                            "76985a241b88f74d6962af99c3f9493a1db234e4633271785ab5759cf8de9a5f",
                            "e40828a0802b3bf759978a7b68b9534c55bf57036de1f872ccbce38ad2afa20b",
                            "27912b78125ffcbef3f7239ab394552b1c0d188a0275f691bfaa87e072795bf9") and
    not (process.name : "regsvr32.exe" and dll.path : "C:\\Oracle\\*.dll")]
'''

min_endpoint_version = "8.4.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 1

[[optional_actions]]
action = "rollback"
field = "process.entity_id"
state = 1

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1566"
name = "Phishing"
reference = "https://attack.mitre.org/techniques/T1566/"
[[threat.technique.subtechnique]]
id = "T1566.001"
name = "Spearphishing Attachment"
reference = "https://attack.mitre.org/techniques/T1566/001/"

[[threat.technique.subtechnique]]
id = "T1566.002"
name = "Spearphishing Link"
reference = "https://attack.mitre.org/techniques/T1566/002/"



[threat.tactic]
id = "TA0001"
name = "Initial Access"
reference = "https://attack.mitre.org/tactics/TA0001/"
[[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.technique.subtechnique]]
id = "T1059.005"
name = "Visual Basic"
reference = "https://attack.mitre.org/techniques/T1059/005/"

[[threat.technique.subtechnique]]
id = "T1059.007"
name = "JavaScript"
reference = "https://attack.mitre.org/techniques/T1059/007/"



[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.010"
name = "Regsvr32"
reference = "https://attack.mitre.org/techniques/T1218/010/"

[[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 = "8.4.0"

Stages and Predicates

Stage 1: file

[ file where event.action != "deletion" and
    not user.id : ("S-1-5-18", "S-1-5-19", "S-1-5-20") and
      process.name :
          ("WINWORD.EXE",
           "EXCEL.EXE",
           "POWERPNT.EXE",
           "MSACCESS.EXE",
           "MSHTA.EXE",
           "wscript.exe",
           "CertUtil.exe",
           "CertReq.exe",
           "Cmd.exe",
           "xcopy.exe",
           "curl.exe",
           "powershell.exe") and
      (
        file.extension : ("dll", "cpl", "ocx") or
        file.Ext.header_bytes : "4d5a*"
      ) and
  not (file.path : ("?:\\oracle\\x86\\bin\\*", "?:\\oracle\\x64\\bin\\*") and process.name : "xcopy.exe") and
  not (process.name : "cmd.exe" and
      file.path : ("?:\\PROBAS\\*", "?:\\Windows\\SysWOW64\\*", "?:\\Windows\\System32\\*",  "C:\\Development\\Components\\*.dll"))
  ] as event0

Stage 2: library

[ library where process.name : ("rundll32.exe", "regsvr32.exe") and
    stringcontains~(dll.path, event0.file.path) and
    not dll.code_signature.trusted == true and not user.id : ("S-1-5-18", "S-1-5-19", "S-1-5-20") and
    not dll.path : ("?:\\Program Files (x86)\\*", "?:\\Program Files\\*") and
    not (dll.pe.original_file_name == "RbkVssProvider.dll" and dll.path : "?:\\Windows\\Temp\\rubrik_vmware*\\RbkVssProvider.dll") and
    not dll.pe.imphash : "7ce8b277ed3218e26a4bab54ca4af843" and
    not dll.hash.sha256 in ("2a95cf7d3189920f30bc35b0ca2ee50097d8b9d959582fee913e3f0125feec3b",
                            "3adc5ac350d41a1c29e900089b09d237374fe4e9c8887dbe75d2ba0af982c798",
                            "76985a241b88f74d6962af99c3f9493a1db234e4633271785ab5759cf8de9a5f",
                            "e40828a0802b3bf759978a7b68b9534c55bf57036de1f872ccbce38ad2afa20b",
                            "27912b78125ffcbef3f7239ab394552b1c0d188a0275f691bfaa87e072795bf9") and
    not (process.name : "regsvr32.exe" and dll.path : "C:\\Oracle\\*.dll")]

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
file.pathstarts_with?:\oracle\x86\bin\, ?:\oracle\x64\bin\excludes:file.path field:"file.path" value:"?:\oracle\x86\bin\" field:"file.path" value:"?:\oracle\x64\bin\"
process.nameeqxcopy.exeexcludes:process.name field:"process.name" value:"xcopy.exe"
file.pathwildcard?:\PROBAS\*, ?:\Windows\SysWOW64\*, ?:\Windows\System32\*, C:\Development\Components\*.dllexcludes:file.path
process.nameeqcmd.exeexcludes:process.name field:"process.name" value:"cmd.exe"
user.ideqS-1-5-18, S-1-5-19, S-1-5-20excludes:user.id field:"user.id" value:"S-1-5-18" field:"user.id" value:"S-1-5-19" field:"user.id" value:"S-1-5-20"
dll.pathwildcard?:\Windows\Temp\rubrik_vmware*\RbkVssProvider.dllexcludes:dll.path field:"dll.path" value:"?:\Windows\Temp\rubrik_vmware*\RbkVssProvider.dll"
dll.pe.original_file_nameeqRbkVssProvider.dllexcludes:dll.pe.original_file_name field:"dll.pe.original_file_name" value:"RbkVssProvider.dll"
dll.pathwildcardC:\Oracle\*.dllexcludes:dll.path field:"dll.path" value:"C:\Oracle\*.dll"
process.nameeqregsvr32.exeexcludes:process.name field:"process.name" value:"regsvr32.exe"
dll.code_signature.trustedeqtrueexcludes:dll.code_signature.trusted field:"dll.code_signature.trusted" value:"true"
dll.hash.sha256in27912b78125ffcbef3f7239ab394552b1c0d188a0275f691bfaa87e072795bf9, 2a95cf7d3189920f30bc35b0ca2ee50097d8b9d959582fee913e3f0125feec3b, 3adc5ac350d41a1c29e900089b09d237374fe4e9c8887dbe75d2ba0af982c798, 76985a241b88f74d6962af99c3f9493a1db234e4633271785ab5759cf8de9a5f, e40828a0802b3bf759978a7b68b9534c55bf57036de1f872ccbce38ad2afa20bexcludes:dll.hash.sha256
dll.pathstarts_with?:\Program Files (x86)\, ?:\Program Files\excludes:dll.path field:"dll.path" value:"?:\Program Files (x86)\" field:"dll.path" value:"?:\Program Files\"
dll.pe.imphasheq7ce8b277ed3218e26a4bab54ca4af843excludes:dll.pe.imphash field:"dll.pe.imphash" value:"7ce8b277ed3218e26a4bab54ca4af843"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
dll.pathcontains
  • event0.file.path (field reference)
field:"ImageLoaded" kind:contains value:"event0.file.path"
event.actionne
  • deletion corpus 86 (elastic 86)
field:"EventType" kind:ne value:"deletion"
file.Ext.header_byteswildcard
  • 4d5a* corpus 46 (elastic 46)
field:"file.Ext.header_bytes" kind:wildcard value:"4d5a*"
file.extensionwildcard
  • cpl corpus 19 (elastic 19)
  • dll corpus 33 (elastic 33)
  • ocx corpus 6 (elastic 6)
field:"file.extension" kind:wildcard
process.namewildcard
  • CertReq.exe corpus 20 (elastic 20)
  • CertUtil.exe corpus 44 (elastic 38, splunk 6)
  • Cmd.exe corpus 121 (elastic 92, splunk 29)
  • EXCEL.EXE corpus 34 (elastic 34)
  • MSACCESS.EXE corpus 19 (elastic 19)
  • MSHTA.EXE corpus 84 (elastic 79, splunk 5)
  • POWERPNT.EXE corpus 31 (elastic 31)
  • WINWORD.EXE corpus 35 (elastic 35)
  • curl.exe corpus 34 (elastic 31, splunk 3)
  • powershell.exe corpus 184 (elastic 140, splunk 44)
  • regsvr32.exe corpus 73 (elastic 68, splunk 5)
  • rundll32.exe corpus 126 (elastic 100, splunk 26)
  • wscript.exe corpus 83 (elastic 82, splunk 1)
  • xcopy.exe corpus 10 (elastic 10)
field:"process_name" kind:wildcard