-
Notifications
You must be signed in to change notification settings - Fork 0
/
dirp.py
49 lines (39 loc) · 1.13 KB
/
dirp.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
#!/usr/bin/python3
import os
import sys
import requests
import time
def loadWordlist():
# check wordlist
if os.path.isfile(wordlist) == False:
sys.exit('ERROR: ' + wordlist + ' does not exist')
else:
wordFile = open(wordlist, 'r', encoding = "ISO-8859-1")
words = wordFile.read().splitlines()
print('Wordlist loaded: ' + wordlist)
return words
def checkBaseURL():
# check baseurl
req = requests.get(url)
if req.status_code == requests.codes.ok:
print('Successful connection to: ' + url)
else:
print('FAILED TO CONNECT')
print('ERROR CODE: ' + str(req.status_code))
def startScan(words):
print()
print('<<< STARTING SCAN >>>')
print()
for i in words:
req = requests.get(url + i)
if req.status_code == requests.codes.ok:
print(str(req.status_code) + ' ' + url + i)
# check command line arguments
if len(sys.argv) != 3:
sys.exit('USAGE: dirp.py <http://baseurl/> <wordlist.txt>')
# load command line arguments
url = sys.argv[1]
wordlist = sys.argv[2]
words = loadWordlist()
checkBaseURL()
startScan(words)