Potential Reverse Shell via Suspicious Binary

This detection rule detects the creation of a shell through a chain consisting of the execution of a suspicious binary (located in a commonly abused location or executed manually) followed by a network event and ending with a shell being spawned. Stageless reverse tcp shells display this behaviour. Attackers may spawn reverse shells to establish persistence onto a target system.

Elastic rule (View on GitHub)

 1[metadata]
 2creation_date = "2023/07/05"
 3integration = ["endpoint"]
 4maturity = "production"
 5min_stack_comments = "New fields added: required_fields, related_integrations, setup"
 6min_stack_version = "8.3.0"
 7updated_date = "2023/08/10"
 8
 9[rule]
10author = ["Elastic"]
11description = """
12This detection rule detects the creation of a shell through a chain consisting of the execution of a suspicious binary
13(located in a commonly abused location or executed manually) followed by a network event and ending with a shell being
14spawned. Stageless reverse tcp shells display this behaviour. Attackers may spawn reverse shells to establish 
15persistence onto a target system.
16"""
17from = "now-9m"
18index = ["logs-endpoint.events.*"]
19language = "eql"
20license = "Elastic License v2"
21name = "Potential Reverse Shell via Suspicious Binary"
22references = [
23    "https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md"
24]
25risk_score = 47
26rule_id = "fa3a59dc-33c3-43bf-80a9-e8437a922c7f"
27severity = "medium"
28tags = ["Domain: Endpoint", "OS: Linux", "Use Case: Threat Detection", "Tactic: Execution", "Data Source: Elastic Defend"]
29type = "eql"
30query = '''
31sequence by host.id, process.entity_id with maxspan=1s
32[ process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and
33  process.executable : (
34  "./*", "/tmp/*", "/var/tmp/*", "/var/www/*", "/dev/shm/*", "/etc/init.d/*", "/etc/rc*.d/*",
35  "/etc/crontab", "/etc/cron.*", "/etc/update-motd.d/*", "/usr/lib/update-notifier/*",
36  "/boot/*", "/srv/*", "/run/*", "/root/*", "/etc/rc.local"
37   ) and
38  process.parent.name : ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and not
39  process.name : ("curl", "wget", "ping", "apt", "dpkg", "yum", "rpm", "dnf", "dockerd") ]
40[ network where host.os.type == "linux" and event.type == "start" and event.action in ("connection_attempted", "connection_accepted") and
41  process.executable : (
42  "./*", "/tmp/*", "/var/tmp/*", "/var/www/*", "/dev/shm/*", "/etc/init.d/*", "/etc/rc*.d/*",
43  "/etc/crontab", "/etc/cron.*", "/etc/update-motd.d/*", "/usr/lib/update-notifier/*",
44  "/boot/*", "/srv/*", "/run/*", "/root/*", "/etc/rc.local"
45   ) and destination.ip != null and destination.ip != "127.0.0.1" and destination.ip != "::1" ]
46[ process where host.os.type == "linux" and event.action == "exec" and event.type == "start" and 
47  process.name : ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") and 
48  process.parent.name : ("bash", "dash", "sh", "tcsh", "csh", "zsh", "ksh", "fish") ]
49'''
50
51[[rule.threat]]
52framework = "MITRE ATT&CK"
53
54[rule.threat.tactic]
55name = "Execution"
56id = "TA0002"
57reference = "https://attack.mitre.org/tactics/TA0002/"
58
59[[rule.threat.technique]]
60id = "T1059"
61name = "Command and Scripting Interpreter"
62reference = "https://attack.mitre.org/techniques/T1059/"
63
64[[rule.threat.technique.subtechnique]]
65id = "T1059.004"
66name = "Unix Shell"
67reference = "https://attack.mitre.org/techniques/T1059/004/"
68
69[[rule.threat]]
70framework = "MITRE ATT&CK"
71
72[rule.threat.tactic]
73name = "Command and Control"
74id = "TA0011"
75reference = "https://attack.mitre.org/tactics/TA0011/"
76
77[[rule.threat.technique]]
78name = "Application Layer Protocol"
79id = "T1071"
80reference = "https://attack.mitre.org/techniques/T1071/"```

References

Related rules

to-top