Files
sigma-rules/rta/user_dir_escalation.py
T

49 lines
1.3 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: SYSTEM Escalation from User Directory
# RTA: user_dir_escalation.py
# ATT&CK: T1044
# Description: Spawns mock malware written to a regular user directory and executes as System.
import os
from pathlib import Path
2020-06-29 23:07:16 -06:00
from . import RtaMetadata, common
2020-06-29 23:07:16 -06:00
metadata = RtaMetadata(
uuid="dc734786-66bd-4be6-bd06-eb41fa7b6745",
platforms=["windows"],
endpoint=[],
siem=[],
techniques=[]
)
2022-09-08 12:50:39 -04:00
2023-10-03 10:47:58 -04:00
@common.requires_os(*metadata.platforms)
2020-06-29 23:07:16 -06:00
@common.dependencies(common.PS_EXEC)
def main():
# make sure path is absolute for psexec
status = common.run_system()
if status is not None:
return status
common.log("Run a user-writeable file as system")
source_path = common.get_path("bin", "myapp.exe")
target_directory = "c:\\users\\fake_user_rta-%d" % os.getpid()
if not Path(target_directory).is_dir():
Path(target_directory).mkdir(parents=True)
2020-06-29 23:07:16 -06:00
target_path = Path(target_directory) / "user_file.exe"
2020-06-29 23:07:16 -06:00
common.copy_file(source_path, target_path)
common.execute([target_path])
common.remove_directory(target_directory)
if __name__ == "__main__":
exit(main())