Skip to content

Commit

Permalink
test new IP_RANGE / IP_ADDRESS filter for portscanners
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechromancer committed Dec 17, 2023
1 parent dbb90a3 commit ef74139
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions bbot/test/test_step_2/module_tests/test_module_nmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,23 @@


class TestNmap(ModuleTestBase):
targets = ["127.0.0.1"]
targets = ["127.0.0.1/31"]
config_overrides = {"modules": {"nmap": {"ports": "8888,8889"}}}

async def setup_after_prep(self, module_test):
# make sure our IP_RANGE / IP_ADDRESS filtering is working right
# IPs within the target IP range should be rejected
ip_event_1 = module_test.scan.make_event("127.0.0.0", source=module_test.scan.root_event)
ip_event_1.scope_distance = 0
assert (await module_test.module._event_postcheck(ip_event_1)) == (
False,
"it did not meet custom filter criteria: Skipping 127.0.0.0 because it is already included in 127.0.0.0/31",
)
# but ones outside should be accepted
ip_event_2 = module_test.scan.make_event("127.0.0.3", source=module_test.scan.root_event)
ip_event_2.scope_distance = 0
assert (await module_test.module._event_postcheck(ip_event_2))[0] == True

def check(self, module_test, events):
assert any(e.data == "127.0.0.1:8888" for e in events)
assert 1 == len([e for e in events if e.data == "127.0.0.1:8888"])
assert not any(e.data == "127.0.0.1:8889" for e in events)

0 comments on commit ef74139

Please sign in to comment.