From bdce64c6676b4fb701dfdd5ead676555cada7dca Mon Sep 17 00:00:00 2001 From: github-actions Date: Fri, 20 Dec 2024 16:53:33 -0500 Subject: [PATCH] fix cloudcheck bug --- bbot/core/event/base.py | 29 ++++++++++++++++------------- bbot/modules/internal/cloudcheck.py | 7 ++++++- bbot/modules/wpscan.py | 8 ++++---- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/bbot/core/event/base.py b/bbot/core/event/base.py index 1fb235bc25..3288257140 100644 --- a/bbot/core/event/base.py +++ b/bbot/core/event/base.py @@ -1564,19 +1564,22 @@ def __init__(self, *args, **kwargs): # detect type of file content using magic from bbot.core.helpers.libmagic import get_magic_info, get_compression - extension, mime_type, description, confidence = get_magic_info(self.data["path"]) - self.data["magic_extension"] = extension - self.data["magic_mime_type"] = mime_type - self.data["magic_description"] = description - self.data["magic_confidence"] = confidence - # detection compression - compression = get_compression(mime_type) - if compression: - self.add_tag("compressed") - self.add_tag(f"{compression}-archive") - self.data["compression"] = compression - # refresh hash - self.data = self.data + try: + extension, mime_type, description, confidence = get_magic_info(self.data["path"]) + self.data["magic_extension"] = extension + self.data["magic_mime_type"] = mime_type + self.data["magic_description"] = description + self.data["magic_confidence"] = confidence + # detection compression + compression = get_compression(mime_type) + if compression: + self.add_tag("compressed") + self.add_tag(f"{compression}-archive") + self.data["compression"] = compression + # refresh hash + self.data = self.data + except Exception as e: + log.debug(f"Error detecting file type: {type(e).__name__}: {e}") class RAW_DNS_RECORD(DictHostEvent, DnsEvent): diff --git a/bbot/modules/internal/cloudcheck.py b/bbot/modules/internal/cloudcheck.py index c45acfe954..82f4e164f4 100644 --- a/bbot/modules/internal/cloudcheck.py +++ b/bbot/modules/internal/cloudcheck.py @@ -41,7 +41,12 @@ async def handle_event(self, event, **kwargs): for i, host in enumerate(hosts_to_check): host_is_ip = self.helpers.is_ip(host) - for provider, provider_type, subnet in self.helpers.cloudcheck(host): + try: + cloudcheck_results = self.helpers.cloudcheck(host) + except Exception as e: + self.trace(f"Error running cloudcheck against {event} (host: {host}): {e}") + continue + for provider, provider_type, subnet in cloudcheck_results: if provider: event.add_tag(f"{provider_type}-{provider}") if host_is_ip: diff --git a/bbot/modules/wpscan.py b/bbot/modules/wpscan.py index 980d24fb5f..4f1a63a1b5 100644 --- a/bbot/modules/wpscan.py +++ b/bbot/modules/wpscan.py @@ -141,10 +141,10 @@ def construct_command(self, url): def parse_wpscan_output(self, output, base_url, source_event): json_output = json.loads(output) - interesting_json = json_output.get("interesting_findings", {}) - version_json = json_output.get("version", {}) - theme_json = json_output.get("main_theme", {}) - plugins_json = json_output.get("plugins", {}) + interesting_json = json_output.get("interesting_findings", {}) or {} + version_json = json_output.get("version", {}) or {} + theme_json = json_output.get("main_theme", {}) or {} + plugins_json = json_output.get("plugins", {}) or {} if interesting_json: yield from self.parse_wp_misc(interesting_json, base_url, source_event) if version_json: