Skip to content

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

Identify social media profile links based on names.

smicallef95ddd5b3fc60
diff --git a/modules/sfp_bingsearch.py b/modules/sfp_bingsearch.py
index 9cc56187..40f2ac0a 100644
--- a/modules/sfp_bingsearch.py
+++ b/modules/sfp_bingsearch.py
@@ -19,20 +19,18 @@ from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
sf = None
class sfp_bingsearch(SpiderFootPlugin):
- """Bing:Some light Bing scraping to identify sub-domains and co-hosted sites."""
+ """Bing:Some light Bing scraping to identify sub-domains and links."""
# Default options
opts = {
'fetchlinks': True, # Should we fetch links on the base domain?
- 'pages': 20, # Number of bing results pages to iterate
- 'cohostsamedomain': False
+ 'pages': 20 # Number of bing results pages to iterate
}
# Option descriptions
optdescs = {
'fetchlinks': "Fetch links found on the target domain-name?",
- 'pages': "Number of Bing results pages to iterate through.",
- 'cohostsamedomain': "Treat co-hosted sites on the same target domain as co-hosting?"
+ 'pages': "Number of Bing results pages to iterate through."
}
# Target
@@ -51,7 +49,7 @@ class sfp_bingsearch(SpiderFootPlugin):
# What events is this module interested in for input
def watchedEvents(self):
- return [ "IP_ADDRESS" ]
+ return None
# What events this module produces
# This is to support the end user in selecting modules based on events
@@ -60,119 +58,10 @@ class sfp_bingsearch(SpiderFootPlugin):
return [ "LINKED_URL_INTERNAL", "SEARCH_ENGINE_WEB_CONTENT",
"CO_HOSTED_SITE" ]
- # Handle events sent to this module
- def handleEvent(self, event):
- eventName = event.eventType
- srcModuleName = event.module
- eventData = event.data
- self.currentEventSrc = event
-
- sf.debug("Received event, " + eventName + ", from " + srcModuleName)
-
- # Don't look up stuff twice
- if eventData in self.results:
- sf.debug("Skipping " + eventData + " as already mapped.")
- return None
- else:
- self.results.append(eventData)
-
- results = self.bingIterate("ip:" + eventData, dict(limit=self.opts['pages']))
- myres = list()
- if results == None:
- sf.info("No data returned from Bing.")
- return None
-
- for key in results.keys():
- res = results[key]
- matches = re.findall("<div class=\"sb_meta\"><cite>(\S+)</cite>",
- res, re.IGNORECASE)
- for match in matches:
- sf.info("Found something on same IP: " + match)
- site = sf.urlFQDN(match)
- if site not in myres and site != eventData:
- if not self.opts['cohostsamedomain'] and site.endswith(self.baseDomain):
- sf.debug("Skipping " + site + " because it is on the same domain.")
- continue
- evt = SpiderFootEvent("CO_HOSTED_SITE", site, self.__name__, event)
- self.notifyListeners(evt)
- myres.append(site)
-
- # Submit the bing results for analysis
- evt = SpiderFootEvent("SEARCH_ENGINE_WEB_CONTENT", results[key],
- self.__name__, event)
- self.notifyListeners(evt)
-
- # Scrape Bing for content, starting at startUrl and iterating through
- # results based on options supplied. Will return a dictionary of all pages
- # fetched and their contents {page => content}.
- # Options accepted:
- # limit: number of search result pages before returning, default is 10
- # nopause: don't randomly pause between fetches
- def bingIterate(self, searchString, opts=dict()):
- limit = 10
- fetches = 0
- returnResults = dict()
-
- if opts.has_key('limit'):
- limit = opts['limit']
-
- # We attempt to make the URL look as authentically human as possible
- seedUrl = "http://www.bing.com/search?q={0}".format(searchString) + \
- "&pc=MOZI"
- firstPage = sf.fetchUrl(seedUrl, timeout=self.opts['_fetchtimeout'],
- useragent=self.opts['_useragent'])
- if firstPage['code'] == "403":
- sf.error("Bing doesn't like us right now..", False)
- return None
-
- if firstPage['content'] == None:
- sf.error("Failed to fetch content from Bing.", False)
- return None
-
- returnResults[seedUrl] = firstPage['content']
-
- matches = re.findall("(\/search\S+first=\d+.[^\'\"]*FORM=\S+)", firstPage['content'])
- while matches > 0 and fetches < limit:
- nextUrl = None
- fetches += 1
- for match in matches:
- # Bing moves in increments of 10
- if "first=" + str((fetches*10)+1) in match:
- nextUrl = match.replace("&amp;", "&").replace("%3a", ":")
-
- if nextUrl == None:
- sf.debug("Nothing left to scan for in Bing results.")
- return returnResults
- sf.info("Next Bing URL: " + nextUrl)
-
- # Wait for a random number of seconds between fetches
- if not opts.has_key('nopause'):
- pauseSecs = random.randint(4, 15)
- sf.info("Pausing for " + str(pauseSecs))
- time.sleep(pauseSecs)
-
- # Check if we've been asked to stop
- if self.checkForStop():
- return None
-
- nextPage = sf.fetchUrl('http://www.bing.com' + nextUrl,
- timeout=self.opts['_fetchtimeout'], useragent=self.opts['_useragent'])
- if firstPage['code'] == 403:
- sf.error("Bing doesn't like us any more..", False)
- return returnResults
-
- if nextPage['content'] == None:
- sf.error("Failed to fetch subsequent content from Bing.", False)
- return returnResults
-
- returnResults[nextUrl] = nextPage['content']
- matches = re.findall("(\/search\S+first=\d+.[^\'\"]*)", nextPage['content'], re.IGNORECASE)
-
- return returnResults
-
def start(self):
# Sites hosted on the domain
- pages = self.bingIterate("domain:" + self.baseDomain, dict(limit=self.opts['pages']))
+ pages = sf.bingIterate("site:" + self.baseDomain, dict(limit=self.opts['pages'],
+ useragent=self.opts['_useragent'], timeout=self.opts['_fetchtimeout']))
if pages == None:
sf.info("No results returned from Bing.")
return None
diff --git a/modules/sfp_googlesearch.py b/modules/sfp_googlesearch.py
index e98ac387..9d66e73b 100644
--- a/modules/sfp_googlesearch.py
+++ b/modules/sfp_googlesearch.py
@@ -19,7 +19,7 @@ from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
sf = None
class sfp_googlesearch(SpiderFootPlugin):
- """Google:Some light Google scraping to identify links for spidering."""
+ """Google:Some light Google scraping to identify sub-domains and links."""
# Default options
opts = {
diff --git a/modules/sfp_ir.py b/modules/sfp_ir.py
index b41e7be9..32c361f6 100644
--- a/modules/sfp_ir.py
+++ b/modules/sfp_ir.py
@@ -45,7 +45,8 @@ class sfp_ir(SpiderFootPlugin):
for opt in userOpts.keys():
self.opts[opt] = userOpts[opt]
- self.keyword = sf.domainKeyword(self.baseDomain, self.opts['_internettlds']).lower()
+ self.keyword = sf.domainKeyword(self.baseDomain,
+ self.opts['_internettlds']).lower()
# What events is this module interested in for input
def watchedEvents(self):
@@ -213,7 +214,6 @@ class sfp_ir(SpiderFootPlugin):
keywordList.append(self.keyword.replace('-', ' '))
keywordList.append(self.keyword.replace('-', '_'))
keywordList.append(self.keyword.replace('-', ''))
- # More versions in future..
for kw in keywordList:
for r in rx:
if re.match(r.format(kw), string, re.IGNORECASE) != None:
diff --git a/modules/sfp_sharedip.py b/modules/sfp_sharedip.py
new file mode 100644
index 00000000..a2d1c4ac
--- /dev/null
+++ b/modules/sfp_sharedip.py
@@ -0,0 +1,103 @@
+#-------------------------------------------------------------------------------
+# Name: sfp_sharedip
+# Purpose: Searches Bing and/or Robex.com for hosts sharing the same IP.
+#
+# Author: Steve Micallef <[email protected]>
+#
+# Created: 12/04/2014
+# Copyright: (c) Steve Micallef 2014
+# Licence: GPL
+#-------------------------------------------------------------------------------
+
+import sys
+import random
+import re
+import time
+from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
+
+# SpiderFoot standard lib (must be initialized in setup)
+sf = None
+
+class sfp_sharedip(SpiderFootPlugin):
+ """Shared IP:Search Bing and/or Robex.com for hosts sharing the same IP."""
+
+ # Default options
+ opts = {
+ 'cohostsamedomain': False,
+ 'pages': 20,
+ }
+
+ # Option descriptions
+ optdescs = {
+ 'cohostsamedomain': "Treat co-hosted sites on the same target domain as co-hosting?",
+ 'pages': "If using Bing, how many pages to iterate through."
+ }
+
+ # Target
+ baseDomain = None
+ results = list()
+
+ def setup(self, sfc, target, userOpts=dict()):
+ global sf
+
+ sf = sfc
+ self.baseDomain = target
+ self.results = list()
+
+ for opt in userOpts.keys():
+ self.opts[opt] = userOpts[opt]
+
+ # What events is this module interested in for input
+ def watchedEvents(self):
+ return [ "IP_ADDRESS" ]
+
+ # What events this module produces
+ # This is to support the end user in selecting modules based on events
+ # produced.
+ def producedEvents(self):
+ return [ "CO_HOSTED_SITE", "SEARCH_ENGINE_WEB_CONTENT" ]
+
+ # Handle events sent to this module
+ def handleEvent(self, event):
+ eventName = event.eventType
+ srcModuleName = event.module
+ eventData = event.data
+ self.currentEventSrc = event
+
+ sf.debug("Received event, " + eventName + ", from " + srcModuleName)
+
+ # Don't look up stuff twice
+ if eventData in self.results:
+ sf.debug("Skipping " + eventData + " as already mapped.")
+ return None
+ else:
+ self.results.append(eventData)
+
+ results = sf.bingIterate("ip:" + eventData, dict(limit=self.opts['pages'],
+ useragent=self.opts['_useragent'], timeout=self.opts['_fetchtimeout']))
+ myres = list()
+ if results == None:
+ sf.info("No data returned from Bing.")
+ return None
+
+ for key in results.keys():
+ res = results[key]
+ matches = re.findall("<div class=\"sb_meta\"><cite>(\S+)</cite>",
+ res, re.IGNORECASE)
+ for match in matches:
+ sf.info("Found something on same IP: " + match)
+ site = sf.urlFQDN(match)
+ if site not in myres and site != eventData:
+ if not self.opts['cohostsamedomain'] and site.endswith(self.baseDomain):
+ sf.debug("Skipping " + site + " because it is on the same domain.")
+ continue
+ evt = SpiderFootEvent("CO_HOSTED_SITE", site, self.__name__, event)
+ self.notifyListeners(evt)
+ myres.append(site)
+
+ # Submit the bing results for analysis
+ evt = SpiderFootEvent("SEARCH_ENGINE_WEB_CONTENT", results[key],
+ self.__name__, event)
+ self.notifyListeners(evt)
+
+# End of sfp_sharedip class
diff --git a/modules/sfp_socialprofiles.py b/modules/sfp_socialprofiles.py
new file mode 100644
index 00000000..d4629ff8
--- /dev/null
+++ b/modules/sfp_socialprofiles.py
@@ -0,0 +1,172 @@
+#-------------------------------------------------------------------------------
+# Name: sfp_socialprofiles
+# Purpose: Obtains social media profiles of any identified human names.
+#
+# Author: Steve Micallef <[email protected]>
+#
+# Created: 12/04/2014
+# Copyright: (c) Steve Micallef 2014
+# Licence: GPL
+#-------------------------------------------------------------------------------
+
+import sys
+import random
+import re
+import time
+import urllib
+from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
+
+# SpiderFoot standard lib (must be initialized in setup)
+sf = None
+
+sites = {
+ # Search string to use, domain name the profile will sit on within
+ # those search results.
+ "Facebook": ['+intitle:%22{0}%22%20+site:facebook.com',
+ '"(https?://[a-z\.]*facebook.[a-z\.]+/[^\"<> ]+)"' ],
+ "Google+": ['+intitle:%22{0}%22%20+site:plus.google.com',
+ '"(https?://plus.google.[a-z\.]+/\d+[^\"<>\/ ]+)"' ],
+ "LinkedIn": ['+intitle:%22{0}%22%20+site:linkedin.com',
+ '"(https?://[a-z\.]*linkedin.[a-z\.]+/[^\"<> ]+)"' ]
+}
+
+class sfp_socialprofiles(SpiderFootPlugin):
+ """Social Media Profiles:Identify the social media profiles for human names identified."""
+
+ # Default options
+ opts = {
+ 'pages': 1,
+ 'method': "yahoo",
+ 'tighten': False
+ }
+
+ # Option descriptions
+ optdescs = {
+ 'pages': "Number of search engine pages of identified profiles to iterate through.",
+ 'tighten': "Tighten results by expecting to find the keyword of the target domain mentioned in the results?",
+ 'method': "Search engine to use: google, yahoo or bing."
+ }
+
+ # Target
+ baseDomain = None
+ keyword = None
+ results = list()
+
+ def setup(self, sfc, target, userOpts=dict()):
+ global sf
+
+ sf = sfc
+ self.baseDomain = target
+ self.results = list()
+
+ for opt in userOpts.keys():
+ self.opts[opt] = userOpts[opt]
+
+ self.keyword = sf.domainKeyword(self.baseDomain,
+ self.opts['_internettlds']).lower()
+
+ # What events is this module interested in for input
+ def watchedEvents(self):
+ return [ "HUMAN_NAME" ]
+
+ # What events this module produces
+ # This is to support the end user in selecting modules based on events
+ # produced.
+ def producedEvents(self):
+ return [ "SOCIAL_MEDIA" ]
+
+ def yahooCleaner(self, string):
+ ret = "\"" + urllib.unquote(string.group(1)) + "\""
+ return ret
+
+ # Handle events sent to this module
+ def handleEvent(self, event):
+ eventName = event.eventType
+ srcModuleName = event.module
+ eventData = event.data
+ self.currentEventSrc = event
+
+ sf.debug("Received event, " + eventName + ", from " + srcModuleName)
+
+ # Don't look up stuff twice
+ if eventData in self.results:
+ sf.debug("Skipping " + eventData + " as already mapped.")
+ return None
+ else:
+ self.results.append(eventData)
+
+ for site in sites.keys():
+ searchStr = sites[site][0].format(eventData).replace(" ", "%20")
+ searchDom = sites[site][1]
+
+ if self.opts['method'].lower() == "google":
+ results = sf.googleIterate(searchStr, dict(limit=self.opts['pages'],
+ useragent=self.opts['_useragent'],
+ timeout=self.opts['_fetchtimeout']))
+
+ if self.opts['method'].lower() == "yahoo":
+ results = sf.yahooIterate(searchStr, dict(limit=self.opts['pages'],
+ useragent=self.opts['_useragent'],
+ timeout=self.opts['_fetchtimeout']))
+
+ if self.opts['method'].lower() == "bing":
+ results = sf.bingIterate(searchStr, dict(limit=self.opts['pages'],
+ useragent=self.opts['_useragent'],
+ timeout=self.opts['_fetchtimeout']))
+
+ if results == None:
+ sf.info("No data returned from " + self.opts['method'] + ".")
+ return None
+
+ if self.checkForStop():
+ return None
+
+ pauseSecs = random.randint(4, 15)
+ sf.debug("Pausing for " + str(pauseSecs))
+ time.sleep(pauseSecs)
+
+ for key in results.keys():
+ instances = list()
+ # Yahoo requires some additional parsing
+ if self.opts['method'].lower() == "yahoo":
+ res = re.sub("RU=(.[^\/]+)\/RK=", self.yahooCleaner,
+ results[key], 0)
+ else:
+ res = results[key]
+
+ matches = re.findall(searchDom, res, re.IGNORECASE)
+
+ if matches != None:
+ for match in matches:
+ if match in instances:
+ continue
+ else:
+ instances.append(match)
+
+ if self.checkForStop():
+ return None
+
+ # Fetch the profile page if we are checking
+ # for a firm relationship.
+ if self.opts['tighten']:
+ pres = sf.fetchUrl(match, timeout=self.opts['_fetchtimeout'],
+ useragent=self.opts['_useragent'])
+
+ if pres['content'] == None:
+ continue
+ else:
+ if not self.keyword in pres['content'] and \
+ not self.baseDomain in pres['content']:
+ continue
+
+ sf.info("Social Media Profile found at " + site + ": " + match)
+ evt = SpiderFootEvent("SOCIAL_MEDIA", match,
+ self.__name__, event)
+ self.notifyListeners(evt)
+
+ # Submit the bing results for analysis
+ evt = SpiderFootEvent("SEARCH_ENGINE_WEB_CONTENT", res,
+ self.__name__, event)
+ self.notifyListeners(evt)
+
+# End of sfp_socialprofiles class
diff --git a/sflib.py b/sflib.py
index 13240794..8336cd61 100644
--- a/sflib.py
+++ b/sflib.py
@@ -752,7 +752,8 @@ class SpiderFoot:
"&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a"
firstPage = self.fetchUrl(seedUrl, timeout=opts['timeout'],
useragent=opts['useragent'])
- if firstPage['code'] == 403 or firstPage['code'] == 503:
+ if firstPage['code'] == 403 or firstPage['code'] == 503 \
+ or "name=\"captcha\"" in firstPage['content']:
self.error("Google doesn't like us right now..", False)
return None
@@ -761,7 +762,8 @@ class SpiderFoot:
return None
returnResults[seedUrl] = firstPage['content']
- matches = re.findall("(\/search\S+start=\d+.[^\'\"]*sa=N)", firstPage['content'])
+ matches = re.findall("(\/search\S+start=\d+.[^\'\"]*sa=N)",
+ firstPage['content'])
while matches > 0 and fetches < limit:
nextUrl = None
@@ -784,7 +786,8 @@ class SpiderFoot:
nextPage = self.fetchUrl('http://www.google.com' + nextUrl,
timeout=opts['timeout'], useragent=opts['useragent'])
- if firstPage['code'] == 403 or firstPage['code'] == 503:
+ if nextPage['code'] == 403 or nextPage['code'] == 503 \
+ or "name=\"captcha\"" in nextPage['content']:
self.error("Google doesn't like us right now..", False)
return returnResults
@@ -793,10 +796,146 @@ class SpiderFoot:
return returnResults
returnResults[nextUrl] = nextPage['content']
- matches = re.findall("(\/search\S+start=\d+.[^\'\"]*)", nextPage['content'], re.IGNORECASE)
+ matches = re.findall("(\/search\S+start=\d+.[^\'\"]*)",
+ nextPage['content'], re.IGNORECASE)
return returnResults
+ # Scrape Bing for content, starting at startUrl and iterating through
+ # results based on options supplied. Will return a dictionary of all pages
+ # fetched and their contents {page => content}.
+ # Options accepted:
+ # limit: number of search result pages before returning, default is 10
+ # nopause: don't randomly pause between fetches
+ # useragent: User-Agent string to use
+ # timeout: Fetch timeout
+ def bingIterate(self, searchString, opts=dict()):
+ limit = 10
+ fetches = 0
+ returnResults = dict()
+
+ if opts.has_key('limit'):
+ limit = opts['limit']
+
+ # We attempt to make the URL look as authentically human as possible
+ seedUrl = "http://www.bing.com/search?q={0}".format(searchString) + \
+ "&pc=MOZI"
+ firstPage = self.fetchUrl(seedUrl, timeout=opts['timeout'],
+ useragent=opts['useragent'])
+ if firstPage['code'] == 400 or "/challengepic?" in firstPage['content']:
+ self.error("Bing doesn't like us right now..", False)
+ return None
+
+ if firstPage['content'] == None:
+ self.error("Failed to fetch content from Bing.", False)
+ return None
+
+ returnResults[seedUrl] = firstPage['content']
+
+ matches = re.findall("(\/search\S+first=\d+.[^\'\"]*FORM=\S+)",
+ firstPage['content'])
+ while matches > 0 and fetches < limit:
+ nextUrl = None
+ fetches += 1
+ for match in matches:
+ # Bing moves in increments of 10
+ if "first=" + str((fetches*10)+1) in match:
+ nextUrl = match.replace("&amp;", "&").replace("%3a", ":")
+
+ if nextUrl == None:
+ self.debug("Nothing left to scan for in Bing results.")
+ return returnResults
+ self.info("Next Bing URL: " + nextUrl)
+
+ # Wait for a random number of seconds between fetches
+ if not opts.has_key('nopause'):
+ pauseSecs = random.randint(4, 15)
+ self.info("Pausing for " + str(pauseSecs))
+ time.sleep(pauseSecs)
+
+ nextPage = self.fetchUrl('http://www.bing.com' + nextUrl,
+ timeout=opts['timeout'], useragent=opts['useragent'])
+ if nextPage['code'] == 400 or "/challengepic?" in nextPage['content']:
+ self.error("Bing doesn't like us any more..", False)
+ return returnResults
+
+ if nextPage['content'] == None:
+ self.error("Failed to fetch subsequent content from Bing.", False)
+ return returnResults
+
+ returnResults[nextUrl] = nextPage['content']
+ matches = re.findall("(\/search\S+first=\d+.[^\'\"]*)",
+ nextPage['content'], re.IGNORECASE)
+
+ return returnResults
+
+ # Scrape Yahoo for content, starting at startUrl and iterating through
+ # results based on options supplied. Will return a dictionary of all pages
+ # fetched and their contents {page => content}.
+ # Options accepted:
+ # limit: number of search result pages before returning, default is 10
+ # nopause: don't randomly pause between fetches
+ # useragent: User-Agent string to use
+ # timeout: Fetch timeout
+ def yahooIterate(self, searchString, opts=dict()):
+ limit = 10
+ fetches = 0
+ returnResults = dict()
+
+ if opts.has_key('limit'):
+ limit = opts['limit']
+
+ # We attempt to make the URL look as authentically human as possible
+ seedUrl = "https://search.yahoo.com/search?p={0}".format(searchString) + \
+ "&toggle=1&cop=mss&ei=UTF-8"
+ firstPage = self.fetchUrl(seedUrl, timeout=opts['timeout'],
+ useragent=opts['useragent'])
+ if firstPage['code'] == 403:
+ self.error("Yahoo doesn't like us right now..", False)
+ return None
+
+ if firstPage['content'] == None:
+ self.error("Failed to fetch content from Yahoo.", False)
+ return None
+
+ returnResults[seedUrl] = firstPage['content']
+
+ matches = re.findall("(\/search;\S+b=\d+.[^\'\"]*)",
+ firstPage['content'])
+ while matches > 0 and fetches < limit:
+ nextUrl = None
+ fetches += 1
+ for match in matches:
+ # Yahoo moves in increments of 10
+ if "b=" + str((fetches*10)+1) in match:
+ nextUrl = "https://search.yahoo.com" + match
+
+ if nextUrl == None:
+ self.debug("Nothing left to scan for in Yahoo results.")
+ return returnResults
+ self.info("Next Yahoo URL: " + nextUrl)
+
+ # Wait for a random number of seconds between fetches
+ if not opts.has_key('nopause'):
+ pauseSecs = random.randint(4, 15)
+ self.info("Pausing for " + str(pauseSecs))
+ time.sleep(pauseSecs)
+
+ nextPage = self.fetchUrl(nextUrl,
+ timeout=opts['timeout'], useragent=opts['useragent'])
+ if nextPage['code'] == 403:
+ self.error("Yahoo doesn't like us any more..", False)
+ return returnResults
+
+ if nextPage['content'] == None:
+ self.error("Failed to fetch subsequent content from Yahoo.", False)
+ return returnResults
+
+ returnResults[nextUrl] = nextPage['content']
+ matches = re.findall("(\/search;\S+b=\d+.[^\'\"]*)",
+ nextPage['content'], re.IGNORECASE)
+
+ return returnResults
#
# SpiderFoot plug-in module base class