-
Notifications
You must be signed in to change notification settings - Fork 1
/
bruter.py
66 lines (56 loc) · 1.75 KB
/
bruter.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
import queue
import requests
import sys
import threading
AGENT = "Mozilla/5.0 (X11; Linux x86_64; rv:19.0) Gecko/20100101 Firefox/19.0"
EXTENSIONS = ['.php', '.bak', '.orig', '.inc']
TARGET = "http://testphp.vulnweb.com"
THREADS = 50
WORDLIST = "/home/tim/Downloads/all.txt"
def get_words(resume=None):
def extend_words(word):
if "." in word:
words.put(f'/{word}')
else:
words.put(f'/{word}/')
for extension in EXTENSIONS:
words.put(f'/{word}{extension}')
with open(WORDLIST) as f:
raw_words = f.read()
found_resume = False
words = queue.Queue()
for word in raw_words.split():
if resume is not None:
if found_resume:
extend_words(word)
elif word == resume:
found_resume = True
print(f'Resuming wordlist from: {resume}')
else:
print(word)
extend_words(word)
return words
def dir_bruter(words):
headers = {'User-Agent': AGENT}
while not words.empty():
url = f'{TARGET}{words.get()}'
try:
r = requests.get(url, headers=headers)
except requests.exceptions.ConnectionError:
sys.stderr.write('x')
sys.stderr.flush()
continue
if r.status_code == 200:
print(f'\nSuccess ({r.status_code}: {url})')
elif r.status_code == 404:
sys.stderr.write('.')
sys.stderr.flush()
else:
print(f'{r.status_code} => {url}')
if __name__ == '__main__':
words = get_words()
print('Press return to continue.')
sys.stdin.readline()
for _ in range(THREADS):
t = threading.Thread(target=dir_bruter, args=(words,))
t.start()