Skip to content

Commit 4c65a0a

Browse files
Sync RTA Potential Process Masquerading via Exec
Co-authored-by: shashank-elastic <[email protected]> (cherry picked from commit d1f4427)
1 parent 252e9c6 commit 4c65a0a

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

rta/linux_command_and_control_ip_address_arg_from_hidden_executable.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ def main() -> None:
3131

3232
commands = [masquerade, "netcon", "-h", "8.8.8.8", "-p", "53"]
3333
common.execute([*commands], timeout=5, kill=True)
34+
3435
common.log("Cleaning...")
36+
3537
common.remove_file(masquerade)
38+
3639
common.log("Simulation successfull!")
3740

3841

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="4e6ded7e-23cb-460c-8a5b-21c5e5e8d6e8",
11+
platforms=["linux"],
12+
endpoint=[
13+
{
14+
"rule_name": "Potential Process Masquerading via Exec",
15+
"rule_id": "e6669bc3-cb75-4fb3-91e0-ddaa06dd59b2",
16+
},
17+
],
18+
techniques=["T1564", "T1059"],
19+
)
20+
21+
22+
@common.requires_os(*metadata.platforms)
23+
def main() -> None:
24+
common.log("Creating a fake executable..")
25+
masquerade = "[foo]"
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 = [masquerade2, masquerade]
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)