Scripting Files

What does this hook into?

Scripting tasking involves the following RESTful endpoints on an instance of Mythic. This means you need to create a new Mythic instance (i.e. mythic = Mythic(username="blah" ... ) and then call these functions like mythic.download_file():
1
async def download_file(self, file: FileMeta) -> bytes:
2
"""
3
Download a file that is either scheduled for upload or is finished downloading
4
"""
Copied!
The FileMeta class type refers to this: https://github.com/MythicMeta/Mythic_Scripting/blob/master/mythic/mythic_rest.py#L2801. All of the scripting tries to work on Objects rather than opaque dictionaries, so if you want to download a file, you need to indicate which file you want to download. Let's take an example:
1
await mythic.listen_for_new_files(analyze_file_upload_download)
2
...
3
async def analyze_file_upload_download(mythic, file):
4
try:
5
if file.total_chunks == file.chunks_received:
6
if file.is_download_from_agent:
7
print("[+] Notified of finished file download, pulling from server for offline analysis...")
8
contents = await mythic.download_file(file)
9
with open("downloaded_file", "wb") as f:
10
f.write(contents)
11
else:
12
print("this is an upload or screenshot")
13
14
else:
15
print(f"[*] Don't have full file yet: {file.chunks_received} of {file.total_chunks} so far")
16
except Exception as e:
17
print(e)
Copied!
Last modified 6mo ago
Copy link