Reverse Shell Created via Named Pipe

Identifies a reverse shell via the abuse of named pipes on Linux with the help of OpenSSL or Netcat. First in, first out (FIFO) files are special files for reading and writing to by Linux processes. For this to work, a named pipe is created and passed to a Linux shell where the use of a network connection tool such as Netcat or OpenSSL has been established. The stdout and stderr are captured in the named pipe from the network connection and passed back to the shell for execution.

Elastic rule (View on GitHub)

 1[metadata]
 2creation_date = "2022/11/14"
 3deprecation_date = "2023/07/04"
 4integration = ["endpoint"]
 5maturity = "deprecated"
 6min_stack_comments = "New fields added: required_fields, related_integrations, setup"
 7min_stack_version = "8.3.0"
 8updated_date = "2023/07/04"
 9
10[rule]
11author = ["Elastic"]
12description = """
13Identifies a reverse shell via the abuse of named pipes on Linux with the help of OpenSSL or Netcat. First in, first out
14(FIFO) files are special files for reading and writing to by Linux processes. For this to work, a named pipe is created
15and passed to a Linux shell where the use of a network connection tool such as Netcat or OpenSSL has been established.
16The stdout and stderr are captured in the named pipe from the network connection and passed back to the shell for
17execution.
18"""
19false_positives = [
20    """
21    Netcat and OpenSSL are common tools used for establishing network connections and creating encryption keys. While
22    they are popular, capturing the stdout and stderr in a named pipe pointed to a shell is anomalous.
23    """,
24]
25from = "now-9m"
26index = ["auditbeat-*", "logs-endpoint.events.*", "endgame-*"]
27language = "eql"
28license = "Elastic License v2"
29name = "Reverse Shell Created via Named Pipe"
30references = [
31    "https://int0x33.medium.com/day-43-reverse-shell-with-openssl-1ee2574aa998",
32    "https://blog.gregscharf.com/2021/03/22/tar-in-cronjob-to-privilege-escalation/",
33    "https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md#openssl",
34]
35risk_score = 47
36rule_id = "dd7f1524-643e-11ed-9e35-f661ea17fbcd"
37severity = "medium"
38tags = [
39    "Domain: Endpoint",
40    "OS: Linux",
41    "Use Case: Threat Detection",
42    "Tactic: Execution",
43    "Data Source: Elastic Endgame",
44]
45type = "eql"
46
47query = '''
48sequence by host.id with maxspan = 5s
49    [process where host.os.type == "linux" and event.type == "start" and process.executable : ("/usr/bin/mkfifo","/usr/bin/mknod") and process.args:("/tmp/*","$*")]
50    [process where host.os.type == "linux" and process.executable : ("/bin/sh","/bin/bash") and process.args:("-i") or
51        (process.executable: ("/usr/bin/openssl") and process.args: ("-connect"))]
52    [process where host.os.type == "linux" and (process.name:("nc","ncat","netcat","netcat.openbsd","netcat.traditional") or
53                    (process.name: "openssl" and process.executable: "/usr/bin/openssl"))]
54'''
55
56
57[[rule.threat]]
58framework = "MITRE ATT&CK"
59[[rule.threat.technique]]
60id = "T1059"
61name = "Command and Scripting Interpreter"
62reference = "https://attack.mitre.org/techniques/T1059/"
63[[rule.threat.technique.subtechnique]]
64id = "T1059.004"
65name = "Unix Shell"
66reference = "https://attack.mitre.org/techniques/T1059/004/"
67
68
69
70[rule.threat.tactic]
71id = "TA0002"
72name = "Execution"
73reference = "https://attack.mitre.org/tactics/TA0002/"

References

Related rules

to-top