Skip to content

Commit 6d2ae67

Browse files
Merge pull request #2108 from blacklanternsecurity/misc-bugfixes
Small bugfixes in cloudcheck, wpscan, and filedownload
2 parents f6fdd79 + bdce64c commit 6d2ae67

File tree

3 files changed

+26
-18
lines changed

3 files changed

+26
-18
lines changed

bbot/core/event/base.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,19 +1578,22 @@ def __init__(self, *args, **kwargs):
15781578
# detect type of file content using magic
15791579
from bbot.core.helpers.libmagic import get_magic_info, get_compression
15801580

1581-
extension, mime_type, description, confidence = get_magic_info(self.data["path"])
1582-
self.data["magic_extension"] = extension
1583-
self.data["magic_mime_type"] = mime_type
1584-
self.data["magic_description"] = description
1585-
self.data["magic_confidence"] = confidence
1586-
# detection compression
1587-
compression = get_compression(mime_type)
1588-
if compression:
1589-
self.add_tag("compressed")
1590-
self.add_tag(f"{compression}-archive")
1591-
self.data["compression"] = compression
1592-
# refresh hash
1593-
self.data = self.data
1581+
try:
1582+
extension, mime_type, description, confidence = get_magic_info(self.data["path"])
1583+
self.data["magic_extension"] = extension
1584+
self.data["magic_mime_type"] = mime_type
1585+
self.data["magic_description"] = description
1586+
self.data["magic_confidence"] = confidence
1587+
# detection compression
1588+
compression = get_compression(mime_type)
1589+
if compression:
1590+
self.add_tag("compressed")
1591+
self.add_tag(f"{compression}-archive")
1592+
self.data["compression"] = compression
1593+
# refresh hash
1594+
self.data = self.data
1595+
except Exception as e:
1596+
log.debug(f"Error detecting file type: {type(e).__name__}: {e}")
15941597

15951598

15961599
class RAW_DNS_RECORD(DictHostEvent, DnsEvent):

bbot/modules/internal/cloudcheck.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ async def handle_event(self, event, **kwargs):
4141

4242
for i, host in enumerate(hosts_to_check):
4343
host_is_ip = self.helpers.is_ip(host)
44-
for provider, provider_type, subnet in self.helpers.cloudcheck(host):
44+
try:
45+
cloudcheck_results = self.helpers.cloudcheck(host)
46+
except Exception as e:
47+
self.trace(f"Error running cloudcheck against {event} (host: {host}): {e}")
48+
continue
49+
for provider, provider_type, subnet in cloudcheck_results:
4550
if provider:
4651
event.add_tag(f"{provider_type}-{provider}")
4752
if host_is_ip:

bbot/modules/wpscan.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ def construct_command(self, url):
141141

142142
def parse_wpscan_output(self, output, base_url, source_event):
143143
json_output = json.loads(output)
144-
interesting_json = json_output.get("interesting_findings", {})
145-
version_json = json_output.get("version", {})
146-
theme_json = json_output.get("main_theme", {})
147-
plugins_json = json_output.get("plugins", {})
144+
interesting_json = json_output.get("interesting_findings", {}) or {}
145+
version_json = json_output.get("version", {}) or {}
146+
theme_json = json_output.get("main_theme", {}) or {}
147+
plugins_json = json_output.get("plugins", {}) or {}
148148
if interesting_json:
149149
yield from self.parse_wp_misc(interesting_json, base_url, source_event)
150150
if version_json:

0 commit comments

Comments
 (0)