Suspicious Reconnaissance Activity

Detects suspicious command line activity on Windows systems

Rule Content

- title: Suspicious Reconnaissance Activity
  id: d95de845-b83c-4a9a-8a6a-4fc802ebf6c0
  status: experimental
  description: Detects suspicious command line activity on Windows systems
  author: Florian Roth
  tags:
  - attack.discovery
  - attack.t1087
  logsource:
    category: process_creation
    product: windows
    service: null
  detection:
    selection:
      CommandLine:
      - net group "domain admins" /domain
      - net localgroup administrators
    condition: selection
  fields:
  - CommandLine
  - ParentCommandLine
  falsepositives:
  - Inventory tool runs
  - Penetration tests
  - Administrative activity
  analysis:
    recommendation: Check if the user that executed the commands is suspicious (e.g.
      service accounts, LOCAL_SYSTEM)
  level: medium

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-*', doc_type='doc')

Run Elasticsearch Query


In [ ]:
s = searchContext.query('query_string', query='process_command_line:("net\ group\ \"domain\ admins\"\ \/domain" OR "net\ localgroup\ administrators")')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()