Skip to content

Commit 0311698

Browse files
Merge pull request #436 from Kalivarapubindusree/D2
Dirbrute_Script is added
2 parents 177a6ad + 7449bbd commit 0311698

2 files changed

Lines changed: 193 additions & 0 deletions

File tree

Dirbrute_Script/Dirbrute_Script.py

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# dirbrute.py
5+
#
6+
#
7+
#
8+
# This program is free software; you can redistribute it and/or modify
9+
# it under the terms of the GNU General Public License as published by
10+
# the Free Software Foundation; either version 2 of the License, or
11+
# (at your option) any later version.
12+
#
13+
# This program is distributed in the hope that it will be useful,
14+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
# GNU General Public License for more details.
17+
#
18+
#
19+
20+
yellow = "\033[93m"
21+
green = "\033[92m"
22+
blue = "\033[94m"
23+
red = "\033[91m"
24+
bold = "\033[1m"
25+
end = "\033[0m"
26+
27+
28+
print(blue+bold+"""
29+
\t _ _ _ _
30+
\t __| (_)_ __| |__ _ __ _ _| |_ ___
31+
\t / _` | | '__| '_ \| '__| | | | __/ _ \\
32+
\t| (_| | | | | |_) | | | |_| | || __/
33+
\t \__,_|_|_| |_.__/|_| \__,_|\__\___|"""+bold+"V: 1.6"+ end +blue+"""
34+
\t
35+
\t
36+
\t ---------------
37+
"""+end)
38+
39+
40+
from concurrent.futures import ThreadPoolExecutor as executor
41+
import sys, time, requests
42+
from optparse import *
43+
44+
start = time.time()
45+
46+
def printer(word):
47+
sys.stdout.write(word + " \r")
48+
sys.stdout.flush()
49+
return True
50+
51+
52+
def presearch(domain, ext, url):
53+
if ext == 'Null' or ext == 'None':
54+
checkstatus(domain, url)
55+
elif url == "" or url == " ":
56+
pass
57+
else:
58+
ext = list(ext)
59+
ext.append("")
60+
for i in ext:
61+
if i == "" or i == "None":
62+
link = url
63+
else:
64+
link = url + "." + str(i)
65+
66+
checkstatus(domain, link)
67+
68+
69+
def checkstatus(domain, url):
70+
if url == "" or url == " ":
71+
pass
72+
elif url.startswith("#"):
73+
pass
74+
elif len(url) > 30:
75+
pass
76+
77+
else:
78+
printer("Testing: " + domain + url)
79+
#time.sleep(1)
80+
try:
81+
link = domain + url
82+
req = requests.head(link)
83+
st = str(req.status_code)
84+
if st.startswith("2"):
85+
print(green + "[+] "+st+" | Found: " + end + "[ " + url + " ]" + " \r")
86+
elif st.startswith("3"):
87+
link = req.headers['Location']
88+
#link = req.url
89+
print(yellow + "[*] "+st+" | Redirection From: " + end + "[ " + url + " ]" + yellow + " -> " + end + "[ " + link + " ]" + " \r")
90+
91+
elif st.startswith("1"):
92+
print(green + "[+] "+st+" | Found: " + end + "[ " + url + " ]" + " \r")
93+
elif st.startswith("4"):
94+
if st != '404':
95+
print(blue+"[!] "+st+" | Found: " + end + "[ " + url + " ]" + " \r")
96+
97+
#writer(link,'up')
98+
99+
return True
100+
101+
except Exception:
102+
#writer(url,'down')
103+
return False
104+
105+
106+
parser = OptionParser(green+"""
107+
#Usage:"""+yellow+"""
108+
-t target host
109+
-w wordlist
110+
-d thread number (Optional, Default: 10)
111+
-e extensions (Optional, ex: html,php)
112+
"""+green+"""
113+
#Example:"""+yellow+"""
114+
python3 dirbrute.py -t domain.com -w dirlist.txt -d 20 -e php,html
115+
"""+end)
116+
117+
def Main():
118+
try:
119+
parser.add_option("-t", dest="target", type="string", help="the target domain")
120+
parser.add_option("-w", dest="wordlist", type="string", help="wordlist file")
121+
parser.add_option("-d", dest="thread", type="int", help="the thread number")
122+
parser.add_option("-e", dest="extension", type="string", help="the extendions")
123+
(options, args) = parser.parse_args()
124+
if options.target == None or options.wordlist == None:
125+
print(parser.usage)
126+
exit(1)
127+
else:
128+
target = str(options.target)
129+
wordlist = str(options.wordlist)
130+
thread = str(options.thread)
131+
ext = str(options.extension)
132+
133+
if thread == "None":
134+
thread = 10
135+
else:
136+
thread = thread
137+
138+
if target.startswith("http"):
139+
target = target
140+
else:
141+
target = "http://" + target
142+
143+
if target.endswith("/"):
144+
target = target
145+
else:
146+
target = target + "/"
147+
148+
lines = len(open(wordlist).readlines())
149+
150+
print("["+ yellow + bold +"Info"+ end +"]:\n")
151+
print(blue + "["+red+"+"+blue+"] Target: " + end + target)
152+
print(blue +"["+red+"+"+blue+"] File: " + end + wordlist)
153+
print(blue +"["+red+"+"+blue+"] Length: " + end + str(lines))
154+
print(blue +"["+red+"+"+blue+"] Thread: " + end + str(thread))
155+
print(blue +"["+red+"+"+blue+"] Extension: " + end + str(ext))
156+
print("\n["+ yellow + bold +"Start Searching"+ end +"]:\n")
157+
158+
if ext == "None":
159+
ext = "Null"
160+
else:
161+
ext = ext.split(",")
162+
163+
urls = open(wordlist, 'r')
164+
with executor(max_workers=int(thread)) as exe:
165+
jobs = [exe.submit(presearch, target, ext, url.strip('\n')) for url in urls]
166+
167+
took = time.time() - start
168+
took = took / 60
169+
took = round(took,2)
170+
171+
print(red + "Took: " + end + str(took) + " m" + " \r")
172+
173+
print("\n\t* Happy Hacking *")
174+
except Exception as e:
175+
print(red + "#Error: " + end + str(e))
176+
exit(1)
177+
178+
if __name__ == '__main__':
179+
Main()

Dirbrute_Script/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Dirbrute_Script
2+
3+
Short description of package/script
4+
5+
- This Script Was simple to setup
6+
- Need import ThreadPoolExecutor, concurrent.futures, sys, time, requests, optparse
7+
8+
## Setup instructions
9+
10+
Just Need to Import ThreadPoolExecutor, concurrent.futures, sys, time, requests, optparse then run the Dirbrute_Script.py file and for running python3 is must be installed!
11+
12+
## Detailed explanation of script, if needed
13+
14+
This Script Is Only for Dirbrute_Script use only!

0 commit comments

Comments
 (0)