Skip to content

armgit / bbot

Public Imported from GitHub
0

The recursive internet scanner for hackers. 🧡

events: show host in FINDING text output when not otherwise present

liquidsec87ebd0da0f51
diff --git a/bbot/core/event/base.py b/bbot/core/event/base.py
index f3e3f2b13..3f8b9aab7 100644
--- a/bbot/core/event/base.py
+++ b/bbot/core/event/base.py
@@ -2020,8 +2020,11 @@ class FINDING(ClosestHostEvent):
parts.append(f"Confidence: [{self.data['confidence']}]")
parts.append(self.data["description"])
url = self.data.get("url", "")
+ host = self.data.get("host", "")
if url and url not in self.data["description"]:
parts.append(f"({url})")
+ elif host and not url and host not in self.data["description"]:
+ parts.append(f"Host: [{host}]")
cves = self.data.get("cves", [])
if cves:
parts.append(f"[{', '.join(cves)}]")
diff --git a/bbot/test/test_step_1/test_events.py b/bbot/test/test_step_1/test_events.py
index a33117218..cc353ff72 100644
--- a/bbot/test/test_step_1/test_events.py
+++ b/bbot/test/test_step_1/test_events.py
@@ -417,8 +417,35 @@ async def test_events(events, helpers):
"FINDING",
dummy=True,
)
- assert test_vuln2.data_human == "Severity: [INFO] Confidence: [HIGH] asdf"
+ assert test_vuln2.data_human == "Severity: [INFO] Confidence: [HIGH] asdf Host: [192.168.1.1]"
assert test_vuln2.host.is_private
+ # host is not repeated when the description already contains it
+ test_vuln3 = scan.make_event(
+ {
+ "host": "www.evilcorp.com",
+ "severity": "INFO",
+ "confidence": "HIGH",
+ "description": "Something found on www.evilcorp.com",
+ "name": "Test Finding",
+ },
+ "FINDING",
+ dummy=True,
+ )
+ assert test_vuln3.data_human == "Severity: [INFO] Confidence: [HIGH] Something found on www.evilcorp.com"
+ # url takes the place of host when present
+ test_vuln4 = scan.make_event(
+ {
+ "host": "www.evilcorp.com",
+ "url": "http://www.evilcorp.com/admin",
+ "severity": "INFO",
+ "confidence": "HIGH",
+ "description": "asdf",
+ "name": "Test Finding",
+ },
+ "FINDING",
+ dummy=True,
+ )
+ assert test_vuln4.data_human == "Severity: [INFO] Confidence: [HIGH] asdf (http://www.evilcorp.com/admin)"
# must have severity
with pytest.raises(ValidationError, match=".*validation error.*\nseverity\n.*Field required.*"):
test_vuln = scan.make_event({"host": "evilcorp.com", "description": "asdf"}, "FINDING", dummy=True)