Last active
August 27, 2024 07:30
-
-
Save d0zingcat/3cf1b5a7b12279e237a51b69dccf10e2 to your computer and use it in GitHub Desktop.
smtp example in python(spoofing)
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 | |
# List of recipients to whom the email will be sent. | |
# ATTENTION: should replace this with your email | |
RECIPIENTS = ["[email protected]"] | |
# Define the subject and body of the email. | |
SUBJECT = "ACTIONS NEED TO BE TAKEN!" | |
BODY = "This is the body of the text message" | |
# Define the sender's email address. | |
FAKE_SENDER = "XXX <[email protected]>" | |
def send_email(smtp_server, smtp_port, subject, body, fake_sender, user, password, recipients): | |
""" | |
Send an email using the Gmail SMTP server. | |
:param str smtp_server: The SMTP server address. | |
:param int smtp_port: The SMTP server port. | |
:param str subject: The subject of the email. | |
:param str body : The body of the email. | |
:param str fake_sender: The sender's email address. | |
:param str user: The username for the Gmail account. | |
:param str password: The password for the Gmail account. | |
:param lsit recipients: A list of recipients' email addresses. | |
:return: None | |
:rtype: None | |
""" | |
# Create a MIMEText object with the body of the email. | |
msg = MIMEText(body) | |
# Set the subject of the email. | |
msg['Subject'] = subject | |
# Set the sender's email. | |
msg['From'] = fake_sender | |
msg['Reply-To'] = fake_sender | |
# Join the list of recipients into a single string separated by commas. | |
msg['To'] = ', '.join(recipients) | |
with smtplib.SMTP(smtp_server, smtp_port) as smtp_server: | |
smtp_server.ehlo() | |
smtp_server.starttls() | |
smtp_server.login(user, password) | |
smtp_server.sendmail(fake_sender, recipients, msg.as_string()) | |
smtp_server.close() | |
# Print a message to console after successfully sending the email. | |
print("Message sent!") | |
def main(): | |
provider = input( | |
"""Enter 1 for Gmail, 2 for iCloud, 3 for Outlook, 4 for QQ, 5 for Google Workspace: """) | |
if provider == "1": | |
# Using Gmail SMTP | |
smtp_server = 'smtp.gmail.com' | |
smtp_port = 587 | |
smtp_username = 'xxx' | |
smtp_password = 'yyy' | |
elif provider == "2": | |
# Using iCloud SMTP | |
smtp_server = 'smtp.mail.me.com' | |
smtp_port = 587 | |
smtp_username = 'xxx' | |
smtp_password = 'yyy' | |
elif provider == "3": | |
# Using iCloud SMTP | |
smtp_server = 'smtp-mail.outlook.com' | |
smtp_port = 587 | |
smtp_username = 'xxx' | |
smtp_password = 'yyy' | |
elif provider == "4": | |
# Using iCloud SMTP | |
smtp_server = 'smtp.qq.com' | |
smtp_port = 587 | |
smtp_username = 'xxx' | |
smtp_password = 'yyy' | |
elif provider == "5": | |
# Using Google Workspace SMTP | |
smtp_server = 'smtp.gmail.com' | |
smtp_port = 587 | |
smtp_username = 'xxx' | |
smtp_password = 'yyy' | |
else: | |
print("Invalid input. Exiting...") | |
exit() | |
assert smtp_server is not None | |
assert smtp_port is not None | |
send_email(smtp_server, smtp_port, SUBJECT, BODY, FAKE_SENDER, | |
smtp_username, smtp_password, RECIPIENTS) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment