-
Notifications
You must be signed in to change notification settings - Fork 8
/
gxlu.py
executable file
·167 lines (123 loc) · 4.03 KB
/
gxlu.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
#!/usr/bin/python
#
# Email checker for gmail accounts
# Author czz78
# Thanx to x0rz for infos on his blog https://blog.0day.rocks/abusing-gmail-to-get-previously-unlisted-e-mail-addresses-41544b62b2
#
import sys
import argparse
from multiprocessing.dummy import Pool as ThreadPool
from functools import partial
import requests
#
# Check if email [email protected] exists
# returns the email that has been checked if true, nothing if false
#
def check(email, verbose = 'no'):
url = "https://mail.google.com/mail/gxlu?email={0}".format(email)
r = requests.get(url)
try:
if(r.headers['set-cookie'] != ''):
if(verbose == 'yes'):
#print ("email %s is valid" % (email))
print r.headers
return email
except:
if(verbose == 'yes'):
print r.headers
return
#
# Write to file
#
def write_to_file(hnd, data):
for d in data:
if d is not None:
hnd.write(str(d + "\n"))
#
# Write to standard out ( default )
#
def write_to_stdout(data, tag = ''):
for d in data:
if d is not None:
print "%s %s" % (d, tag)
########################### MAIN ##########################################
# parse arguments
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--verbose", help="increase output verbosity",action="store_true")
parser.add_argument("-s", "--single", help="single email. Only one address")
parser.add_argument("-f", "--filename", help="Name of file with a list of emails")
parser.add_argument("-t", "--threads", help="number of threads, default 4")
parser.add_argument("-o", "--out", help="Name of output file")
parser.add_argument("-i", "--invalid", help="if used with --out will give a file invalid.outputfilename else will print in std out", action="store_true")
args = parser.parse_args()
verbose = "no"
if args.verbose:
verbose = "yes"
threads = 20
if args.threads:
threads = int(args.threads)
if ((args.single and args.filename) or (not args.single and not args.filename)):
parser.print_help()
parser.exit(1)
# make the Pool of workers
pool = ThreadPool(threads)
# if single address
if args.single:
results = check("%s" % (args.single), verbose)
if results is None:
print "%s address not valid" % (args.single)
else:
print "%s address valid" % (args.single)
if args.out:
out = open(args.out,"w")
if args.invalid:
if args.out:
invalid = open("invalid." + args.out,"w")
if args.filename:
# initialize emails var
emails=[]
with open(args.filename) as fp:
flag = 0
for i,line in enumerate(fp, start=1):
if args.out:
sys.stdout.write('.')
sys.stdout.flush()
else:
if i == 1:
print "waiting for results ....\n"
line = line.replace("\n","").replace("\r","")
emails.append(line)
if (i%threads == 0):
results= pool.map(partial(check, verbose=verbose), emails)
if args.out:
write_to_file(out,results)
else:
write_to_stdout(results)
if args.invalid:
if args.out:
write_to_file(invalid,set(emails)-set(results))
else:
write_to_stdout(set(emails)-set(results), "NOT VALID")
emails = []
flag = 0
else:
flag = 1
if flag == 1:
results= pool.map(partial(check, verbose=verbose), emails)
if args.out:
write_to_file(out,results)
else:
write_to_stdout(results)
if args.invalid:
if args.out:
write_to_file(invalid,set(emails)-set(results))
else:
write_to_stdout(set(emails)-set(results), "NOT VALID")
if not args.out:
print ""
print "Done\n"
if args.out:
out.close()
pool.close()
pool.join()
#End