SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
fix: update docs & improve error handling
Amr Awad47dd8ac8905a
diff --git a/modules/sfp_bingsearch.py b/modules/sfp_bingsearch.pyindex fdaa16cd..b19be908 100644--- a/modules/sfp_bingsearch.py+++ b/modules/sfp_bingsearch.py@@ -13,7 +13,7 @@ from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEventclass sfp_bingsearch(SpiderFootPlugin):- """Bing:Footprint,Investigate,Passive:Search Engines::Obtain information from bing to identify sub-domains and links."""+ """Bing:Footprint,Investigate,Passive:Search Engines:apikey:Obtain information from bing to identify sub-domains and links."""# Default optionsopts = {"pages": 20, "api_key": ""}@@ -65,7 +65,7 @@ class sfp_bingsearch(SpiderFootPlugin):},)if results is None:- # Failed to talk to bing api or no results returned+ # Failed to talk to the bing API or no results returnedreturn Noneurls = results["urls"]new_links = list(set(urls) - set(self.results))diff --git a/modules/sfp_bingsharedip.py b/modules/sfp_bingsharedip.pyindex 514f18c8..ff5e6186 100644--- a/modules/sfp_bingsharedip.py+++ b/modules/sfp_bingsharedip.py@@ -31,7 +31,7 @@ class sfp_bingsharedip(SpiderFootPlugin):# Option descriptionsoptdescs = {"cohostsamedomain": "Treat co-hosted sites on the same target domain as co-hosting?",- "pages": "Number of max bing results to request from api.",+ "pages": "Number of max bing results to request from API.","verify": "Verify co-hosts are valid by checking if they still resolve to the shared IP.","maxcohost": "Stop reporting co-hosted sites after this many are found, as it would likely indicate web hosting.","api_key": "Bing API Key.",diff --git a/sflib.py b/sflib.pyindex bd67a27f..bcf01f08 100644--- a/sflib.py+++ b/sflib.py@@ -1302,15 +1302,15 @@ class SpiderFoot:return returnResults- # Request search results from bing api. Will return a dict:+ # Request search results from the bing API. Will return a dict:# {# "urls": a list of urls that match the query string,# "webSearchUrl": url for bing results page,# }# Options accepted:- # count: number of search results to request from the api+ # count: number of search results to request from the API# useragent: User-Agent string to use- # timeout: api call timeout+ # timeout: API call timeoutdef bingIterate(self, searchString, opts=dict()):endpoint = "https://api.cognitive.microsoft.com/bing/v7.0/search?"params = {@@ -1326,12 +1326,20 @@ class SpiderFoot:)if response['status'] != 'OK':- self.error("Failed to get a valid response from bing API", exception=False)+ self.error("Failed to get a valid response from the bing API", exception=False)return None- response_json = json.loads(response['content'])+ try:+ response_json = json.loads(response['content'])+ except ValueError:+ self.error("the key 'content' in the bing API response doesn't contain valid json.", exception=False)+ return None- if "webPages" in response_json:+ if (+ "webPages" in response_json+ and "value" in response_json["webPages"]+ and "webSearchUrl" in response_json["webPages"]+ ):results = {"urls": [result["url"] for result in response_json["webPages"]["value"]],"webSearchUrl": response_json["webPages"]["webSearchUrl"],