Skip to content

Commit 05c734a

Browse files
authored
Update dirbrute.py
1 parent aff6ae0 commit 05c734a

File tree

1 file changed

+72
-61
lines changed

1 file changed

+72
-61
lines changed

dirbrute.py

Lines changed: 72 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33
#
4-
# subchecker.py
4+
# dirbrute.py
55
#
66
# Copyright 2019 bingo <bingo@hacklab>
77
#
@@ -31,7 +31,7 @@
3131
\t __| (_)_ __| |__ _ __ _ _| |_ ___
3232
\t / _` | | '__| '_ \| '__| | | | __/ _ \\
3333
\t| (_| | | | | |_) | | | |_| | || __/
34-
\t \__,_|_|_| |_.__/|_| \__,_|\__\___|"""+bold+"V: 1.5"+ end +blue+"""
34+
\t \__,_|_|_| |_.__/|_| \__,_|\__\___|"""+bold+"V: 1.6"+ end +blue+"""
3535
\t
3636
\t Coded by: Bingo
3737
\t ---------------
@@ -40,10 +40,9 @@
4040

4141
from concurrent.futures import ThreadPoolExecutor as executor
4242
import sys, time, requests
43-
43+
from optparse import *
4444

4545
start = time.time()
46-
count = 0
4746

4847
def printer(word):
4948
sys.stdout.write(word + " \r")
@@ -99,66 +98,78 @@ def checkstatus(domain, url):
9998
return False
10099

101100

102-
try:
103-
urlsfile = sys.argv[1]#raw_input("[subdomains]> ")
104-
domain = sys.argv[2]
105-
106-
107-
except Exception:
108-
print(red + "#Usage:\n\tpython dirbrute.py <Wordlist> <Domain> <Thread (optional)> <extensions (optional)>\n" + end)
109-
exit(0)
110-
111-
try:
112-
thread = sys.argv[3]
113-
114-
except:
115-
thread = 20
116-
117-
try:
118-
ext = sys.argv[4]
119-
#ext = list(ext)
120-
except:
121-
ext = "Null"
122-
123-
#print(ext)
124-
125-
126-
if domain.startswith("http"):
127-
domain = domain
128-
else:
129-
domain = "http://" + domain
130-
131-
if domain.endswith("/"):
132-
domain = domain
133-
else:
134-
domain = domain + "/"
135-
136-
lines = len(open(urlsfile, encoding="utf-8").readlines())
137-
138-
print("["+ yellow + bold +"Info"+ end +"]:\n")
139-
print(blue + "["+red+"+"+blue+"] Target: " + end + domain)
140-
print(blue +"["+red+"+"+blue+"] File: " + end + urlsfile)
141-
print(blue +"["+red+"+"+blue+"] Length: " + end + str(lines))
142-
print(blue +"["+red+"+"+blue+"] Thread: " + end + str(thread))
143-
print(blue +"["+red+"+"+blue+"] Extension: " + end + str(ext))
144-
print("\n["+ yellow + bold +"Start Searching"+ end +"]:\n")
101+
parser = OptionParser("""
102+
103+
#Usage:
104+
-t target host
105+
-w wordlist
106+
-d thread number (Optional, Default: 10)
107+
-e extensions (Optional, ex: html,php)
108+
#Exemple:
109+
python3 dirbrute.py -t domain.com -w dirlist.txt -d 20 -e php,html
110+
111+
""")
112+
113+
def Main():
114+
try:
115+
parser.add_option("-t", dest="target", type="string", help="the target domain")
116+
parser.add_option("-w", dest="wordlist", type="string", help="wordlist file")
117+
parser.add_option("-d", dest="thread", type="int", help="the thread number")
118+
parser.add_option("-e", dest="extension", type="string", help="the extendions")
119+
(options, args) = parser.parse_args()
120+
if options.target == None or options.wordlist == None:
121+
print(parser.usage)
122+
exit(1)
123+
else:
124+
target = str(options.target)
125+
wordlist = str(options.wordlist)
126+
thread = str(options.thread)
127+
ext = str(options.extension)
128+
129+
if thread == "None":
130+
thread = 10
131+
else:
132+
thread = thread
145133

146-
#exit(0)
134+
if target.startswith("http"):
135+
target = target
136+
else:
137+
target = "http://" + target
147138

148-
urls = open(urlsfile, 'r')
139+
if target.endswith("/"):
140+
target = target
141+
else:
142+
target = target + "/"
143+
144+
lines = len(open(wordlist).readlines())
145+
146+
print("["+ yellow + bold +"Info"+ end +"]:\n")
147+
print(blue + "["+red+"+"+blue+"] Target: " + end + target)
148+
print(blue +"["+red+"+"+blue+"] File: " + end + wordlist)
149+
print(blue +"["+red+"+"+blue+"] Length: " + end + str(lines))
150+
print(blue +"["+red+"+"+blue+"] Thread: " + end + str(thread))
151+
print(blue +"["+red+"+"+blue+"] Extension: " + end + str(ext))
152+
print("\n["+ yellow + bold +"Start Searching"+ end +"]:\n")
153+
154+
if ext == None:
155+
ext = "Null"
156+
else:
157+
ext = ext.split(",")
158+
159+
urls = open(wordlist, 'r')
160+
with executor(max_workers=int(thread)) as exe:
161+
jobs = [exe.submit(presearch, target, ext, url.strip('\n')) for url in urls]
149162

150-
if ext == "Null":
151-
pass
152-
else:
153-
ext = ext.split(",")
163+
took = time.time() - start
164+
took = took / 60
165+
took = round(took,2)
154166

155-
with executor(max_workers=int(thread)) as exe:
156-
jobs = [exe.submit(presearch, domain, ext, url.strip('\n')) for url in urls]
157-
#results = [job.result() for job in jobs]
158-
159-
took = (time.time() - start) / 60
160-
took = round(took,2)
161-
print(red+"Took: "+end, took, " m", " \r")
167+
print(red + "Took: " + end + str(took) + " m" + " \r")
162168

163-
print("\n\t* Happy Hacking *")
169+
print("\n\t* Happy Hacking *")
170+
except Exception as e:
171+
print(red + "#Error: " + end + str(e))
172+
exit(1)
164173

174+
if __name__ == '__main__':
175+
Main()

0 commit comments

Comments
 (0)