Linux Restricted Shell Breakout via the gcc command

Identifies Linux binary gcc abuse to break out from restricted environments by spawning an interactive system shell. The gcc utility is a complier system for various languages and mainly used to compile C and C++ programs. The activity of spawning shell is not a standard use of this binary for a user or system administrator. It indicates a potentially malicious actor attempting to improve the capabilities or stability of their access.

Elastic rule (View on GitHub)

 1[metadata]
 2creation_date = "2022/03/09"
 3deprecation_date = "2022/05/09"
 4maturity = "deprecated"
 5updated_date = "2022/05/09"
 6
 7[rule]
 8author = ["Elastic"]
 9description = """
10Identifies Linux binary gcc abuse to break out from restricted environments by spawning an interactive system shell. The
11gcc utility is a complier system for various languages and mainly used to compile C and C++ programs. The activity of
12spawning shell is not a standard use of this binary for a user or system administrator. It indicates a potentially
13malicious 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 gcc command"
20references = ["https://gtfobins.github.io/gtfobins/gcc/"]
21risk_score = 47
22rule_id = "da986d2c-ffbf-4fd6-af96-a88dbf68f386"
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 ("sh", "dash", "bash")  and
30  process.parent.name == "gcc" and process.parent.args == "-wrapper" and
31  process.parent.args in ("sh,-s", "bash,-s", "dash,-s", "/bin/sh,-s", "/bin/bash,-s", "/bin/dash,-s")
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