Skip to content

Commit 4a12967

Browse files
Sync RTA Potential Proxy Execution via Crash (#4175)
Co-authored-by: shashank-elastic <[email protected]> (cherry picked from commit fb4bc72)
1 parent 4f30de5 commit 4a12967

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="fa40fdc4-23bf-491c-bc55-6a6848c5b6da",
11+
platforms=["linux"],
12+
endpoint=[
13+
{
14+
"rule_name": "Potential Proxy Execution via Crash",
15+
"rule_id": "995c8bdb-5ebb-4c5b-9a03-4d39b52c0ff3",
16+
},
17+
],
18+
techniques=["T1218", "T1059"],
19+
)
20+
21+
22+
@common.requires_os(*metadata.platforms)
23+
def main() -> None:
24+
common.log("Creating a fake executable..")
25+
masquerade = "/tmp/crash"
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, '-h', masquerade, '-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)