SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
Affiliate e-mail addresses added.
Steve Micallef5e1bcd168231
diff --git a/modules/sfp_email.py b/modules/sfp_email.pyindex dcc2ac23..f0c77ae8 100644--- a/modules/sfp_email.py+++ b/modules/sfp_email.py@@ -11,14 +11,19 @@# Licence: GPL# --------------------------------------------------------------------------------import re-from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent+try:+ import re2 as re+except ImportError:+ import re+from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEventclass sfp_email(SpiderFootPlugin):"""E-Mail:Footprint,Investigate,Passive:Content Analysis::Identify e-mail addresses in any obtained data."""++# Default optionsopts = {# options specific to this module@@ -42,7 +47,7 @@ class sfp_email(SpiderFootPlugin):# This is to support the end user in selecting modules based on events# produced.def producedEvents(self):- return ["EMAILADDR"]+ return ["EMAILADDR", "AFFILIATE_EMAILADDR"]# Handle events sent to this moduledef handleEvent(self, event):@@ -50,19 +55,33 @@ class sfp_email(SpiderFootPlugin):srcModuleName = event.moduleeventData = event.data- if eventName.startswith("EMAILADDR"):+ # Don't re-parse e-mail addresses+ if "EMAILADDR" in eventName:+ return None++ # Ignore any web content that isn't from the target. This avoids noise from+ # pastebin and other content where unrelated e-mails are likely to be found.+ if "_CONTENT" in eventName and eventName != "TARGET_WEB_CONTENT":return Noneself.sf.debug("Received event, " + eventName + ", from " + srcModuleName)if type(eventData) not in [str, unicode]:- self.sf.debug("Unhandled type to find e-mails: " + str(type(eventData)))- return None+ try:+ if type(eventData) in [ list, dict ]:+ eventData = str(eventData)+ else:+ self.sf.debug("Unhandled type to find e-mails: " + str(type(eventData)))+ return None+ except BaseException as e:+ self.sf.debug("Unable to convert list/dict to string: " + str(e))+ return Nonepat = re.compile("([\%a-zA-Z\.0-9_\-]+@[a-zA-Z\.0-9\-]+\.[a-zA-Z\.0-9\-]+)")matches = re.findall(pat, eventData)myres = list()for match in matches:+ evttype = "EMAILADDR"if len(match) < 4:self.sf.debug("Likely invalid address: " + match)continue@@ -72,11 +91,15 @@ class sfp_email(SpiderFootPlugin):self.sf.debug("Skipped address: " + match)continue- # Get the doain and strip potential ending .+ # Get the domain and strip potential ending .mailDom = match.lower().split('@')[1].strip('.')if not self.getTarget().matches(mailDom):- self.sf.debug("Ignoring e-mail address on an external domain: " + match)- continue+ self.sf.debug("External domain, so possible affiliate e-mail")+ # Raw RIR data returning external e-mails generates way+ # too much noise.+ if eventName == "RAW_RIR_DATA":+ return None+ evttype = "AFFILIATE_EMAILADDR"self.sf.info("Found e-mail address: " + match)if type(match) == str:@@ -90,7 +113,7 @@ class sfp_email(SpiderFootPlugin):else:myres.append(mail)- evt = SpiderFootEvent("EMAILADDR", mail, self.__name__, event)+ evt = SpiderFootEvent(evttype, mail, self.__name__, event)if event.moduleDataSource:evt.moduleDataSource = event.moduleDataSourceelse:diff --git a/modules/sfp_pgp.py b/modules/sfp_pgp.pyindex cd7cb9e3..4042373b 100644--- a/modules/sfp_pgp.py+++ b/modules/sfp_pgp.py@@ -55,7 +55,7 @@ class sfp_pgp(SpiderFootPlugin):# This is to support the end user in selecting modules based on events# produced.def producedEvents(self):- return ["EMAILADDR", "PGP_KEY"]+ return ["EMAILADDR", "AFFILIATE_EMAILADDR", "PGP_KEY"]# Handle events sent to this moduledef handleEvent(self, event):@@ -85,6 +85,7 @@ class sfp_pgp(SpiderFootPlugin):pat = re.compile("([a-zA-Z\.0-9_\-]+@[a-zA-Z\.0-9\-]+\.[a-zA-Z\.0-9\-]+)")matches = re.findall(pat, res['content'])for match in matches:+ evttype = "EMAILADDR"self.sf.debug("Found possible email: " + match)if len(match) < 4:self.sf.debug("Likely invalid address.")@@ -92,11 +93,10 @@ class sfp_pgp(SpiderFootPlugin):mailDom = match.lower().split('@')[1]if not self.getTarget().matches(mailDom):- self.sf.debug("Ignoring e-mail address on an external domain: " + match)- continue+ evttype = "AFFILIATE_EMAILADDR"self.sf.info("Found e-mail address: " + match)- evt = SpiderFootEvent("EMAILADDR", match, self.__name__, event)+ evt = SpiderFootEvent(evttype, match, self.__name__, event)self.notifyListeners(evt)if eventName == "EMAILADDR":