Skip to content

Commit bfd508c

Browse files
Dirbrute_Script added
1 parent b7157e6 commit bfd508c

2 files changed

Lines changed: 200 additions & 0 deletions

File tree

Dirbrute/Dirbrute_Script.py

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

Dirbrute/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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!
15+
16+
## Author(s)
17+
18+
Kalivarapubindusree

0 commit comments

Comments
 (0)