Possible Impacket SecretDump remote activity

Detect AD credential dumping using impacket secretdump HKTL

Rule Content

- title: Possible Impacket SecretDump remote activity
  id: 252902e3-5830-4cf6-bf21-c22083dfd5cf
  description: Detect AD credential dumping using impacket secretdump HKTL
  author: Samir Bousseaden
  references:
  - https://blog.menasec.net/2019/02/threat-huting-10-impacketsecretdump.html
  tags:
  - attack.credential_access
  - attack.t1003
  logsource:
    product: windows
    service: security
    description: The advanced audit policy setting "Object Access > Audit Detailed
      File Share" must be configured for Success/Failure
    category: null
  detection:
    selection:
      EventID: 5145
      ShareName: \\*\ADMIN$
      RelativeTargetName: SYSTEM32\\*.tmp
    condition: selection
  falsepositives:
  - pentesting
  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-security-*', doc_type='doc')

Run Elasticsearch Query


In [ ]:
s = searchContext.query('query_string', query='(event_id:"5145" AND share_name.keyword:\\*\\ADMIN$ AND share_relative_target_name.keyword:SYSTEM32\\*.tmp)')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()