forked from elastic/detection-rules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwinrar_startup_folder.py
32 lines (25 loc) · 1.23 KB
/
winrar_startup_folder.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
# 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.
# Name: WinRAR Startup Folder
# RTA: winrar_startup_folder.py
# ATT&CK: T1060
# Description: Writes batch file into Windows Startup folder using process ancestry tied to exploit (CVE-2018-20250)
import os
from . import common
@common.requires_os(common.WINDOWS)
def main():
common.log("WinRAR StartUp Folder Persistence")
win_rar_path = os.path.abspath('WinRAR.exe')
ace_loader_path = os.path.abspath('Ace32Loader.exe')
batch_file_path = '\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\mssconf.bat'
startup_path = os.environ['USERPROFILE'] + batch_file_path
common.copy_file("C:\\Windows\\System32\\cmd.exe", win_rar_path)
common.copy_file("C:\\Windows\\System32\\cmd.exe", ace_loader_path)
common.execute([win_rar_path, '/c', ace_loader_path, '/c', 'echo', 'test', '^>', startup_path], kill=True)
common.remove_file(startup_path)
common.remove_file(ace_loader_path)
common.remove_file(win_rar_path)
if __name__ == "__main__":
exit(main())