Skip to content

Commit 47de416

Browse files
author
AnonymOnline
committed
changed project structure and fixed bugs in buildURL
1 parent 03f7305 commit 47de416

File tree

10 files changed

+61
-36
lines changed

10 files changed

+61
-36
lines changed

URL_Fuzzer/__init__.py renamed to Fuzzix.py

+20-17
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import argparse
22

3-
from Data import Host, URL, Settings, Dir
4-
from util import WebApi, logger, Content_Worker, Content, TERMINATE_WORKER
3+
from Fuzzix.Data import Host, URL, Settings, Dir
4+
from Fuzzix.Util import WebApi, Content_Worker, Content, TERMINATE_WORKER
5+
from Fuzzix import Logger
56

67
settings = None
78

@@ -15,19 +16,19 @@ def __init__(self, host):
1516
else:
1617
raise ValueError("wrong type for attribute host!")
1718

18-
logger.info("fuzzing url", self.host.getURL())
19+
Logger.info("fuzzing url", self.host.getURL())
1920

2021
def spider(self):
2122
"""
2223
spider-routine of the URL_Fuzzer
2324
return: None
2425
"""
2526

26-
logger.info("Spidering URL", self.host.getURL())
27+
Logger.info("Spidering URL", self.host.getURL())
2728
rootcontent = Content(self.host.getURL())
2829
Content_Worker.queue.put(rootcontent)
2930
for i in range(0, Settings.readAttribute("recursion_depth",0)):
30-
logger.info('Processing recursion', i, Content_Worker.queue.qsize(), 'tasks to be done')
31+
Logger.info('Processing recursion', i, Content_Worker.queue.qsize(), 'tasks to be done')
3132
Content_Worker.queue.join()
3233

3334
while not Content_Worker.done.empty():
@@ -49,18 +50,19 @@ def spider(self):
4950
self.host.getRootdir().appendPath(path, length)
5051
Content_Worker.queue.put(newContent)
5152
except ValueError as e:
52-
continue
53-
53+
Logger.error(e)
54+
else:
55+
Logger.error('received error ' + str(content.getStatus()) + ' for ' + content.getURL().getURL())
5456
self.host.getRootdir().printDirs()
55-
logger.info("spidering completed")
57+
Logger.info("spidering completed")
5658

5759

5860

5961
def fuzz(self):
60-
logger.info("fuzzing URL", self.host.getURL())
62+
Logger.info("fuzzing URL", self.host.getURL())
6163

6264

63-
logger.info("fuzzing completed")
65+
Logger.info("fuzzing completed")
6466

6567

6668

@@ -102,6 +104,7 @@ def startup():
102104
Settings.writeAttribute("verify_cert",verify_cert)
103105
Settings.writeAttribute("threads",threads)
104106
Settings.writeAttribute("recursion_depth",recursion_depth)
107+
Settings.readConfig("config/config.ini")
105108

106109
WebApi.setProtocol(URL(Settings.readAttribute("host_url","")).getProto())
107110
except ValueError as e:
@@ -115,12 +118,12 @@ def startWorkers(amount=4):
115118
return: None
116119
"""
117120

118-
logger.info("Starting " + str(amount) + " threads")
121+
Logger.info("Starting " + str(amount) + " threads")
119122
for i in range(0, amount):
120123
c = Content_Worker()
121124
c.start()
122125
Content_Worker.workers.append(c)
123-
logger.info("Threads started")
126+
Logger.info("Threads started")
124127

125128

126129
def stopWorkers():
@@ -129,13 +132,13 @@ def stopWorkers():
129132
return: None
130133
"""
131134

132-
logger.info("stopping workers")
135+
Logger.info("stopping workers")
133136
for w in Content_Worker.workers:
134137
Content_Worker.queue.put(TERMINATE_WORKER)
135138
for w in Content_Worker.workers:
136139
w.join()
137140

138-
logger.info("stopped workers")
141+
Logger.info("stopped workers")
139142

140143

