Latest alertCVE-2018-11776 in Apache Struts Confirmed Exploited in the WildRead
Search all news in the platform

Detection rule

PUA - Ngrok Execution

HighTest-data validatedSigmaHQ (community)T1572

Overview

Detects the use of Ngrok, a utility used for port forwarding and tunneling, often used by threat actors to make local protected services publicly available. Involved domains are bin.equinox.io for download and *.ngrok.io for connections.

Rule id
ee37eb7c-a4e7-4cd5-8fa4-efa27f1c3f31
ATT&CK techniques
T1572 Protocol Tunneling
Severity
High
Confidence
Low
Origin
SigmaHQ (community)
SigmaHQ status
test
Used in defense packs
The Gentlemen, qilin

Validation

  1. ExperimentalSyntax checked only. Not yet tested on events.
  2. Test-data validatedMatched positive test events and ignored near-miss events. Not yet run in a production SIEM.
  3. SIEM-validatedRun in a real SIEM, with a recorded result.

2 of 2 positive test events matched; 1 of 1 near-miss events were correctly ignored. Community rule reused unmodified from SigmaHQ. OffSet7 converted it and tested it on synthetic events.

Detection logic and queries

Queries are shown exactly as generated. Test them in your environment before you deploy them.

Sigma

Sigma (YAML) · ee37eb7c-a4e7-4cd5-8fa4-efa27f1c3f31

Download
title: PUA - Ngrok Execution
id: ee37eb7c-a4e7-4cd5-8fa4-efa27f1c3f31
status: test
description: |
  Detects the use of Ngrok, a utility used for port forwarding and tunneling, often used by threat actors to make local protected services publicly available.
  Involved domains are bin.equinox.io for download and *.ngrok.io for connections.
references:
    - https://ngrok.com/docs
    - https://www.fireeye.com/blog/threat-research/2021/05/shining-a-light-on-darkside-ransomware-operations.html
    - https://stackoverflow.com/questions/42442320/ssh-tunnel-to-ngrok-and-initiate-rdp
    - https://www.virustotal.com/gui/file/58d21840d915aaf4040ceb89522396124c82f325282f805d1085527e1e2ccfa1/detection
    - https://cybleinc.com/2021/02/15/ngrok-platform-abused-by-hackers-to-deliver-a-new-wave-of-phishing-attacks/
    - https://twitter.com/xorJosh/status/1598646907802451969
    - https://www.softwaretestinghelp.com/how-to-use-ngrok/
author: Florian Roth (Nextron Systems)
date: 2021-05-14
modified: 2023-02-21
tags:
    - attack.command-and-control
    - attack.t1572
logsource:
    category: process_creation
    product: windows
detection:
    selection1:
        CommandLine|contains:
            - ' tcp 139'
            - ' tcp 445'
            - ' tcp 3389'
            - ' tcp 5985'
            - ' tcp 5986'
    selection2:
        CommandLine|contains|all:
            - ' start '
            - '--all'
            - '--config'
            - '.yml'
    selection3:
        Image|endswith: 'ngrok.exe'
        CommandLine|contains:
            - ' tcp '
            - ' http '
            - ' authtoken '
    selection4:
        CommandLine|contains:
            - '.exe authtoken '
            - '.exe start --all'
    condition: 1 of selection*
