Skip to content

Commit

Permalink
Merge branch 'dev' into bbot-2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTechromancer authored Apr 19, 2024
2 parents f8694fd + 7c22371 commit d1c6d2e
Show file tree
Hide file tree
Showing 10 changed files with 268 additions and 225 deletions.
5 changes: 5 additions & 0 deletions bbot/core/event/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,11 @@ class _data_validator(BaseModel):
url: str
_validate_url = field_validator("url")(validators.validate_url)

def sanitize_data(self, data):
data = super().sanitize_data(data)
data["name"] = data["name"].lower()
return data

def _words(self):
return self.data["name"]

Expand Down
1 change: 1 addition & 0 deletions bbot/core/helpers/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from tabulate import tabulate
import wordninja as _wordninja
from contextlib import suppress
from unidecode import unidecode # noqa F401
import cloudcheck as _cloudcheck
import tldextract as _tldextract
import xml.etree.ElementTree as ET
Expand Down
4 changes: 3 additions & 1 deletion bbot/modules/deadly/dastardly.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ def parse_dastardly_xml(self, xml_file):
et = etree.parse(f)
for testsuite in et.iter("testsuite"):
yield TestSuite(testsuite)
except Exception as e:
except FileNotFoundError:
pass
except etree.ParseError as e:
self.warning(f"Error parsing Dastardly XML at {xml_file}: {e}")


Expand Down
2 changes: 2 additions & 0 deletions bbot/modules/github_org.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ async def handle_event(self, event):
user = event.data
self.verbose(f"Validating whether the organization {user} is within our scope...")
is_org, in_scope = await self.validate_org(user)
if "target" in event.tags:
in_scope = True
if not is_org or not in_scope:
self.verbose(f"Unable to validate that {user} is in-scope, skipping...")
return
Expand Down
4 changes: 3 additions & 1 deletion bbot/modules/internal/speculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ async def handle_event(self, event):
if registered_domain:
tld_stub = getattr(tldextracted, "domain", "")
if tld_stub:
org_stubs.add(tld_stub)
decoded_tld_stub = self.helpers.smart_decode_punycode(tld_stub)
org_stubs.add(decoded_tld_stub)
org_stubs.add(self.helpers.unidecode(decoded_tld_stub))
elif event.type == "SOCIAL":
stub = event.data.get("stub", "")
if stub:
Expand Down
5 changes: 3 additions & 2 deletions bbot/modules/templates/bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ async def handle_event(self, event):

async def handle_dns_name(self, event):
buckets = set()
base = event.data
base = self.helpers.unidecode(self.helpers.smart_decode_punycode(event.data))
stem = self.helpers.domain_stem(base)
for b in [base, stem]:
split = b.split(".")
for d in self.delimiters:
buckets.add(d.join(split))
bucket_name = d.join(split)
buckets.add(bucket_name)
async for bucket_name, url, tags in self.brute_buckets(buckets, permutations=self.permutations):
await self.emit_event({"name": bucket_name, "url": url}, "STORAGE_BUCKET", source=event, tags=tags)

Expand Down
11 changes: 11 additions & 0 deletions bbot/scanner/target.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
import logging
import ipaddress
from contextlib import suppress
Expand Down Expand Up @@ -86,6 +87,10 @@ def __init__(self, scan, *targets, strict_scope=False, make_in_scope=False):
self.scan = scan
self.strict_scope = strict_scope
self.make_in_scope = make_in_scope
self.special_event_types = {
"ORG_STUB": re.compile(r"^ORG:(.*)", re.IGNORECASE),
"ASN": re.compile(r"^ASN:(.*)", re.IGNORECASE),
}

self._dummy_module = TargetDummyModule(scan)
self._events = dict()
Expand Down Expand Up @@ -124,6 +129,12 @@ def add_target(self, t, event_type=None):
if is_event(t):
event = t
else:
for eventtype, regex in self.special_event_types.items():
match = regex.match(t)
if match:
t = match.groups()[0]
event_type = eventtype
break
try:
event = self.scan.make_event(
t,
Expand Down
9 changes: 9 additions & 0 deletions bbot/test/test_step_1/test_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,3 +444,12 @@ async def test_events(events, scan, helpers, bbot_config):
event_5 = scan.make_event("127.0.0.5", source=event_4)
assert event_5.get_sources() == [event_4, event_3, event_2, event_1, scan.root_event]
assert event_5.get_sources(omit=True) == [event_4, event_2, event_1, scan.root_event]

# test storage bucket validation
bucket_event = scan.make_event(
{"name": "ASDF.s3.amazonaws.com", "url": "https://ASDF.s3.amazonaws.com"},
"STORAGE_BUCKET",
source=scan.root_event,
)
assert bucket_event.data["name"] == "asdf.s3.amazonaws.com"
assert bucket_event.data["url"] == "https://asdf.s3.amazonaws.com/"
449 changes: 229 additions & 220 deletions poetry.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ omegaconf = "^2.3.0"
psutil = "^5.9.4"
wordninja = "^2.0.0"
ansible-runner = "^2.3.2"
deepdiff = "^6.2.3"
deepdiff = ">=6.2.3,<8.0.0"
xmltojson = "^2.0.2"
pycryptodome = "^3.17"
idna = "^3.4"
Expand All @@ -47,6 +47,7 @@ cloudcheck = ">=2.1.0.181,<4.0.0.0"
tldextract = "^5.1.1"
cachetools = "^5.3.2"
socksio = "^1.0.0"
unidecode = "^1.3.8"

[tool.poetry.group.dev.dependencies]
flake8 = ">=6,<8"
Expand Down

0 comments on commit d1c6d2e

Please sign in to comment.