Skip to content

Commit 6ec5c5b

Browse files
Sync RTA Foomatic-rip Shell Execution (#4200)
Co-authored-by: shashank-elastic <[email protected]>
1 parent be656ae commit 6ec5c5b

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
2+
# or more contributor license agreements. Licensed under the Elastic License
3+
# 2.0; you may not use this file except in compliance with the Elastic License
4+
# 2.0.
5+
6+
import sys
7+
from . import RtaMetadata, common
8+
9+
metadata = RtaMetadata(
10+
uuid="1c088eaa-97a1-4ff7-9fa5-a6bc311e9b1e",
11+
platforms=["linux"],
12+
endpoint=[
13+
{
14+
"rule_name": "Foomatic-rip Shell Execution",
15+
"rule_id": "8ccebdc1-9929-4584-ac8f-a96ee8e8c616",
16+
},
17+
],
18+
techniques=["T1203"],
19+
)
20+
21+
22+
@common.requires_os(*metadata.platforms)
23+
def main() -> None:
24+
common.log("Creating a fake executable..")
25+
masquerade = "/tmp/foomatic-rip"
26+
masquerade2 = "/tmp/sh"
27+
28+
source = common.get_path("bin", "linux.ditto_and_spawn")
29+
common.copy_file(source, masquerade)
30+
common.log("Granting execute permissions...")
31+
common.execute(["chmod", "+x", masquerade])
32+
33+
source = common.get_path("bin", "linux.ditto_and_spawn")
34+
common.copy_file(source, masquerade2)
35+
common.log("Granting execute permissions...")
36+
common.execute(["chmod", "+x", masquerade2])
37+
38+
commands = [masquerade, masquerade2, '-c', 'whoami']
39+
common.execute([*commands], timeout=5, kill=True)
40+
common.log("Cleaning...")
41+
common.remove_file(masquerade)
42+
common.remove_file(masquerade2)
43+
common.log("Simulation successfull!")
44+
45+
46+
if __name__ == "__main__":
47+
sys.exit(main())

0 commit comments

Comments
 (0)