falsepositives:
    - Another tool that uses the command line switches of Ngrok
    - Ngrok http 3978 (https://learn.microsoft.com/en-us/azure/bot-service/bot-service-debug-channel-ngrok?view=azure-bot-service-4.0)
level: high

QRadar AQL

IBM QRadar AQL (hunting query)Hunting query

Hunting search for the Log Activity tab or the API. It is not a QRadar rule.

AQL search for the Log Activity tab or the API. It is NOT a deployable QRadar rule: real-time detection in QRadar is a CRE (Custom Rule Engine) rule, for which this build only writes a design specification (qradar_cre).

SELECT * FROM events WHERE devicetype=12 AND ((LOWER(Command) LIKE '% tcp 139%' OR LOWER(Command) LIKE '% tcp 445%' OR LOWER(Command) LIKE '% tcp 3389%' OR LOWER(Command) LIKE '% tcp 5985%' OR LOWER(Command) LIKE '% tcp 5986%') OR (LOWER(Command) LIKE '% start %' AND LOWER(Command) LIKE '%--all%' AND LOWER(Command) LIKE '%--config%' AND LOWER(Command) LIKE '%.yml%') OR ((LOWER("Process Path") LIKE '%ngrok.exe' OR LOWER("Process Name") LIKE '%ngrok.exe') AND (LOWER(Command) LIKE '% tcp %' OR LOWER(Command) LIKE '% http %' OR LOWER(Command) LIKE '% authtoken %')) OR (LOWER(Command) LIKE '%.exe authtoken %' OR LOWER(Command) LIKE '%.exe start --all%'))

QRadar CRE

Design for the QRadar Rule Wizard. It is not importable and has not been tested in QRadar.

Rule name
OffSet7: PUA - Ngrok Execution
Rule type
Event rule (Local)
Log source types
Microsoft Windows Security Event Log DSM: Security 4688 (with command-line auditing) or Sysmon EID 1

Building blocks

  • BB:OffSet7:PUA Ngrok Execution:selection1 (match)
    All test lines must match (AND).
    • Command contains: tcp 139, tcp 445, tcp 3389, tcp 5985, tcp 5986
  • BB:OffSet7:PUA Ngrok Execution:selection2 (match)
    All test lines must match (AND).
    • Command contains: start, --all, --config, .yml
  • BB:OffSet7:PUA Ngrok Execution:selection3 (match)
    All test lines must match (AND).
    • Process Path / Process Name ends with: ngrok.exe
    • Command contains: tcp, http, authtoken
  • BB:OffSet7:PUA Ngrok Execution:selection4 (match)
    All test lines must match (AND).
    • Command contains: .exe authtoken, .exe start --all

Main rule, option A (building blocks)

  1. when the event(s) were detected by one or more of these log source types: Microsoft Windows Security Event Log DSM: Security 4688 (with command-line auditing) or Sysmon EID 1
  2. when an event matches the condition built from these building blocks: (ANY of [BB:OffSet7:PUA Ngrok Execution:selection1, BB:OffSet7:PUA Ngrok Execution:selection2, BB:OffSet7:PUA Ngrok Execution:selection3, BB:OffSet7:PUA Ngrok Execution:selection4])

Main rule, option B (AQL filter test)

  1. when the event matches this AQL filter query: devicetype=12 AND ((LOWER(Command) LIKE '% tcp 139%' OR LOWER(Command) LIKE '% tcp 445%' OR LOWER(Command) LIKE '% tcp 3389%' OR LOWER(Command) LIKE '% tcp 5985%' OR LOWER(Command) LIKE '% tcp 5986%') OR (LOWER(Command) LIKE '% start %' AND LOWER(Command) LIKE '%--all%' AND LOWER(Command) LIKE '%--config%' AND LOWER(Command) LIKE '%.yml%') OR ((LOWER("Process Path") LIKE '%ngrok.exe' OR LOWER("Process Name") LIKE '%ngrok.exe') AND (LOWER(Command) LIKE '% tcp %' OR LOWER(Command) LIKE '% http %' OR LOWER(Command) LIKE '% authtoken %')) OR (LOWER(Command) LIKE '%.exe authtoken %' OR LOWER(Command) LIKE '%.exe start --all%'))

Rule response

  • Severity 7, credibility 6, relevance 7
  • Ensure the detected event is part of an offense; index offense on Log Source (host) and annotate with the rule title and OffSet7 rule id
  • Respond no more than once per 30 minutes per Log Source (tune per environment)

Limitations

  • QRadar AQL LIKE / CRE string tests are case-sensitive unless the property is lower-cased; the AQL option uses LOWER() where the backend applied it.

Splunk

Splunk SPLSearch

Search for Splunk with Windows/Sysmon field names. A scheduled search or ES correlation search also needs a schedule, time range, throttling and an adaptive response, set in your environment.

CommandLine IN ("* tcp 139*", "* tcp 445*", "* tcp 3389*", "* tcp 5985*", "* tcp 5986*") OR (CommandLine="* start *" CommandLine="*--all*" CommandLine="*--config*" CommandLine="*.yml*") OR (Image="*ngrok.exe" (CommandLine IN ("* tcp *", "* http *", "* authtoken *"))) OR CommandLine IN ("*.exe authtoken *", "*.exe start --all*")

Splunk savedsearches.conf stanzaScheduled search template

Template stanza. Review schedule, alert actions and index/sourcetype for your environment before enabling.

[default]
dispatch.earliest_time = -30d
dispatch.latest_time = now

[PUA - Ngrok Execution]
description = Detects the use of Ngrok, a utility used for port forwarding and tunneling, often used by threat actors to make local protected services publicly available.Involved domains are bin.equinox.io for download and *.ngrok.io for connections.
search = CommandLine IN ("* tcp 139*", "* tcp 445*", "* tcp 3389*", "* tcp 5985*", "* tcp 5986*") OR (CommandLine="* start *" CommandLine="*--all*" CommandLine="*--config*" CommandLine="*.yml*") OR (Image="*ngrok.exe" (CommandLine IN ("* tcp *", "* http *", "* authtoken *"))) OR CommandLine IN ("*.exe authtoken *", "*.exe start --all*")

Microsoft Sentinel

Microsoft Sentinel KQL (ASIM)Hunting query

Hunting query over ASIM-normalized tables. An analytics rule also needs a schedule, entity mapping and alert grouping.

imProcessCreate
| where (TargetProcessCommandLine contains " tcp 139" or TargetProcessCommandLine contains " tcp 445" or TargetProcessCommandLine contains " tcp 3389" or TargetProcessCommandLine contains " tcp 5985" or TargetProcessCommandLine contains " tcp 5986") or (TargetProcessCommandLine contains " start " and TargetProcessCommandLine contains "--all" and TargetProcessCommandLine contains "--config" and TargetProcessCommandLine contains ".yml") or (TargetProcessName endswith "ngrok.exe" and (TargetProcessCommandLine contains " tcp " or TargetProcessCommandLine contains " http " or TargetProcessCommandLine contains " authtoken ")) or (TargetProcessCommandLine contains ".exe authtoken " or TargetProcessCommandLine contains ".exe start --all")

Defender XDR

Microsoft Defender XDR KQLHunting query

Advanced hunting query. A custom detection rule also needs a frequency, impacted entities and actions.

DeviceProcessEvents
| where (ProcessCommandLine contains " tcp 139" or ProcessCommandLine contains " tcp 445" or ProcessCommandLine contains " tcp 3389" or ProcessCommandLine contains " tcp 5985" or ProcessCommandLine contains " tcp 5986") or (ProcessCommandLine contains " start " and ProcessCommandLine contains "--all" and ProcessCommandLine contains "--config" and ProcessCommandLine contains ".yml") or (FolderPath endswith "ngrok.exe" and (ProcessCommandLine contains " tcp " or ProcessCommandLine contains " http " or ProcessCommandLine contains " authtoken ")) or (ProcessCommandLine contains ".exe authtoken " or ProcessCommandLine contains ".exe start --all")

Elastic

Elastic Lucene (ECS)Hunting query

Lucene query over ECS fields (Winlogbeat/Elastic Agent Windows mappings). A detection rule also needs an index pattern, schedule and actions.

(process.command_line:(*\ tcp\ 139* OR *\ tcp\ 445* OR *\ tcp\ 3389* OR *\ tcp\ 5985* OR *\ tcp\ 5986*)) OR (process.command_line:*\ start\ * AND process.command_line:*\-\-all* AND process.command_line:*\-\-config* AND process.command_line:*.yml*) OR (process.executable:*ngrok.exe AND (process.command_line:(*\ tcp\ * OR *\ http\ * OR *\ authtoken\ *))) OR (process.command_line:(*.exe\ authtoken\ * OR *.exe\ start\ \-\-all*))

Elastic EQL (ECS)Hunting query

EQL query over ECS fields. Usable in an Elastic Security EQL rule after review; index pattern and schedule are set per environment.

any where (process.command_line like~ ("* tcp 139*", "* tcp 445*", "* tcp 3389*", "* tcp 5985*", "* tcp 5986*")) or (process.command_line:"* start *" and process.command_line:"*--all*" and process.command_line:"*--config*" and process.command_line:"*.yml*") or (process.executable:"*ngrok.exe" and (process.command_line like~ ("* tcp *", "* http *", "* authtoken *"))) or (process.command_line like~ ("*.exe authtoken *", "*.exe start --all*"))

Elastic ES|QL (ECS)Hunting query

ES|QL query over ECS fields; the FROM clause uses * and must be narrowed to your indices.

from * metadata _id, _index, _version | where process.command_line like "* tcp 139*" or process.command_line like "* tcp 445*" or process.command_line like "* tcp 3389*" or process.command_line like "* tcp 5985*" or process.command_line like "* tcp 5986*" or process.command_line like "* start *" and process.command_line like "*--all*" and process.command_line like "*--config*" and process.command_line like "*.yml*" or ends_with(process.executable, "ngrok.exe") and (process.command_line like "* tcp *" or process.command_line like "* http *" or process.command_line like "* authtoken *") or process.command_line like "*.exe authtoken *" or process.command_line like "*.exe start --all*"

Required telemetry

Log source
product: windows · category: process_creation
Fields used
CommandLine Image

False positives

  • Another tool that uses the command line switches of Ngrok
  • Ngrok http 3978 (https://learn.microsoft.com/en-us/azure/bot-service/bot-service-debug-channel-ngrok?view=azure-bot-service-4.0)

Investigation and response

No OffSet7 investigation guidance has been written for this rule yet. Start from the false positives above and the ATT&CK technique pages.

References

Author and attribution

Author
Florian Roth (Nextron Systems)
Source
SigmaHQ · rules/windows/process_creation/proc_creation_win_pua_ngrok.yml
Upstream commit
9688134317a2
Licence
Detection Rule License (DRL) 1.1

Version history

  1. Version 1Imported from SigmaHQ
  2. OffSet7 build · SigmaHQ 9688134317a2

Related rules