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

Adding nuclei retries / batch_size option, test rework #799

Merged
merged 3 commits into from
Oct 23, 2023
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
7 changes: 7 additions & 0 deletions bbot/modules/deadly/nuclei.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ class nuclei(BaseModule):
"etags": "",
"budget": 1,
"directory_only": True,
"retries": 0,
"batch_size": 200,
}
options_desc = {
"version": "nuclei version",
Expand All @@ -33,6 +35,8 @@ class nuclei(BaseModule):
"etags": "tags to exclude from the scan",
"budget": "Used in budget mode to set the number of requests which will be alloted to the nuclei scan",
"directory_only": "Filter out 'file' URL event (default True)",
"retries": "number of times to retry a failed request (default 0)",
"batch_size": "Number of targets to send to Nuclei per batch (default 200)",
}
deps_ansible = [
{
Expand Down Expand Up @@ -84,6 +88,7 @@ async def setup(self):
self.info(f"Limiting nuclei templates to the following severites: [{self.severity}]")
self.iserver = self.scan.config.get("interactsh_server", None)
self.itoken = self.scan.config.get("interactsh_token", None)
self.retries = int(self.config.get("retries", 0))

if self.mode not in ("technology", "severe", "manual", "budget"):
self.warning(f"Unable to initialize nuclei: invalid mode selected: [{self.mode}]")
Expand Down Expand Up @@ -184,6 +189,8 @@ async def execute_nuclei(self, nuclei_input):
self.concurrency,
"-disable-update-check",
"-stats-json",
"-retries",
self.retries,
]

if self.helpers.system_resolvers:
Expand Down
35 changes: 32 additions & 3 deletions bbot/test/test_step_2/module_tests/test_module_nuclei.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ class TestNucleiTechnology(TestNucleiManual):
}

async def setup_before_prep(self, module_test):
self.caplog = module_test.request_fixture.getfixturevalue("caplog")
expect_args = {"method": "GET", "uri": "/"}
respond_args = {
"response_data": "<html><Directory></Directory></html>",
Expand All @@ -98,10 +97,11 @@ async def setup_before_prep(self, module_test):
module_test.set_expect_requests(expect_args=expect_args, respond_args=respond_args)

def check(self, module_test, events):
if "Using Interactsh Server" in self.caplog.text:
return False
assert any(e.type == "FINDING" and "apache" in e.data["description"] for e in events)

with open(module_test.scan.home / "debug.log") as f:
assert "Using Interactsh Server" not in f.read()


class TestNucleiBudget(TestNucleiManual):
config_overrides = {
Expand All @@ -123,3 +123,32 @@ async def setup_before_prep(self, module_test):

def check(self, module_test, events):
assert any(e.type == "FINDING" and "SpiderFoot" in e.data["description"] for e in events)


class TestNucleiRetries(TestNucleiManual):
config_overrides = {
"interactsh_disable": True,
"modules": {"nuclei": {"tags": "musictraveler"}},
}

async def setup_before_prep(self, module_test):
expect_args = {"method": "GET", "uri": "/"}
respond_args = {
"response_data": "content",
}
module_test.set_expect_requests(expect_args=expect_args, respond_args=respond_args)

def check(self, module_test, events):
with open(module_test.scan.home / "debug.log") as f:
assert "-retries 0" in f.read()


class TestNucleiRetriesCustom(TestNucleiRetries):
config_overrides = {
"interactsh_disable": True,
"modules": {"nuclei": {"tags": "musictraveler", "retries": 1}},
}

def check(self, module_test, events):
with open(module_test.scan.home / "debug.log") as f:
assert "-retries 1" in f.read()
2 changes: 2 additions & 0 deletions docs/modules/nuclei.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ The Nuclei module has many configuration options:
| etags | Tags to exclude from the scan | <blank> |
| directory_only | When on, limits scan to only "directory" URLs (omit endpoints) | True |
| budget | Used in budget mode to set the number of requests which will be allotted | 1 |
| retries | Mumber of times to retry a failed request | 0 |
| batch_size | The number of targets BBOT will pass to Nuclei at a time | 200 |

Most of these you probably will **NOT** want to change. In particular, we strongly advise against changing the version of Nuclei, as it's very likely the latest version won't work right with BBOT.

Expand Down