-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdirhunter.py
28 lines (23 loc) · 1.09 KB
/
dirhunter.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
import requests
def attack(host, wordlist, extension, codeToIgnore):
try:
wordlist = wordlist.split('\n')
for word in wordlist:
if not word.startswith('#') and not word.startswith(' '):
response = requests.get('{0}{1}'.format(host, word), headers=None)
if str(response.status_code) != codeToIgnore:
print('{:<25s}{:>4d}'.format(word, response.status_code))
if extension != None:
response = requests.get('{0}{1}'.format(host, word + extension), headers=None)
print('{:<25s}{:>4d}'.format(word + extension, response.status_code))
except KeyboardInterrupt:
print('\n\nBye!')
host = input('Enter the host...\n')
fileName = input('Enter the file name your wordlist (e.g. directory-list-2.3-small.txt)...\n')
codeToIgnore = input('Enter a response status code to ignore if you want...\n')
if not host.endswith('/'):
host = host + '/'
extension = '.html'
file = open(fileName, 'r')
wordlist = file.read()
attack(host, wordlist, extension, codeToIgnore)