Files
sigma-rules/rta/deprecated/_persistence_reopened_app.py
T
2023-10-03 10:47:58 -04:00

40 lines
1.2 KiB
Python

# 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 pathlib import Path
from .. import common
from .. import RtaMetadata
metadata = RtaMetadata(
uuid="8a6aee3d-fa5f-41ca-83f6-d0669fc159ac",
platforms=["macos"],
endpoint=[{"rule_id": "57e9e13a-4eda-4b5f-b39a-d38c8104ab0f", "rule_name": "Re-Opened Application Persistence"}],
siem=[],
techniques=["T1547", "T1547.007"],
)
@common.requires_os(*metadata.platforms)
def main():
# create masquerades
masquerade = "/tmp/bash"
common.create_macos_masquerade(masquerade)
path = Path(f"{Path.home()}/Library/Preferences/ByHost/")
path.mkdir(exist_ok=True, parents=True)
plist = path / "com.apple.loginwindow.plist"
common.log("Executing file modification on com.apple.loginwindow.test.plist file.")
common.execute([masquerade, "childprocess", f"echo 'test'> {plist}"], timeout=5, kill=True)
# cleanup
common.remove_directory(str(path))
if __name__ == "__main__":
exit(main())