Socat Reverse Shell or Listener Activity


Description

This rule detects the execution of the socat command with suspicious arguments. Attackers may use socat to set up a listener or establish a reverse connection.

Query · eql

process where event.type == "start" and event.action == "exec" and process.name == "socat" and
process.command_line like~ ("*exec*", "*tty*", "*fork*", "*file*", "*open*") and
process.command_line like~ ("*tcp*", "*udp*", "*openssl*") and
not (
  process.command_line like~ ("*127.0.0.1*", "*localhost*", "*/dev/tty*") or
  process.parent.executable in (
    "/usr/bin/wsrep_sst_xtrabackup-v2", "/usr/bin/dumb-init", "/usr/bin/make", "/usr/bin/sudo", "/usr/bin/wsrep_sst_mariabackup",
    "/bin/wsrep_sst_xtrabackup-v2"
  ) or
  process.parent.executable like "/var/lib/docker/*" or
  process.parent.command_line == "runc init" or
  process.parent.command_line like "*/var/tmp/claude-*" or
  process.parent.name in ("kube-apiserver", "apiserver_entrypoint.sh", "start-proxy") or
  (process.working_directory == "/usr/share/epoptes-client" and process.parent.command_line == "epoptes-client") or
  process.parent.args in ("/usr/bin/wsrep_sst_xtrabackup-v2", "/usr/local/share/npm-global/bin/claude", "/root/.acme.sh/acme.sh", "/usr/local/bin/acme.sh") or
  process.args like ("UNIX-CONNECT:/tmp/claude-*.sock", "TCP:*.devops.maintenance.abovecloud.io:443") or
  (
    process.command_line like "socat TCP-LISTEN:*UNIX-CONNECT:/home/*/claude-*.sock" and
    process.args like "UNIX-CONNECT:/home/*/claude-*.sock"
  ) or
  process.command_line == "socat TCP-LISTEN:8081,reuseaddr,fork UNIX-CLIENT:/tmp/spire-agent/public/api.sock"
)
Raw source Socat Reverse Shell or Listener Activity · Elastic TOML
Esc
Published by elastic/protections-artifacts ↗, licensed under Elastic License 2.0 ↗. Reproduced here unmodified.
[rule]
description = """
This rule detects the execution of the socat command with suspicious arguments. Attackers may use socat to set up a
listener or establish a reverse connection.
"""
id = "613da93c-226e-4150-9125-3b476103c0b9"
license = "Elastic License v2"
name = "Socat Reverse Shell or Listener Activity"
os_list = ["linux"]
version = "1.0.17"

query = '''
process where event.type == "start" and event.action == "exec" and process.name == "socat" and
process.command_line like~ ("*exec*", "*tty*", "*fork*", "*file*", "*open*") and
process.command_line like~ ("*tcp*", "*udp*", "*openssl*") and
not (
  process.command_line like~ ("*127.0.0.1*", "*localhost*", "*/dev/tty*") or
  process.parent.executable in (
    "/usr/bin/wsrep_sst_xtrabackup-v2", "/usr/bin/dumb-init", "/usr/bin/make", "/usr/bin/sudo", "/usr/bin/wsrep_sst_mariabackup",
    "/bin/wsrep_sst_xtrabackup-v2"
  ) or
  process.parent.executable like "/var/lib/docker/*" or
  process.parent.command_line == "runc init" or
  process.parent.command_line like "*/var/tmp/claude-*" or
  process.parent.name in ("kube-apiserver", "apiserver_entrypoint.sh", "start-proxy") or
  (process.working_directory == "/usr/share/epoptes-client" and process.parent.command_line == "epoptes-client") or
  process.parent.args in ("/usr/bin/wsrep_sst_xtrabackup-v2", "/usr/local/share/npm-global/bin/claude", "/root/.acme.sh/acme.sh", "/usr/local/bin/acme.sh") or
  process.args like ("UNIX-CONNECT:/tmp/claude-*.sock", "TCP:*.devops.maintenance.abovecloud.io:443") or
  (
    process.command_line like "socat TCP-LISTEN:*UNIX-CONNECT:/home/*/claude-*.sock" and
    process.args like "UNIX-CONNECT:/home/*/claude-*.sock"
  ) or
  process.command_line == "socat TCP-LISTEN:8081,reuseaddr,fork UNIX-CLIENT:/tmp/spire-agent/public/api.sock"
)
'''

min_endpoint_version = "7.15.0"
optional_actions = []
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1059"
name = "Command and Scripting Interpreter"
reference = "https://attack.mitre.org/techniques/T1059/"
[[threat.technique.subtechnique]]
id = "T1059.004"
name = "Unix Shell"
reference = "https://attack.mitre.org/techniques/T1059/004/"



[threat.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1071"
name = "Application Layer Protocol"
reference = "https://attack.mitre.org/techniques/T1071/"


[threat.tactic]
id = "TA0011"
name = "Command and Control"
reference = "https://attack.mitre.org/tactics/TA0011/"

[internal]
min_endpoint_version = "7.15.0"

Detection rules belong to the projects that publish them and remain under their own licenses. This site indexes and links to them; it claims no rights in them.