SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
Code review changes
Krishnasis Mandal70e77e0026c7
diff --git a/modules/sfp_snov.py b/modules/sfp_snov.pyindex 3e93ca97..20948b29 100644--- a/modules/sfp_snov.py+++ b/modules/sfp_snov.py@@ -17,17 +17,17 @@ import urllib.request, urllib.parse, urllib.errorimport jsonclass sfp_snov(SpiderFootPlugin):- """Snov:Investigate,Passive:Reputation Systems:client_id,client_secret:Gather available email ids from target domain"""+ """Snov:Investigate,Passive:Reputation Systems:apikey:Gather available email ids from target domain"""opts = {- 'client_id': '',- 'client_secret': ''+ 'api_key_client_id': '',+ 'api_key_client_secret': ''}# Option descriptions. Delete any options not applicable to this module.optdescs = {- 'client_id': "Client ID for snov.io API",- 'client_secret': "Client Secret for snov.io API"+ 'api_key_client_id': "Client ID for snov.io API",+ 'api_key_client_secret': "Client Secret for snov.io API"}results = None@@ -57,8 +57,8 @@ class sfp_snov(SpiderFootPlugin):def queryAccessToken(self):params = {'grant_type': "client_credentials",- 'client_id': self.opts['client_id'],- 'client_secret': self.opts['client_secret']+ 'client_id': self.opts['api_key_client_id'],+ 'client_secret': self.opts['api_key_client_secret']}headers = {@@ -73,7 +73,7 @@ class sfp_snov(SpiderFootPlugin):)if not res['code'] == '200':- self.sf.error("Could not authenticate credentials", False)+ self.sf.error("No access token received from snov.io for the provided Client ID and/or Client Secret", False)self.errorState = Truereturn Nonetry:@@ -86,7 +86,7 @@ class sfp_snov(SpiderFootPlugin):return str(accessToken)except Exception:- self.sf.debug("Could not fetch access token")+ self.sf.error("No access token received from snov.io for the provided Client ID and/or Client Secret", False)self.errorState = Truereturn None@@ -111,15 +111,12 @@ class sfp_snov(SpiderFootPlugin):timeout=15,useragent=self.opts['_useragent'])-if not res['code'] == '200':self.sf.debug("Could not fetch email addresses")return Nonereturn res.get('content')--# Handle events sent to this moduledef handleEvent(self, event):eventName = event.eventType@@ -133,8 +130,8 @@ class sfp_snov(SpiderFootPlugin):# Always check if the API key is set and complain if it isn't, then set# self.errorState to avoid this being a continual complaint during the scan.- if self.opts['client_id'] == "" or self.opts['client_secret'] == "":- self.sf.error("You enabled sfp_snov but did not set an client_id and/or client_secret", False)+ if self.opts['api_key_client_id'] == "" or self.opts['api_key_client_secret'] == "":+ self.sf.error("You enabled sfp_snov but did not set a Client ID and/or Client Secret", False)self.errorState = Truereturn None@@ -148,7 +145,7 @@ class sfp_snov(SpiderFootPlugin):# Get access token from Snov IO APIaccessToken = self.queryAccessToken()if accessToken is None or accessToken == '':- self.sf.debug("No access token received from Snov")+ self.sf.error("No access token received from snov.io for the provided Client ID and/or Client Secret", False)self.errorState = Truereturn None@@ -160,27 +157,23 @@ class sfp_snov(SpiderFootPlugin):return Nonedata = self.queryDomainName(eventData, accessToken, currentOffset)-if data is None:self.sf.debug("No email address found for target domain")- return None+ break- if isinstance(data, str):- data = json.loads(data.replace("null","None").replace("'","\""))+ try:+ data = json.loads(data)+ except:+ self.sf.debug("No email address found for target domain")+ breakevt = SpiderFootEvent("RAW_RIR_DATA", str(data), self.__name__, event)self.notifyListeners(evt)records = data.get('emails')-- if isinstance(records, str):- records = json.loads(records.replace("null","None").replace("'","\""))-+if records:for record in records:- if isinstance(record, str):- record = json.loads(record.replace("null","None").replace("'","\""))-if record:email = record.get('email')if email:@@ -191,6 +184,7 @@ class sfp_snov(SpiderFootPlugin):evt = SpiderFootEvent("EMAILADDR", str(email), self.__name__, event)self.notifyListeners(evt)+ # Determine whether the next offset can have data or notif len(records) < self.limit:nextPageHasData = FalsecurrentOffset += self.limit