Skip to content

SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.

refactor: clean up url generation in googleIterate

Amr Awad2e31c9fb576d
diff --git a/modules/sfp_onioncity.py b/modules/sfp_onioncity.py
index 0837f9b6..eee3e532 100644
--- a/modules/sfp_onioncity.py
+++ b/modules/sfp_onioncity.py
@@ -64,7 +64,7 @@ class sfp_onioncity(SpiderFootPlugin):
# Sites hosted on the domain
results = 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.py
index 3f8f0689..db5f400e 100644
--- a/modules/sfp_pastebin.py
+++ b/modules/sfp_pastebin.py
@@ -67,7 +67,7 @@ class sfp_pastebin(SpiderFootPlugin):
links = list()
target = self.domains[dom]
results = self.sf.googleIterate(
- searchString="site:" + target + "%20+\"" + eventData + "\"",
+ searchString="site:" + target + " \"" + eventData + "\"",
opts={
"timeout": self.opts["_fetchtimeout"],
"useragent": self.opts["_useragent"],
diff --git a/sflib.py b/sflib.py
index 74fd0e81..1f875732 100644
--- a/sflib.py
+++ b/sflib.py
@@ -1233,9 +1233,15 @@ class SpiderFoot:
if "items" in response_json:
# We attempt to make the URL look as authentically human as possible
- search_url = u"https://www.google.com/search?q={0}".format(searchString) + \
- u"&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a"
-
+ params = {
+ "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)
results = {
"urls": [str(k['link']) for k in response_json['items']],
"webSearchUrl": search_url,
@@ -1262,6 +1268,7 @@ class SpiderFoot:
"responseFilter": "Webpages",
"count": opts["count"],
}
+
response = self.fetchUrl(
endpoint + urllib.urlencode(params),
timeout=opts["timeout"],