141144
def shutdown():
@@ -147,9 +150,9 @@ def shutdown():
147150
try:
148151
stopWorkers()
149152
except:
150-
logger.error("failed to stop threads!")
153+
Logger.error("failed to stop threads!")
151154

152-
logger.info("finished scan")
155+
Logger.info("finished scan")
153156
exit()
154157

155158

@@ -159,7 +162,7 @@ def shutdown():
159162
startup()
160163
startWorkers(Settings.readAttribute("threads",4))
161164
except ValueError as e:
162-
logger.error(e)
165+
Logger.error(e)
163166
exit()
164167

165168
targetHost = Host(

URL_Fuzzer/Data.py renamed to Fuzzix/Data.py

+32-6
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,39 @@ def buildURL(proto, host, port, dir, file):
202202
builds an URL out of the given parameters
203203
attribute proto: the used protocol as str
204204
attribute host: the target host as str
205-
attribute port: the target port as int
205+
attribute port: the target port as int -> warning, currently not supported!
206206
attribute dir: the target dir as str
207207
attribute file: the target file as str
208208
return: the crafted URL of type str
209209
"""
210-
return proto + "://" + host + (
211-
"/" + dir + "/" + file + ":" + str(port) if len((dir + file).replace('/', '')) > 0 else ":" + str(port))
210+
if dir.startswith('/'):
211+
dir = dir[1:]
212+
if dir.endswith('/'):
213+
dir = dir[:-1]
214+
file.replace('/','')
215+
216+
path = ''
217+
if (dir+file).endswith('/'):
218+
if not file:
219+
path = '/' + dir[:-1]
220+
else:
221+
if not dir:
222+
path = '/' + file[:-1]
223+
else:
224+
path = '/' + dir + '/' + file[:-1]
225+
else:
226+
if not dir:
227+
if not file:
228+
path = ''
229+
else:
230+
path = '/' + file
231+
else:
232+
if not file:
233+
path = '/' + dir
234+
else:
235+
path = '/' + dir + '/' + file
236+
237+
return proto + "://" + host + path
212238

213239
@staticmethod
214240
def prettifyURL(host, rootURL, url):
@@ -231,7 +257,7 @@ def prettifyURL(host, rootURL, url):
231257
try:
232258
return URL(url)
233259
except ValueError:
234-
raise ValueError('couldn\'t prettify URL' + url + ' it is not valid')
260+
raise ValueError('couldn\'t prettify URL' + url + ' found in ' + rootURL.getURL() + ' it is not valid')
235261

236262
@staticmethod
237263
def isValidURL(url):
@@ -295,7 +321,7 @@ def readConfig(self,path):
295321
"""
296322
configFile = configparser.ConfigParser()
297323
configFile.read(path)
298-
if configFile.sections() <= 0:
324+
if len(configFile.sections()) <= 0:
299325
raise ValueError("given config empty or not existend")
300326
for section in configFile.sections():
301327
for key in configFile[section]:
@@ -328,4 +354,4 @@ def readAttribute(self,key,default):
328354
def printConfig(self):
329355
for key in self.config:
330356
print(key + " : " + self.config[key])
331-
Settings = __Settings__()
357+
Settings = __Settings__()

URL_Fuzzer/util.py renamed to Fuzzix/Util.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,10 @@
44

55
import threading
66
from queue import Queue
7-
from coloredlogger import ColoredLogger
87
from bs4 import BeautifulSoup
98

10-
logger = ColoredLogger(name="MAIN")
11-
12-
from Data import URL
13-
from Data import HTTP
14-
from Data import Host
15-
from Data import Dir
16-
from Data import File
9+
from Fuzzix import Logger
10+
from Fuzzix.Data import URL, HTTP, Host, Dir, File
1711

1812

1913
class __WebApi__:

Fuzzix/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
from coloredlogger import ColoredLogger
2+
Logger = ColoredLogger(name="MAIN")

URL_Fuzzer/config/config.ini

-5
This file was deleted.

config/config.ini

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[WORDLISTS]
2+
directories = worlists/directories.txt
3+
extensions = worlists/extensions.txt
4+
files = worlists/files.txt
5+
mutations = worlists/mutations.txt
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)