-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathpython_email_sender.py
More file actions
61 lines (51 loc) · 2.07 KB
/
python_email_sender.py
File metadata and controls
61 lines (51 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import smtplib
import ssl
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
def send_spoofed_email(spoofed_domain, recipient_email):
try:
# Generate the spoofed email address using the domain passed in
spoofed_sender_email = f"{spoofed_domain}" # Spoofed sender
recipient_email = f"{recipient_email}" # Recipient email
auth_email = "test@openm.solutions" # Email used for authentication
smtp_server = "c2480355.ferozo.com"
port = 465
password = "sSZY/Pz8aH"
# Email message content
subject = "Testing spoofed email"
html_message = f"""\
<html>
<body>
<p>Hello,<br>
<br>
Facundo Fernandez (@offsec01)
This is a test email to check how spoofed sender addresses are handled.<br>
Please review the headers to verify the sender.<br>
Spoofed domain: {spoofed_domain}
</p>
</body>
</html>
"""
message = MIMEMultipart("alternative")
message["Subject"] = subject
message["From"] = spoofed_sender_email # Spoofed sender address
message["To"] = recipient_email
# Create plain-text and HTML versions of the message
text_part = MIMEText(
"Hello, this is a test email with a spoofed sender address.", "plain"
)
html_part = MIMEText(html_message, "html")
# Attach both parts to the message
message.attach(text_part)
message.attach(html_part)
# Create a secure SSL context
context = ssl.create_default_context()
# Send email
with smtplib.SMTP_SSL(smtp_server, port, context=context) as server:
server.login(
auth_email, password
) # Authenticate using personas@fedeyclau.info
server.sendmail(spoofed_sender_email, recipient_email, message.as_string())
print(f"Spoofed email sent successfully from {spoofed_sender_email}!")
except Exception as e:
print(f"Error: {e}")