LoFP LoFP / ngrok is a legitimate development and remote-access utility. approved developers, it administrators, and endpoint-management workflows may run ngrok or use similar command-line parameters. review the process values and documented tunnel use, and tune approved users, hosts, and parent processes as needed.

Techniques

Sample rules

Ngrok Reverse Proxy Usage

Description

This analytic detects ngrok execution on Linux and Windows by process name, regardless of command line, and detects renamed ngrok binaries through combinations of ngrok-specific command-line behavior. The command-line logic correlates authentication setup with TCP tunneling to RDP or SMB ports, identifies configured all-tunnel startup patterns, and recognizes the Invoke-Ngrok wrapper. Threat actors have used ngrok to expose internal services, maintain persistence, move laterally, and proxy command-and-control traffic. Review the collected commands, parent process, user, endpoint, and approved tunnel configuration to determine whether the use is authorized.

Detection logic


| tstats `security_content_summariesonly`
  count min(_time) as firstTime
        max(_time) as lastTime
        values(Processes.action) as action
        values(Processes.original_file_name) as original_file_name
        values(Processes.parent_process) as parent_process
        values(Processes.parent_process_exec) as parent_process_exec
        values(Processes.parent_process_guid) as parent_process_guid
        values(Processes.parent_process_id) as parent_process_id
        values(Processes.parent_process_name) as parent_process_name
        values(Processes.parent_process_path) as parent_process_path
        values(Processes.process) as process
        values(Processes.process_exec) as process_exec
        values(Processes.process_guid) as process_guid
        values(Processes.process_hash) as process_hash
        values(Processes.process_id) as process_id
        values(Processes.process_integrity_level) as process_integrity_level
        values(Processes.process_name) as process_name
        values(Processes.process_path) as process_path
        values(Processes.user_id) as user_id
        values(Processes.vendor_product) as vendor_product
FROM datamodel=Endpoint.Processes WHERE
(
    Processes.process_name IN ("ngrok", "ngrok.exe")
    OR
    Processes.original_file_name IN ("ngrok", "ngrok.exe")
    OR
    Processes.process IN (
        "*-authtoken*",
        "*-config*-region*",
        "*-hostname*-region*",
        "*-protocol*tcp*",
        "*-region*-config*",
        "*-region*-hostname*",
        "*-region*-subdomain*",
        "*-subdomain*-region*",
        "*config add-authtoken*",
        "*fileserver*",
        "*Invoke-Ngrok*",
        "*start*--all*",
        "*tcp *"
    )
)

BY Processes.dest Processes.user _time span=15m


| `drop_dm_object_name(Processes)`


| eval has_ngrok_process_name = if(
    mvfind(process_name, "(?i)^ngrok(\\.exe)?$") >= 0,
    1,
    0
  )


| eval has_ngrok_original_file_name = if(
    mvfind(original_file_name, "(?i)^ngrok(\\.exe)?$") >= 0,
    1,
    0
  )


| eval has_auth_setup = if(
    mvfind(process, "(?i)config\\s+add-authtoken") >= 0
    OR mvfind(process, "(?i)--authtoken(?:\\s
|=)
|-auth(?:\\s
|=)") >= 0,
    1,
    0
  )


| eval has_tcp_tunnel = if(
    mvfind(process, "(?i)\\btcp\\s+(?:3389
|445)\\b") >= 0
    OR mvfind(process, "(?i)-protocol\\s+tcp\\b") >= 0,
    1,
    0
  )


| eval has_sensitive_port = if(
    mvfind(process, "(?i)\\btcp\\s+(?:3389
|445)\\b") >= 0
    OR mvfind(process, "(?i)-port\\s+(?:3389
|445)\\b") >= 0,
    1,
    0
  )


| eval has_start_all = if(
    mvfind(process, "(?i)\\bstart\\b.*--all\\b") >= 0,
    1,
    0
  )


| eval has_config = if(
    mvfind(process, "(?i)--?config(?:\\s
|=)") >= 0,
    1,
    0
  )


| eval has_region = if(
    mvfind(process, "(?i)--?region(?:\\s
|=)") >= 0,
    1,
    0
  )


| eval has_tunnel_command = if(
    mvfind(process, "(?i)\\b(?:http
|tcp
|tls
|start)\\b") >= 0,
    1,
    0
  )


| eval has_endpoint_option = if(
    mvfind(process, "(?i)--?(?:hostname
|subdomain
|url)(?:\\s
|=)") >= 0,
    1,
    0
  )


| eval has_invoke_ngrok = if(
    mvfind(process, "(?i)Invoke-Ngrok") >= 0,
    1,
    0
  )


| eval has_fileserver = if(
    mvfind(process, "(?i)-fileserver(?:\\s
|=)") >= 0,
    1,
    0
  )


| where
    has_ngrok_process_name = 1
    OR has_ngrok_original_file_name = 1
    OR has_start_all = 1
    OR (has_auth_setup = 1 AND has_tcp_tunnel = 1 AND has_sensitive_port = 1)
    OR (has_config = 1 AND has_region = 1 AND has_tunnel_command = 1)
    OR (has_region = 1 AND has_tunnel_command = 1 AND has_endpoint_option = 1)
    OR (has_invoke_ngrok = 1 AND has_fileserver = 1)
    OR (has_fileserver = 1 AND has_auth_setup = 1)


| `security_content_ctime(firstTime)`

| `security_content_ctime(lastTime)`

| `ngrok_reverse_proxy_usage_filter`