Skip to content

Commit dd335c4

Browse files
Forced_Browse script added
1 parent be54e99 commit dd335c4

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed

Forced_Browse/Forced_Browse.py

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
2+
import sys
3+
import time
4+
import requests
5+
from concurrent.futures import ThreadPoolExecutor as executor
6+
from optparse import OptionParser
7+
8+
def printer(word):
9+
sys.stdout.write(word + " \r")
10+
sys.stdout.flush()
11+
return True
12+
13+
yellow = "\033[93m"
14+
green = "\033[92m"
15+
blue = "\033[94m"
16+
red = "\033[91m"
17+
bold = "\033[1m"
18+
end = "\033[0m"
19+
20+
def check_status(domain, url):
21+
if not url or url.startswith("#") or len(url) > 30:
22+
return False
23+
24+
printer("Testing: " + domain + url)
25+
try:
26+
link = domain + url
27+
req = requests.head(link)
28+
st = str(req.status_code)
29+
if st.startswith(("2", "1")):
30+
print(green + "[+] " + st + " | Found: " + end + "[ " + url + " ]" + " \r")
31+
elif st.startswith("3"):
32+
link = req.headers['Location']
33+
print(yellow + "[*] " + st + " | Redirection From: " + end + "[ " + url + " ]" + yellow + " -> " + end + "[ " + link + " ]" + " \r")
34+
elif st.startswith("4"):
35+
if st != '404':
36+
print(blue + "[!] " + st + " | Found: " + end + "[ " + url + " ]" + " \r")
37+
return True
38+
except Exception:
39+
return False
40+
41+
def presearch(domain, ext, url):
42+
if ext == 'Null' or ext == 'None':
43+
check_status(domain, url)
44+
elif url and not url.isspace():
45+
ext_list = [ext] if ext != "None" else [""]
46+
for i in ext_list:
47+
link = url if not i else url + "." + str(i)
48+
check_status(domain, link)
49+
50+
def main():
51+
parser = OptionParser(green + """
52+
#Usage:""" + yellow + """
53+
-t target host
54+
-w wordlist
55+
-d thread number (Optional, Default: 10)
56+
-e extensions (Optional, ex: html,php)
57+
""" + green + """
58+
#Example:""" + yellow + """
59+
python3 dirbrute.py -t domain.com -w dirlist.txt -d 20 -e php,html
60+
""" + end)
61+
62+
try:
63+
parser.add_option("-t", dest="target", type="string", help="the target domain")
64+
parser.add_option("-w", dest="wordlist", type="string", help="wordlist file")
65+
parser.add_option("-d", dest="thread", type="int", help="the thread number")
66+
parser.add_option("-e", dest="extension", type="string", help="the extensions")
67+
(options, _) = parser.parse_args()
68+
69+
if not options.target or not options.wordlist:
70+
print(parser.usage)
71+
exit(1)
72+
73+
target = options.target
74+
wordlist = options.wordlist
75+
thread = options.thread if options.thread else 10
76+
ext = options.extension if options.extension else "Null"
77+
78+
target = target if target.startswith("http") else "http://" + target
79+
target = target if target.endswith("/") else target + "/"
80+
81+
print("[" + yellow + bold + "Info" + end + "]:\n")
82+
print(blue + "[" + red + "+" + blue + "] Target: " + end + target)
83+
print(blue + "[" + red + "+" + blue + "] File: " + end + wordlist)
84+
print(blue + "[" + red + "+" + blue + "] Thread: " + end + str(thread))
85+
print(blue + "[" + red + "+" + blue + "] Extension: " + end + str(ext))
86+
print("\n[" + yellow + bold + "Start Searching" + end + "]:\n")
87+
88+
ext_list = ext.split(",") if ext != "Null" else ["Null"]
89+
with open(wordlist, 'r') as urls:
90+
with executor(max_workers=int(thread)) as exe:
91+
jobs = [exe.submit(presearch, target, ext, url.strip('\n')) for url in urls]
92+
93+
took = (time.time() - start) / 60
94+
print(red + "Took: " + end + f"{round(took, 2)} m" + " \r")
95+
96+
print("\n\t* Happy Hacking *")
97+
98+
except Exception as e:
99+
print(red + "#Error: " + end + str(e))
100+
exit(1)
101+
102+
if __name__ == '__main__':
103+
start = time.time()
104+
main()

Forced_Browse/README.md

Whitespace-only changes.

0 commit comments

Comments
 (0)