SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
Footprinting names and reduced false positives with name detection.
Steve Micallef0824c74f3433
diff --git a/modules/sfp_accounts.py b/modules/sfp_accounts.pyindex ce97ea97..f4fc0ff9 100644--- a/modules/sfp_accounts.py+++ b/modules/sfp_accounts.py@@ -78,7 +78,7 @@ class sfp_accounts(SpiderFootPlugin):# What events is this module interested in for input# * = be notified about all events.def watchedEvents(self):- return ["EMAILADDR", "DOMAIN_NAME"]+ return ["EMAILADDR", "DOMAIN_NAME", "HUMAN_NAME", "USERNAME"]# What events this module produces# This is to support the end user in selecting modules based on events@@ -196,6 +196,10 @@ class sfp_accounts(SpiderFootPlugin):self.sf.debug("Received event, " + eventName + ", from " + srcModuleName)+ # Skip events coming from me unless they are USERNAME events+ if eventName != "USERNAME" and srcModuleName == "sfp_accounts":+ return None+if eventData not in self.results.keys():self.results[eventData] = Trueelse:@@ -216,6 +220,16 @@ class sfp_accounts(SpiderFootPlugin):self.sites = [d for d in self.sites if d['name'] not in delsites]self.distrustedChecked = True+ if eventName == "HUMAN_NAME":+ names = [ eventData.lower().replace(" ", ""), eventData.lower().replace(" ", ".") ]+ for name in names:+ res = self.batchSites(name)+ for site in res:+ evt = SpiderFootEvent("ACCOUNT_EXTERNAL_OWNED", site,+ self.__name__, event)+ self.notifyListeners(evt)+ users.append(name)+if eventName == "DOMAIN_NAME":kw = self.sf.domainKeyword(eventData, self.opts['_internettlds'])@@ -224,34 +238,30 @@ class sfp_accounts(SpiderFootPlugin):evt = SpiderFootEvent("ACCOUNT_EXTERNAL_OWNED", site,self.__name__, event)self.notifyListeners(evt)- return None+ users.append(kw)if eventName == "EMAILADDR":name = eventData.split("@")[0].lower()+ adduser = Trueif self.opts['generic'] is list() and name in self.opts['generic']:self.sf.debug(name + " is a generic account name, skipping.")- return None+ adduser = Falseif self.opts['ignorenamedict'] and name in self.commonNames:self.sf.debug(name + " is found in our name dictionary, skipping.")- return None+ adduser = Falseif self.opts['ignoreworddict'] and name in self.words:self.sf.debug(name + " is found in our word dictionary, skipping.")- return None-- users.append(name)- for user in users:- if user not in self.reportedUsers:- evt = SpiderFootEvent("USERNAME", user, self.__name__, event)- self.notifyListeners(evt)- self.reportedUsers.append(user)+ adduser = False- res = self.batchSites(user)+ if adduser:+ users.append(name)- for site in res:- evt = SpiderFootEvent("ACCOUNT_EXTERNAL_USER_SHARED", site,- self.__name__, event)- self.notifyListeners(evt)+ for user in users:+ if user not in self.reportedUsers:+ evt = SpiderFootEvent("USERNAME", user, self.__name__, event)+ self.notifyListeners(evt)+ self.reportedUsers.append(user)# End of sfp_accounts classdiff --git a/modules/sfp_arin.py b/modules/sfp_arin.pyindex 149cda08..f7ff368a 100644--- a/modules/sfp_arin.py+++ b/modules/sfp_arin.py@@ -26,7 +26,6 @@ class sfp_arin(SpiderFootPlugin):results = dict()currentEventSrc = NonememCache = dict()- nbreported = dict()keywords = Nonedef setup(self, sfc, userOpts=dict()):@@ -34,7 +33,6 @@ class sfp_arin(SpiderFootPlugin):self.results = dict()self.memCache = dict()self.currentEventSrc = None- self.nbreported = dict()for opt in userOpts.keys():self.opts[opt] = userOpts[opt]@@ -47,7 +45,7 @@ class sfp_arin(SpiderFootPlugin):# This is to support the end user in selecting modules based on events# produced.def producedEvents(self):- return ["HUMAN_NAME", "RAW_RIR_DATA"]+ return ["RAW_RIR_DATA"]# Fetch content and notify of the raw datadef fetchRir(self, url):@@ -132,8 +130,13 @@ class sfp_arin(SpiderFootPlugin):if "," in name:sname = name.split(", ", 1)name = sname[1] + " " + sname[0]- evt = SpiderFootEvent("HUMAN_NAME", name,- self.__name__, event)++ # A bit of a hack. The reason we do this is because+ # the names are separated in the content and sfp_names+ # won't recognise it. So we submit this and see if it+ # really is considered a name.+ evt = SpiderFootEvent("RAW_RIR_DATA", "Possible full name: " + name,+ self.__name__, self.currentEventSrc)self.notifyListeners(evt)# We just want the raw data so we can get potentialdiff --git a/modules/sfp_builtwith.py b/modules/sfp_builtwith.pyindex ebaf0abb..66363f37 100644--- a/modules/sfp_builtwith.py+++ b/modules/sfp_builtwith.py@@ -51,7 +51,7 @@ class sfp_builtwith(SpiderFootPlugin):# What events this module producesdef producedEvents(self):- return [ "INTERNET_NAME", "EMAILADDR", "HUMAN_NAME",+ return [ "INTERNET_NAME", "EMAILADDR", "RAW_RIR_DATA","WEB_TECHNOLOGY", "PHONE_NUMBER" ]def query(self, t):@@ -98,7 +98,7 @@ class sfp_builtwith(SpiderFootPlugin):if "Meta" in data:if data['Meta'].get("Names", []):for nb in data['Meta']['Names']:- e = SpiderFootEvent("HUMAN_NAME", nb['Name'],+ e = SpiderFootEvent("RAW_RIR_DATA", "Possible full name: " + nb['Name'],self.__name__, event)self.notifyListeners(e)if nb.get('Email', None):diff --git a/modules/sfp_clearbit.py b/modules/sfp_clearbit.pyindex 681b5888..2bbd7066 100644--- a/modules/sfp_clearbit.py+++ b/modules/sfp_clearbit.py@@ -50,7 +50,7 @@ class sfp_clearbit(SpiderFootPlugin):# What events this module producesdef producedEvents(self):- return [ "HUMAN_NAME", "PHONE_NUMBER", "PHYSICAL_ADDRESS",+ return [ "RAW_RIR_DATA", "PHONE_NUMBER", "PHYSICAL_ADDRESS","AFFILIATE_INTERNET_NAME", "EMAILADDR" ]def query(self, t):@@ -101,7 +101,8 @@ class sfp_clearbit(SpiderFootPlugin):# Get the name associated with the e-mailif "person" in data:name = data['person']['name']['fullName']- evt = SpiderFootEvent("HUMAN_NAME", name, self.__name__, event)+ evt = SpiderFootEvent("RAW_RIR_DATA", "Possible full name: " + name,+ self.__name__, event)self.notifyListeners(evt)except Exception:self.sf.debug("Unable to extract name from JSON.")diff --git a/modules/sfp_fullcontact.py b/modules/sfp_fullcontact.pyindex 398a5e38..85f0b867 100644--- a/modules/sfp_fullcontact.py+++ b/modules/sfp_fullcontact.py@@ -54,7 +54,7 @@ class sfp_fullcontact(SpiderFootPlugin):# What events this module producesdef producedEvents(self):- return [ "EMAILADDR", "HUMAN_NAME", "PHONE_NUMBER",+ return [ "EMAILADDR", "RAW_RIR_DATA", "PHONE_NUMBER","GEOINFO", "PHYSICAL_ADDRESS" ]def query(self, url, data, failcount=0):@@ -151,7 +151,8 @@ class sfp_fullcontact(SpiderFootPlugin):return Noneif 'fullName' not in data:return None- e = SpiderFootEvent("HUMAN_NAME", data['fullName'], self.__name__, event)+ e = SpiderFootEvent("RAW_RIR_DATA", "Possible full name: " + \+ data['fullName'], self.__name__, event)self.notifyListeners(e)return@@ -174,18 +175,21 @@ class sfp_fullcontact(SpiderFootPlugin):if "locations" in data:for r in data['locations']:if "city" in r and "country" in r:- e = SpiderFootEvent("GEOINFO", r['city'] + ", " + r['country'], self.__name__, event)+ e = SpiderFootEvent("GEOINFO", r['city'] + ", " + r['country'],+ self.__name__, event)self.notifyListeners(e)if "formatted" in r:# Seems to contain some junk sometimesif len(r['formatted']) > 10:- e = SpiderFootEvent("PHYSICAL_ADDRESS", r['formatted'], self.__name__, event)+ e = SpiderFootEvent("PHYSICAL_ADDRESS", r['formatted'],+ self.__name__, event)self.notifyListeners(e)if "keyPeople" in data:for r in data['keyPeople']:if 'fullName' in r:- e = SpiderFootEvent("HUMAN_NAME", r['fullName'], self.__name__, event)+ e = SpiderFootEvent("RAW_RIR_DATA", "Possible full name: " + \+ r['fullName'], self.__name__, event)self.notifyListeners(e)diff --git a/modules/sfp_hunter.py b/modules/sfp_hunter.pyindex 1aa09a91..d380901d 100644--- a/modules/sfp_hunter.py+++ b/modules/sfp_hunter.py@@ -49,7 +49,7 @@ class sfp_hunter(SpiderFootPlugin):# What events this module producesdef producedEvents(self):- return [ "EMAILADDR", "HUMAN_NAME" ]+ return [ "EMAILADDR", "RAW_RIR_DATA" ]def query(self, t):ret = None@@ -103,7 +103,8 @@ class sfp_hunter(SpiderFootPlugin):if 'first_name' in email and 'last_name' in email:if email['first_name'] != None and email['last_name'] != None:n = email['first_name'] + " " + email['last_name']- e = SpiderFootEvent("HUMAN_NAME", n, self.__name__, event)+ e = SpiderFootEvent("RAW_RIR_DATA", "Possible full name: " + n,+ self.__name__, event)self.notifyListeners(e)diff --git a/modules/sfp_names.py b/modules/sfp_names.pyindex b1fad056..319f6afc 100644--- a/modules/sfp_names.py+++ b/modules/sfp_names.py@@ -17,18 +17,18 @@ from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEventclass sfp_names(SpiderFootPlugin):"""Name Extractor:Footprint,Passive:Real World:errorprone:Attempt to identify human names in fetched content."""--# Default optionsopts = {- 'algotune': 50,- 'emailtoname': True+ 'algolimit': 75,+ 'emailtoname': True,+ 'filterjscss': True}# Option descriptionsoptdescs = {- 'algotune': "A value between 0-100 to tune the sensitivity of the name finder. Less than 40 will give you a lot of junk, over 50 and you'll probably miss things but will have less false positives.",- 'emailtoname': "Convert e-mail addresses in the form of firstname.surname@target to names?"+ 'algolimit': "A value between 0-100 to tune the sensitivity of the name finder. Less than 40 will give you a lot of junk, over 50 and you'll probably miss things but will have less false positives.",+ 'emailtoname': "Convert e-mail addresses in the form of firstname.surname@target to names?",+ 'filterjscss': "Filter out names that originated from CSS/JS content. Enabling this avoids detection of popular Javascript and web framework author names."}results = dict()@@ -38,14 +38,8 @@ class sfp_names(SpiderFootPlugin):def setup(self, sfc, userOpts=dict()):self.sf = sfcself.results = dict()-- d = self.sf.dictwords()- self.n = self.sf.dictnames()- # Take dictionary words out of the names list to keep things clean- self.d = set(set(d) - set(self.n))-- # Clear / reset any other class member variables here- # or you risk them persisting between threads.+ self.d = set(self.sf.dictwords())+ self.n = set(self.sf.dictnames())for opt in userOpts.keys():self.opts[opt] = userOpts[opt]@@ -54,7 +48,8 @@ class sfp_names(SpiderFootPlugin):# * = be notified about all events.def watchedEvents(self):return ["TARGET_WEB_CONTENT", "EMAILADDR",- "DOMAIN_WHOIS", "NETBLOCK_WHOIS"]+ "DOMAIN_WHOIS", "NETBLOCK_WHOIS",+ "RAW_RIR_DATA"]# What events this module produces# This is to support the end user in selecting modules based on events@@ -70,6 +65,15 @@ class sfp_names(SpiderFootPlugin):self.sf.debug("Received event, " + eventName + ", from " + srcModuleName)+ # If the source event is web content, check if the source URL was javascript+ # or CSS, in which case optionally ignore it.+ if eventName == "TARGET_WEB_CONTENT":+ #url = event.sourceEvent.data+ url = event.actualSource+ if self.opts['filterjscss'] and (".js" in url or ".css" in url):+ self.sf.debug("Ignoring web content from CSS/JS.")+ return None+if eventName == "EMAILADDR" and self.opts['emailtoname']:if "." in eventData.split("@")[0]:if type(eventData) == unicode:@@ -107,8 +111,11 @@ class sfp_names(SpiderFootPlugin):# If both words are not in the dictionary, add 75 points.if first not in self.d and second not in self.d:+ self.sf.debug("Both first and second names are not in the dictionary, so high chance of name: (" + first +":" + second +").")p += 75notindict = True+ else:+ self.sf.debug(first + " was found or " + second + " was found in dictionary.")# If the first word is a known popular first name, award 50 points.if first in self.n:@@ -131,7 +138,8 @@ class sfp_names(SpiderFootPlugin):name = r[0] + " " + secondOrig- if p > self.opts['algotune']:+ self.sf.debug("Name of " + name + " has score: " + str(p))+ if p > self.opts['algolimit']:# Notify other modules of what you've foundevt = SpiderFootEvent("HUMAN_NAME", name, self.__name__, event)if event.moduleDataSource:diff --git a/modules/sfp_socialprofiles.py b/modules/sfp_socialprofiles.pyindex 0116547f..bf10d29b 100644--- a/modules/sfp_socialprofiles.py+++ b/modules/sfp_socialprofiles.py@@ -13,18 +13,21 @@import randomimport reimport time-import urllib+import urllib2from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEventsites = {# Search string to use, domain name the profile will sit on within# those search results."Facebook": ['+title:%22{0}%22%20+site:facebook.com',- '"(https?://[a-z\.]*facebook.[a-z\.]+/[^\"<> ]+)"'],+ ['"(https?://[a-z\.]*facebook.[a-z\.]+/[^/\"<> ]+)"',+ '(https?%3a%2f%2f[a-z\.]*facebook.[a-z\.]+%2f[^\/\"<> ]+)']],"Google+": ['+title:%22{0}%22%20+site:plus.google.com',- '"(https?://plus.google.[a-z\.]+/\d+[^\"<>\/ ]+)"'],+ ['"(https?://plus.google.[a-z\.]+/\d+[^\"<>\/ ]+)"',+ '(https?%3a%2f%2fplus.google.[a-z\.]+%2f\d+[^\/\"<> ]+)']],"LinkedIn": ['+title:%22{0}%22%20+site:linkedin.com',- '"(https?://[a-z\.]*linkedin.[a-z\.]+/[^\"<> ]+)"']+ ['"(https?://[a-z\.]*linkedin.[a-z\.]+/[^/\"<> ]+)"',+ '(https?%3a%2f%2f[a-z\.]*linkedin.[a-z\.]+%2f[^\/\"<> ]+)']]}@@ -52,6 +55,7 @@ class sfp_socialprofiles(SpiderFootPlugin):def setup(self, sfc, userOpts=dict()):self.sf = sfcself.results = list()+ self.keywords = Nonefor opt in userOpts.keys():self.opts[opt] = userOpts[opt]@@ -85,11 +89,12 @@ class sfp_socialprofiles(SpiderFootPlugin):if self.keywords is None:self.keywords = self.sf.domainKeywords(self.getTarget().getNames(),self.opts['_internettlds'])+ if len(self.keywords) == 0:+ self.keywords = Nonefor site in sites.keys():s = unicode(sites[site][0]).format(eventData)searchStr = s.replace(" ", "%20")- searchDom = sites[site][1]results = Noneif self.opts['method'].lower() == "google":@@ -124,10 +129,14 @@ class sfp_socialprofiles(SpiderFootPlugin):for key in results.keys():instances = list()- matches = re.findall(searchDom, results[key], re.IGNORECASE)+ for searchDom in sites[site][1]:+ matches = re.findall(searchDom, results[key], re.IGNORECASE|re.MULTILINE)++ if not matches:+ continue- if matches is not None:for match in matches:+ self.sf.debug("Match found: " + match)if match in instances:continueelse:@@ -135,13 +144,16 @@ class sfp_socialprofiles(SpiderFootPlugin):if self.opts['method'] == "yahoo":match = re.sub(r'.*RU=(.*?)/RK=.*', r'\1', match)+ self.sf.debug("Yahoo match: " + match)if self.checkForStop():return None# Fetch the profile page if we are checking# for a firm relationship.- if self.opts['tighten']:+ # Keywords might be empty if the target was an IP, subnet or name.+ if self.opts['tighten'] and self.keywords:+ self.sf.debug("Tightening results to look for " + str(self.keywords))pres = self.sf.fetchUrl(match, timeout=self.opts['_fetchtimeout'],useragent=self.opts['_useragent'])@@ -156,6 +168,7 @@ class sfp_socialprofiles(SpiderFootPlugin):if not found:continue+ match = urllib2.unquote(match)self.sf.info("Social Media Profile found at " + site + ": " + match)evt = SpiderFootEvent("SOCIAL_MEDIA", site + ": " + match,self.__name__, event)diff --git a/sfwebui.py b/sfwebui.pyindex d7e4da09..20dcd0ba 100644--- a/sfwebui.py+++ b/sfwebui.py@@ -67,7 +67,7 @@ class SpiderFootWebUi:c = cgi.escape(item, True)c = c.replace('\'', '"')# We don't actually want & translated to &- c = c.replace("&", "&")+ c = c.replace("&", "&").replace(""", "\"")ret.append(c)return ret@@ -274,13 +274,16 @@ class SpiderFootWebUi:targetType = sf.targetType(scantarget)if targetType == None:- # Should never be triggered for a re-run scan..- return self.error("Invalid target type. Could not recognize it as " + \- "an IP address, IP subnet, domain name or host name.")+ # It must then be a name, as a re-run scan should always have a clean+ # target.+ targetType = "HUMAN_NAME"++ if targetType != "HUMAN_NAME":+ scantarget = scantarget.lower()# Start running a new scannewId = sf.genScanInstanceGUID(scanname)- t = SpiderFootScanner(scanname, scantarget.lower(), targetType, newId,+ t = SpiderFootScanner(scanname, scantarget, targetType, newId,modlist, cfg, modopts)t.start()@@ -319,7 +322,7 @@ class SpiderFootWebUi:if targetType == None:# Should never be triggered for a re-run scan..return self.error("Invalid target type. Could not recognize it as " + \- "an IP address, IP subnet, domain name or host name.")+ "a human name, IP address, IP subnet, domain name or host name.")# Start running a new scannewId = sf.genScanInstanceGUID(scanname)@@ -352,6 +355,7 @@ class SpiderFootWebUi:# Clone an existing scan (pre-selected options in the newscan page)def clonescan(self, id):+ sf = SpiderFoot(self.config)dbh = SpiderFootDb(self.config)types = dbh.eventTypes()info = dbh.scanInstanceGet(id)@@ -363,6 +367,11 @@ class SpiderFootWebUi:if scanname == "" or scantarget == "" or len(scanconfig) == 0:return self.error("Something went wrong internally.")+ targetType = sf.targetType(scantarget)+ if targetType == None:+ # It must be a name, so wrap quotes around it+ scantarget = """ + scantarget + """+modlist = scanconfig['_modulesenabled'].split(',')templ = Template(filename='dyn/newscan.tmpl', lookup=self.lookup)@@ -724,14 +733,18 @@ class SpiderFootWebUi:if targetType is None:if not cli:return self.error("Invalid target type. Could not recognize it as " + \- "an IP address, IP subnet, domain name or host name.")+ "a human name, IP address, IP subnet, domain name or host name.")else:return json.dumps(["ERROR", "Unrecognised target type."])# Start running a new scanscanId = sf.genScanInstanceGUID(scanname)- t = SpiderFootScanner(scanname, scantarget.lower(), targetType, scanId,+ if targetType == "HUMAN_NAME":+ scantarget = scantarget.replace("\"", "")+ else:+ scantarget = scantarget.lower()+ t = SpiderFootScanner(scanname, scantarget, targetType, scanId,modlist, cfg, modopts)t.start()