-
Notifications
You must be signed in to change notification settings - Fork 2
/
isGmailAddress.py
executable file
·50 lines (37 loc) · 1.42 KB
/
isGmailAddress.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
#!/usr/bin/env python3
'''
Not working anymore, the glxu endpoint no longer differentiates between valid and invalid addresses
'''
import requests
import argparse
parser = argparse.ArgumentParser(description="Check GMail address validity",formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument("-e","--email",help="A single address to check")
parser.add_argument("-f","--file",help="A CRLF delimited set of addresses to check")
parser.add_argument("-v","--verbose",action="store_true",help="Verbose output",default=False)
args = parser.parse_args()
email = args.email
addr = "https://mail.google.com/mail/gxlu?email={}"
def check_email(email):
r = requests.get(addr.format(email))
if args.verbose:
print(f"\n[!] VERBOSE: {r.headers}\n")
if "Set-Cookie" in r.headers:
return(f"[✔] {email} is a REGISTERED GMail address")
else:
return(f"[x] {email} is an INVALID GMail address")
if __name__ == "__main__":
if args.file:
with open(args.file,'r') as f:
for email in f:
print(check_email(email.strip()))
else:
if email:
print(check_email(email))
else:
parser.print_help()
''' Output:
% ./isGmailAddress.py -e [email protected]
[x] [email protected] is an INVALID GMail address
% ./isGmailAddress.py -e [email protected]
[✔] [email protected] is a REGISTERED GMail address
'''