Skip to content

Commit 078e9dd

Browse files
Sync RTA System Binary Proxy Execution via ld.so (#4176)
Co-authored-by: shashank-elastic <[email protected]> (cherry picked from commit bc821f5)
1 parent c76eac7 commit 078e9dd

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="e2a136e5-bda1-41c4-8143-514c0b0784c4",
11+
platforms=["linux"],
12+
endpoint=[
13+
{
14+
"rule_name": "System Binary Proxy Execution via ld.so",
15+
"rule_id": "10cb6563-35a9-45b7-a394-e7bca6fd5bed",
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 = "/lib/ld-linux-foo.so"
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, 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)