|
1 | 1 | #!/usr/bin/env python3
|
2 | 2 | # -*- coding: utf-8 -*-
|
3 | 3 | #
|
4 |
| -# subchecker.py |
| 4 | +# dirbrute.py |
5 | 5 | #
|
6 | 6 | # Copyright 2019 bingo <bingo@hacklab>
|
7 | 7 | #
|
|
31 | 31 | \t __| (_)_ __| |__ _ __ _ _| |_ ___
|
32 | 32 | \t / _` | | '__| '_ \| '__| | | | __/ _ \\
|
33 | 33 | \t| (_| | | | | |_) | | | |_| | || __/
|
34 |
| -\t \__,_|_|_| |_.__/|_| \__,_|\__\___|"""+bold+"V: 1.5"+ end +blue+""" |
| 34 | +\t \__,_|_|_| |_.__/|_| \__,_|\__\___|"""+bold+"V: 1.6"+ end +blue+""" |
35 | 35 | \t
|
36 | 36 | \t Coded by: Bingo
|
37 | 37 | \t ---------------
|
|
40 | 40 |
|
41 | 41 | from concurrent.futures import ThreadPoolExecutor as executor
|
42 | 42 | import sys, time, requests
|
43 |
| - |
| 43 | +from optparse import * |
44 | 44 |
|
45 | 45 | start = time.time()
|
46 |
| -count = 0 |
47 | 46 |
|
48 | 47 | def printer(word):
|
49 | 48 | sys.stdout.write(word + " \r")
|
@@ -99,66 +98,78 @@ def checkstatus(domain, url):
|
99 | 98 | return False
|
100 | 99 |
|
101 | 100 |
|
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 |
145 | 133 |
|
146 |
| -#exit(0) |
| 134 | + if target.startswith("http"): |
| 135 | + target = target |
| 136 | + else: |
| 137 | + target = "http://" + target |
147 | 138 |
|
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] |
149 | 162 |
|
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) |
154 | 166 |
|
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") |
162 | 168 |
|
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) |
164 | 173 |
|
| 174 | +if __name__ == '__main__': |
| 175 | + Main() |
0 commit comments