Skip to content

Commit 89e063c

Browse files
Sync RTA Renice or Ulimit Execution from Unusual Parent (#4203)
Co-authored-by: shashank-elastic <[email protected]> (cherry picked from commit ae2adc7)
1 parent adb6075 commit 89e063c

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
8+
from . import RtaMetadata, common
9+
10+
metadata = RtaMetadata(
11+
uuid="9e7ec69a-50cb-4bce-8ace-50e4e6f0199d",
12+
platforms=["linux"],
13+
endpoint=[
14+
{
15+
"rule_name": "Renice or Ulimit Execution",
16+
"rule_id": "57ed0e43-643a-47f3-936e-138dc6f480da",
17+
},
18+
],
19+
techniques=["T1059"],
20+
)
21+
22+
23+
@common.requires_os(*metadata.platforms)
24+
def main() -> None:
25+
common.log("Creating a fake executable..")
26+
masquerade = "/dev/shm/evil"
27+
28+
source = common.get_path("bin", "netcon_exec_chain.elf")
29+
common.copy_file(source, masquerade)
30+
common.execute(["chmod", "+x", masquerade])
31+
32+
masquerade2 = "/dev/shm/renice"
33+
common.copy_file(source, masquerade2)
34+
common.log("Granting execute permissions...")
35+
common.execute(["chmod", "+x", masquerade2])
36+
37+
commands = [masquerade, "exec", "-c", "/dev/shm/renice"]
38+
common.execute([*commands], timeout=5, kill=True)
39+
common.log("Cleaning...")
40+
common.remove_file(masquerade)
41+
common.remove_file(masquerade2)
42+
common.log("Simulation successfull!")
43+
44+
45+
if __name__ == "__main__":
46+
sys.exit(main())

0 commit comments

Comments
 (0)