From 60de003b89e4e584b6615ca69277078b882f7b66 Mon Sep 17 00:00:00 2001 From: and7es <155257325+and7es@users.noreply.github.com> Date: Sat, 4 May 2024 01:29:58 +0200 Subject: [PATCH] Update exfil_exchange_mail.py There is a bug when creating the html files with the email subjects. If the subjects contain special characters (ex: / @ # ? ) the program gives an error because it cannot create the file. I have modified the line so that before creating the file it removes the special characters from the subject --- Tokens/exfil_exchange_mail.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Tokens/exfil_exchange_mail.py b/Tokens/exfil_exchange_mail.py index 2fe0ecb..1f19f92 100644 --- a/Tokens/exfil_exchange_mail.py +++ b/Tokens/exfil_exchange_mail.py @@ -1,6 +1,7 @@ import requests import json import base64 +import re # This script requires a token from graph.microsoft.com @@ -29,7 +30,8 @@ # Check if the email has an HTML body if email['body']['contentType'] == 'html': # Save the HTML body to a file - with open(subject + '.html', 'w') as f: + name = re.sub('[^a-zA-Z0-9 \n\.]', '', subject) + with open(name + '.html', 'w') as f: f.write(body) print('HTML email downloaded:', subject + '.html') print('All emails downloaded.')