SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
fix: stop url encoding the search string
Amr Awad62b8d34dc5ae
diff --git a/modules/sfp_onioncity.py b/modules/sfp_onioncity.pyindex eee3e532..a2775616 100644--- a/modules/sfp_onioncity.py+++ b/modules/sfp_onioncity.py@@ -64,7 +64,7 @@ class sfp_onioncity(SpiderFootPlugin):# Sites hosted on the domainresults = self.sf.googleIterate(- searchString="site:onion.link " + eventData,+ searchString="+site:onion.link " + eventData,opts={"timeout": self.opts["_fetchtimeout"],"useragent": self.opts["_useragent"],diff --git a/modules/sfp_pastebin.py b/modules/sfp_pastebin.pyindex db5f400e..9ca2577c 100644--- a/modules/sfp_pastebin.py+++ b/modules/sfp_pastebin.py@@ -67,7 +67,10 @@ class sfp_pastebin(SpiderFootPlugin):links = list()target = self.domains[dom]results = self.sf.googleIterate(- searchString="site:" + target + " \"" + eventData + "\"",+ searchString="+site:{target_site} \"{search_keyword}\"".format(+ target_site=target,+ search_keyword=eventData,+ ),opts={"timeout": self.opts["_fetchtimeout"],"useragent": self.opts["_useragent"],@@ -75,6 +78,7 @@ class sfp_pastebin(SpiderFootPlugin):"cse_id": self.opts["cse_id"],},)+if results is None:# Failed to talk to the Google API or no results returnedreturn Nonediff --git a/modules/sfp_socialprofiles.py b/modules/sfp_socialprofiles.pyindex fe37c39a..ee7c21cc 100644--- a/modules/sfp_socialprofiles.py+++ b/modules/sfp_socialprofiles.py@@ -20,21 +20,21 @@ sites = {# Search string to use, domain name the profile will sit on within# those search results."Facebook": [- "\"{0}\" site:facebook.com",+ "\"{name}\"+site:facebook.com",['"(https?://[a-z\.]*facebook.[a-z\.]+/[^/"<> ]+)"','(https?%3a%2f%2f[a-z\.]*facebook.[a-z\.]+%2f[^\/"<> ]+)',],],"Google+": [- "\"{0}\" site:plus.google.com",+ "\"{name}\"+site:plus.google.com",['"(https?://plus.google.[a-z\.]+/\d+[^"<>\/ ]+)"','(https?%3a%2f%2fplus.google.[a-z\.]+%2f\d+[^\/"<> ]+)',],],"LinkedIn": [- "\"{0}\" site:linkedin.com",+ "\"{name}\"+site:linkedin.com",['"(https?://[a-z\.]*linkedin.[a-z\.]+/[^/"<> ]+)"','(https?%3a%2f%2f[a-z\.]*linkedin.[a-z\.]+%2f[^\/"<> ]+)',@@ -111,7 +111,7 @@ class sfp_socialprofiles(SpiderFootPlugin):self.keywords = Nonefor site in sites:- s = unicode(sites[site][0]).format(eventData)+ s = unicode(sites[site][0]).format(name=eventData)searchStr = s.replace(" ", "%20")results = None@@ -172,11 +172,16 @@ class sfp_socialprofiles(SpiderFootPlugin):self.notifyListeners(evt)+ instances = list()for searchDom in sites[site][1]:+ # Search both the urls & the search engine web content+ search_string = " ".join(results["urls"] + [response["content"]])+matches = re.findall(- searchDom, response["content"], re.IGNORECASE | re.MULTILINE+ searchDom, search_string, re.IGNORECASE | re.MULTILINE)+ import pdb; pdb.set_trace()if not matches:continuediff --git a/sflib.py b/sflib.pyindex 1f875732..9b9c68b8 100644--- a/sflib.py+++ b/sflib.py@@ -1208,9 +1208,10 @@ class SpiderFoot:# useragent: User-Agent string to use# timeout: API call timeoutdef googleIterate(self, searchString, opts=dict()):- endpoint = "https://www.googleapis.com/customsearch/v1?"+ endpoint = "https://www.googleapis.com/customsearch/v1?q={search_string}&".format(+ search_string=searchString.replace(" ", "%20")+ )params = {- "q": searchString,"cx": opts["cse_id"],"key": opts["api_key"],}@@ -1218,7 +1219,6 @@ class SpiderFoot:response = self.fetchUrl(endpoint + urllib.urlencode(params),timeout=opts["timeout"],- useragent=opts["useragent"],)if response['status'] != 'OK':@@ -1234,14 +1234,16 @@ class SpiderFoot:if "items" in response_json:# We attempt to make the URL look as authentically human as possibleparams = {- "q": searchString,"ie": "utf-8","oe": "utf-8","aq": "t","rls": "org.mozilla:en-US:official","client": "firefox-a",}- search_url = u"https://www.google.com/search?" + urllib.urlencode(params)+ search_url = u"https://www.google.com/search?q={search_string}&{params}".format(+ search_string=searchString.replace(" ", "%20"),+ params=urllib.urlencode(params)+ )results = {"urls": [str(k['link']) for k in response_json['items']],"webSearchUrl": search_url,@@ -1262,12 +1264,14 @@ class SpiderFoot:# useragent: User-Agent string to use# timeout: API call timeoutdef bingIterate(self, searchString, opts=dict()):- endpoint = "https://api.cognitive.microsoft.com/bing/v7.0/search?"+ endpoint = "https://api.cognitive.microsoft.com/bing/v7.0/search?q={search_string}&".format(+ search_string=SearchString.replace(" ", "%20")+ )+params = {- "q": searchString,- "responseFilter": "Webpages",- "count": opts["count"],- }+ "responseFilter": "Webpages",+ "count": opts["count"],+ }response = self.fetchUrl(endpoint + urllib.urlencode(params),