-
Notifications
You must be signed in to change notification settings - Fork 505
/
dylib_injection.py
47 lines (39 loc) · 1.36 KB
/
dylib_injection.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License
# 2.0; you may not use this file except in compliance with the Elastic License
# 2.0.
import platform
from . import common
from . import RtaMetadata
metadata = RtaMetadata(
uuid="f1321e5c-101d-4b03-8f0c-6cf8bda174ec",
platforms=["macos"],
endpoint=[
{
"rule_name": "Collect DIAG Dylib Load Event",
"rule_id": "2df75424-4106-43c5-8fea-f115e18588da",
},
{
"rule_name": "Dylib Injection via Process Environment Variables",
"rule_id": "246741d4-3eee-4fbb-beec-53ef562c62c3",
},
{
"rule_name": "Potential Binary Masquerading via Invalid Code Signature",
"rule_id": "4154c8ce-c718-4641-80db-a6a52276f1a4",
},
],
siem=[],
techniques=["T1574", "T1574.006"],
)
@common.requires_os(*metadata.platforms)
def main():
if platform.processor() == "arm":
name = "com.apple.sleep_arm"
dylib = "inject_arm.dylib"
else:
name = "com.apple.sleep_intel"
dylib = "inject_intel.dylib"
target_bin = common.get_path("bin", name)
common.execute([f"DYLD_INSERT_LIBRARIES={dylib}", target_bin, "5"], kill=True, shell=True)
if __name__ == "__main__":
exit(main())