Ping Hex IP

Detects a ping command that uses a hex encoded IP address

Rule Content

- title: Ping Hex IP
  id: 1a0d4aba-7668-4365-9ce4-6d79ab088dfd
  description: Detects a ping command that uses a hex encoded IP address
  references:
  - https://github.com/vysec/Aggressor-VYSEC/blob/master/ping.cna
  - https://twitter.com/vysecurity/status/977198418354491392
  author: Florian Roth
  date: 2018/03/23
  tags:
  - attack.defense_evasion
  - attack.t1140
  - attack.t1027
  logsource:
    category: process_creation
    product: windows
    service: null
  detection:
    selection:
      CommandLine:
      - '*\ping.exe 0x*'
      - '*\ping 0x*'
    condition: selection
  fields:
  - ParentCommandLine
  falsepositives:
  - Unlikely, because no sane admin pings IP addresses in a hexadecimal form
  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-*', doc_type='doc')

Run Elasticsearch Query


In [ ]:
s = searchContext.query('query_string', query='process_command_line.keyword:(*\\ping.exe\ 0x* OR *\\ping\ 0x*)')
response = s.execute()
if response.success():
    df = pd.DataFrame((d.to_dict() for d in s.scan()))

Show Results


In [ ]:
df.head()