Netsh

Allow Incoming Connections by Port or Application on Windows Firewall

Rule Content

- title: Netsh
  id: cd5cfd80-aa5f-44c0-9c20-108c4ae12e3c
  description: Allow Incoming Connections by Port or Application on Windows Firewall
  references:
  - https://attack.mitre.org/software/S0246/ (Lazarus HARDRAIN)
  - https://www.operationblockbuster.com/wp-content/uploads/2016/02/Operation-Blockbuster-RAT-and-Staging-Report.pdf
  date: 2019/01/29
  tags:
  - attack.lateral_movement
  - attack.command_and_control
  - attack.t1090
  status: experimental
  author: Markus Neis
  logsource:
    category: process_creation
    product: windows
    service: null
  detection:
    selection:
      CommandLine:
      - '*netsh firewall add*'
    condition: selection
  falsepositives:
  - Legitimate administration
  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.keyword:(*netsh\ firewall\ add*)')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()