Linux Restricted Shell Breakout via the expect command

Identifies Linux binary expect command abuse to break out from restricted environments by spawning an interactive system shell. The expect utility allows us to automate control of interactive applications such as Telnet, FTP, SSH and others. The activity of spawning shell is not a standard use of this binary for a user or system administrator and could potentially indicate malicious actor attempting to improve the capabilities or stability of their access.

Elastic rule (View on GitHub)

 1[metadata]
 2creation_date = "2022/03/07"
 3deprecation_date = "2022/05/09"
 4maturity = "deprecated"
 5updated_date = "2022/05/09"
 6
 7[rule]
 8author = ["Elastic"]
 9description = """
10Identifies Linux binary expect command abuse to break out from restricted environments by spawning an interactive system
11shell. The expect utility allows us to automate control of interactive applications such as Telnet, FTP, SSH and others.
12The activity of spawning shell is not a standard use of this binary for a user or system administrator and could
13potentially indicate malicious actor attempting to improve the capabilities or stability of their access.
14"""
15from = "now-9m"
16index = ["logs-endpoint.events.*"]
17language = "eql"
18license = "Elastic License v2"
19name = "Linux Restricted Shell Breakout via the expect command"
20references = ["https://gtfobins.github.io/gtfobins/expect/"]
21risk_score = 47
22rule_id = "fd3fc25e-7c7c-4613-8209-97942ac609f6"
23severity = "medium"
24tags = ["Elastic", "Host", "Linux", "Threat Detection", "Execution", "GTFOBins"]
25timestamp_override = "event.ingested"
26type = "eql"
27
28query = '''
29process where event.type == "start" and process.name in ("bash", "sh", "dash") and
30  process.parent.name == "expect" and process.parent.args == "-c" and
31  process.parent.args in ("spawn /bin/sh;interact", "spawn /bin/bash;interact", "spawn /bin/dash;interact", "spawn sh;interact", "spawn bash;interact", "spawn dash;interact")
32'''
33
34
35[[rule.threat]]
36framework = "MITRE ATT&CK"
37[[rule.threat.technique]]
38id = "T1059"
39name = "Command and Scripting Interpreter"
40reference = "https://attack.mitre.org/techniques/T1059/"
41[[rule.threat.technique.subtechnique]]
42id = "T1059.004"
43name = "Unix Shell"
44reference = "https://attack.mitre.org/techniques/T1059/004/"
45
46
47
48[rule.threat.tactic]
49id = "TA0002"
50name = "Execution"
51reference = "https://attack.mitre.org/tactics/TA0002/"

References

Related rules

to-top