Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1365 #1434

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ exclude-subdirs = %%ff/,.;/,..;/,;/,./,../,%%2e/,%%2e%%2e/
random-user-agents = False
max-time = 0
exit-on-error = False
skip-on-status = 429
#subdirs = /,api/
#include-status = 200-299,401
#exclude-status = 400,500-999
Expand All @@ -25,7 +26,6 @@ exit-on-error = False
#exclude-regex = "^403$"
#exclude-redirect = "*/error.html"
#exclude-response = 404.html
#skip-on-status = 429,999

[dictionary]
default-extensions = php,asp,aspx,jsp,html,htm
Expand Down
50 changes: 21 additions & 29 deletions lib/core/fuzzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def __init__(
self._requester = requester
self._dictionary = dictionary
self._base_path: str = ""
self.exc: Exception | None = None
self.match_callbacks = match_callbacks
self.not_found_callbacks = not_found_callbacks
self.error_callbacks = error_callbacks
Expand Down Expand Up @@ -148,6 +147,7 @@ def __init__(
not_found_callbacks=not_found_callbacks,
error_callbacks=error_callbacks,
)
self._exc: Exception | None = None
self._threads = []
self._play_event = threading.Event()
self._quit_event = threading.Event()
Expand Down Expand Up @@ -207,8 +207,8 @@ def start(self) -> None:
thread.start()

def is_finished(self) -> bool:
if self.exc:
raise self.exc
if self._exc:
raise self._exc

for thread in self._threads:
if thread.is_alive():
Expand All @@ -232,7 +232,12 @@ def quit(self) -> None:

def scan(self, path: str) -> None:
scanners = self.get_scanners_for(path)
response = self._requester.request(path)
try:
response = self._requester.request(path)
except RequestException as e:
for callback in self.error_callbacks:
callback(e)
return

if self.is_excluded(response):
for callback in self.not_found_callbacks:
Expand All @@ -246,11 +251,8 @@ def scan(self, path: str) -> None:
callback(response)
return

try:
for callback in self.match_callbacks:
callback(response)
except Exception as e:
self.exc = e
for callback in self.match_callbacks:
callback(response)

def thread_proc(self) -> None:
logger.info(f'THREAD-{threading.get_ident()} started"')
Expand All @@ -263,11 +265,8 @@ def thread_proc(self) -> None:
except StopIteration:
break

except RequestException as e:
for callback in self.error_callbacks:
callback(e)

continue
except Exception as e:
self._exc = e

finally:
time.sleep(options["delay"])
Expand Down Expand Up @@ -359,12 +358,6 @@ async def start(self) -> None:

await asyncio.gather(*self._background_tasks)

def is_finished(self) -> bool:
if self.exc:
raise self.exc

return len(self._background_tasks) == 0

def play(self) -> None:
self._play_event.set()

Expand All @@ -377,7 +370,12 @@ def quit(self) -> None:

async def scan(self, path: str) -> None:
scanners = self.get_scanners_for(path)
response = await self._requester.request(path)
try:
response = await self._requester.request(path)
except RequestException as e:
for callback in self.error_callbacks:
callback(e)
return

if self.is_excluded(response):
for callback in self.not_found_callbacks:
Expand All @@ -391,11 +389,8 @@ async def scan(self, path: str) -> None:
callback(response)
return

try:
for callback in self.match_callbacks:
callback(response)
except Exception as e:
self.exc = e
for callback in self.match_callbacks:
callback(response)

async def task_proc(self) -> None:
async with self.sem:
Expand All @@ -406,8 +401,5 @@ async def task_proc(self) -> None:
await self.scan(self._base_path + path)
except StopIteration:
pass
except RequestException as e:
for callback in self.error_callbacks:
callback(e)
finally:
await asyncio.sleep(options["delay"])
Loading