forked from elastic/detection-rules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitsadmin_download.py
45 lines (33 loc) · 1.48 KB
/
bitsadmin_download.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
44
45
# 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: Suspicious BitsAdmin Download File
# RTA: bitsadmin_download.py
# ATT&CK: T1197
# Description: Runs BitsAdmin to download file via command line.
import subprocess
from pathlib import Path
from . import RtaMetadata, common
metadata = RtaMetadata(
uuid="aee48793-01ec-428f-9890-c5db9df07830",
platforms=["windows"],
endpoint=[],
siem=[{"rule_id": "a624863f-a70d-417f-a7d2-7a404638d47f", "rule_name": "Suspicious MS Office Child Process"}],
techniques=["T1566"],
)
@common.requires_os(*metadata.platforms)
def main():
common.log("Running Windows BitsAdmin to Download")
server, ip, port = common.serve_web()
url = "http://" + ip + ":" + str(port) + "/bin/myapp.exe"
dest_path = Path("myapp-test.exe").resolve()
fake_word = Path("winword.exe").resolve()
common.log("Emulating parent process: {parent}".format(parent=fake_word))
common.copy_file("C:\\Windows\\System32\\cmd.exe", fake_word)
command = subprocess.list2cmdline(["bitsadmin.exe", "/Transfer", "/Download", url, dest_path])
common.execute([fake_word, "/c", command], timeout=15, kill=True)
common.execute(["taskkill", "/f", "/im", "bitsadmin.exe"])
common.remove_files(dest_path, fake_word)
if __name__ == "__main__":
exit(main())