-
Notifications
You must be signed in to change notification settings - Fork 505
/
app_bundler_execution.py
47 lines (37 loc) · 1.36 KB
/
app_bundler_execution.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.
from . import common
from . import RtaMetadata
metadata = RtaMetadata(
uuid="ea7c50ad-5736-48c7-bf39-50f708710826",
platforms=["macos"],
endpoint=[
{
"rule_name": "Script Execution via macOS Application Bundle",
"rule_id": "94a891a9-3771-4a8c-a6ca-82fa66cfd7e2",
}
],
siem=[],
techniques=["T1553", "T1059"],
)
@common.requires_os(*metadata.platforms)
def main():
# create masquerades
masquerade = "/tmp/launchd"
masquerade2 = "/tmp/bash"
masquerade3 = "/tmp/curl"
common.create_macos_masquerade(masquerade)
common.create_macos_masquerade(masquerade2)
common.create_macos_masquerade(masquerade3)
# Execute command
common.log("Launching fake macOS application bundler commands")
command = f"{masquerade2} test.app/Contents/MacOS/test-psntest"
common.execute([masquerade, "childprocess", command], timeout=10, kill=True)
common.execute([masquerade2, "childprocess", masquerade3], timeout=10, kill=True)
# cleanup
common.remove_file(masquerade)
common.remove_file(masquerade2)
if __name__ == "__main__":
exit(main())