PowerShell Rundll32 Remote Thread Creation

Detects PowerShell remote thread creation in Rundll32.exe

Rule Content

- title: PowerShell Rundll32 Remote Thread Creation
  id: 99b97608-3e21-4bfe-8217-2a127c396a0e
  status: experimental
  description: Detects PowerShell remote thread creation in Rundll32.exe
  author: Florian Roth
  references:
  - https://www.fireeye.com/blog/threat-research/2018/06/bring-your-own-land-novel-red-teaming-technique.html
  date: 2018/06/25
  logsource:
    product: windows
    service: sysmon
    category: null
  detection:
    selection:
      EventID: 8
      SourceImage: '*\powershell.exe'
      TargetImage: '*\rundll32.exe'
    condition: selection
  tags:
  - attack.defense_evasion
  - attack.execution
  - attack.t1085
  - attack.t1086
  falsepositives:
  - Unkown
  level: high

Querying Elasticsearch

Import Libraries


In [ ]:
from elasticsearch import Elasticsearch
from elasticsearch_dsl import Search
import pandas as pd

Initialize Elasticsearch client


In [ ]:
es = Elasticsearch(['http://helk-elasticsearch:9200'])
searchContext = Search(using=es, index='logs-endpoint-winevent-sysmon-*', doc_type='doc')

Run Elasticsearch Query


In [ ]:
s = searchContext.query('query_string', query='(event_id:"8" AND process_path.keyword:*\\powershell.exe AND target_process_path.keyword:*\\rundll32.exe)')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()