-
Notifications
You must be signed in to change notification settings - Fork 6
/
email_chooser.py
72 lines (56 loc) · 2.22 KB
/
email_chooser.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
import random
import re
import requests
from twitter_scraper import get_tweets
#-----------------------------------------------------------------------------------------------------------------------------
# TODO: will make this more interactive, may use a class here.
# TODO: May use generator here...
domains_list = [domain.rstrip('\n') for domain in open('data/domains.txt')]
# set up this word list from my phone in a bar, so pardon the liquor names in there.
#---------------------------------------------------------
def genEmail(length=1,pages=1):
userlist = getUsers(pages)
if len(userlist) < length:
return "Sorry we were only able to gather {} of the requested {} users try increasing pages".format(len(userlist),length)
return [random.choice(userlist) + random.choice(domains_list) for _ in range(length)]
def getDumpUrl(pages):
print("Gathering Links")
urls = []
for tweet in get_tweets('dumpmon', pages=pages):
urls.append(re.findall(r"(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9]\.[^\s]{2,})", tweet['text']))
return urls
def getUsers(pages):
urls = getDumpUrl(pages)
e = []
users = []
print('Extracting Emails')
for url in urls:
s = str(url)[2:-2]
r = requests.get(s)
content = str(r.content)
emails = re.findall(r"[a-zA-Z0-9_.+-]+@", content)
for email in emails:
if email.find('-')==-1:
e.append(email)
#print(email)
print('Building user list')
for email in e:
if len(email)>5 and len(email)<24:
#print(email, len(email))
ind = len(email)-2
user = email[0:ind]
if re.match('^(?=.*[a-zA-Z])', user):
users.append(user)
users = list(set(users)) #Remove duplicates
for u in users:
for c in u:
if c.isdigit():
c = replaceDigit(c)
print("Collected {} users".format(len(users)))
return users
def replaceDigit(digit):
d = random.randrange(0,9)
if d != digit:
return d
else:
replaceDigit(d)