SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
Use Python 3 print style
Brendan Colesd511b3565008
diff --git a/modules/sfp__stor_stdout.py b/modules/sfp__stor_stdout.pyindex 4888fbff..b9a323aa 100644--- a/modules/sfp__stor_stdout.py+++ b/modules/sfp__stor_stdout.py@@ -73,17 +73,17 @@ class sfp__stor_stdout(SpiderFootPlugin):if self.opts['_format'] == "tab":if self.opts['_showsource']:- print '{0:30}\t{1:45}\t{2}\t{3}'.format(event.module, self.opts['_eventtypes'][event.eventType], srcdata, data)+ print('{0:30}\t{1:45}\t{2}\t{3}'.format(event.module, self.opts['_eventtypes'][event.eventType], srcdata, data))else:- print '{0:30}\t{1:45}\t{2}'.format(event.module, self.opts['_eventtypes'][event.eventType], data)+ print('{0:30}\t{1:45}\t{2}'.format(event.module, self.opts['_eventtypes'][event.eventType], data))if self.opts['_format'] == "csv":- print event.module + d + self.opts['_eventtypes'][event.eventType] + d + srcdata + d + data+ print(event.module + d + self.opts['_eventtypes'][event.eventType] + d + srcdata + d + data)if self.opts['_format'] == "json":d = event.asDict()d['type'] = self.opts['_eventtypes'][event.eventType]- print json.dumps(d)+ print(json.dumps(d))# Handle events sent to this modulediff --git a/modules/sfp_alienvault.py b/modules/sfp_alienvault.pyindex 18741d55..715d1129 100644--- a/modules/sfp_alienvault.py+++ b/modules/sfp_alienvault.py@@ -102,7 +102,7 @@ class sfp_alienvault(SpiderFootPlugin):try:info = json.loads(res['content'])except Exception as e:- print str(res['content'])+ print(str(res['content']))self.sf.error("Error processing JSON response from AlienVault OTX.", False)return Nonediff --git a/modules/sfp_censys.py b/modules/sfp_censys.pyindex 0a985b3a..0444143b 100644--- a/modules/sfp_censys.py+++ b/modules/sfp_censys.py@@ -91,7 +91,7 @@ class sfp_censys(SpiderFootPlugin):self.sf.error("Error processing JSON response from Censys.io.", False)return None- #print str(info)+ #print(str(info))return infodiff --git a/modules/sfp_fraudguard.py b/modules/sfp_fraudguard.pyindex d46afee9..8c5c562f 100644--- a/modules/sfp_fraudguard.py+++ b/modules/sfp_fraudguard.py@@ -87,7 +87,7 @@ class sfp_fraudguard(SpiderFootPlugin):self.sf.error("Error processing JSON response from Fraudguard.io.", False)return None- #print str(info)+ #print(str(info))return infodiff --git a/modules/sfp_greynoise.py b/modules/sfp_greynoise.pyindex 190c9870..d93a4303 100644--- a/modules/sfp_greynoise.py+++ b/modules/sfp_greynoise.py@@ -87,7 +87,7 @@ class sfp_greynoise(SpiderFootPlugin):try:info = json.loads(res['content'])except Exception as e:- print str(res['content'])+ print(str(res['content']))self.sf.error("Error processing JSON response from Greynoise.", False)return Nonediff --git a/modules/sfp_pulsedive.py b/modules/sfp_pulsedive.pyindex 55811a45..7d56b6f8 100644--- a/modules/sfp_pulsedive.py+++ b/modules/sfp_pulsedive.py@@ -82,7 +82,7 @@ class sfp_pulsedive(SpiderFootPlugin):try:info = json.loads(res['content'])except Exception as e:- print str(res['content'])+ print(str(res['content']))self.sf.error("Error processing JSON response from Pulsedive.", False)return Nonediff --git a/sf.py b/sf.pyindex 2e6dd7e6..d9493e9d 100755--- a/sf.py+++ b/sf.py@@ -35,20 +35,20 @@ for mod in deps:else:__import__(mod)except ImportError as e:- print ""- print "Critical Start-up Failure: " + str(e)- print "================================="- print "It appears you are missing a module required for SpiderFoot"- print "to function. Please refer to the documentation for the list"- print "of dependencies and install them."- print ""- print "Python modules required are: "+ print("")+ print("Critical Start-up Failure: " + str(e))+ print("=================================")+ print("It appears you are missing a module required for SpiderFoot")+ print("to function. Please refer to the documentation for the list")+ print("of dependencies and install them.")+ print("")+ print("Python modules required are: ")for mod in deps:- print " - " + mod- print ""- print "If you are running on Windows and getting this error, please"- print "report this as a bug to [email protected]."- print ""+ print(" - " + mod)+ print("")+ print("If you are running on Windows and getting this error, please")+ print("report this as a bug to [email protected].")+ print("")sys.exit(-1)import os@@ -113,7 +113,7 @@ scanId = Nonedbh = Nonedef handle_abort(signal, frame):- print "[*] Aborting..."+ print("[*] Aborting...")if scanId and dbh:dbh.scanInstanceSet(scanId, None, None, "ABORTED")sys.exit(-1)@@ -184,7 +184,7 @@ if __name__ == '__main__':sfModules[modName]['optdescs'] = sfModules[modName]['object'].optdescsif len(sfModules.keys()) < 1:- print "No modules found in the modules directory."+ print("No modules found in the modules directory.")sys.exit(-1)# Add module info to sfConfig so it can be used by the UI@@ -197,42 +197,42 @@ if __name__ == '__main__':if args:if args.modules:- print "Modules available:"+ print("Modules available:")for m in sorted(sfModules.keys()):if "__" in m:continue- print '{0:25} {1}'.format(m, sfModules[m]['descr'])+ print('{0:25} {1}'.format(m, sfModules[m]['descr']))sys.exit(0)if args.types:- print "Types available:"+ print("Types available:")typedata = dbh.eventTypes()types = dict()for r in typedata:types[r[1]] = r[0]for t in sorted(types.keys()):- print '{0:45} {1}'.format(t, types[t])+ print('{0:45} {1}'.format(t, types[t]))sys.exit(0)if not args.s:- print "You must specify a target when running in scan mode. Try sf.py --help for guidance."+ print("You must specify a target when running in scan mode. Try sf.py --help for guidance.")sys.exit(-1)if args.x and not args.t:- print "-x can only be used with -t. Use --help for guidance."+ print("-x can only be used with -t. Use --help for guidance.")sys.exit(-1)if args.x and args.m:- print "-x can only be used with -t and not with -m. Use --help for guidance."+ print("-x can only be used with -t and not with -m. Use --help for guidance.")sys.exit(-1)if args.r and (args.o and args.o not in ["tab", "csv"]):- print "-r can only be used when your output format is tab or csv."+ print("-r can only be used when your output format is tab or csv.")sys.exit(-1)if args.D and args.o != "csv":- print "-D can only be used when using the csv output format."+ print("-D can only be used when using the csv output format.")sys.exit(-1)target = args.s@@ -240,7 +240,7 @@ if __name__ == '__main__':modlist = list()if not args.t and not args.m:- print "WARNING: You didn't specify any modules or types, so all will be enabled."+ print("WARNING: You didn't specify any modules or types, so all will be enabled.")for m in sfModules.keys():if "__" in m:continue@@ -280,7 +280,7 @@ if __name__ == '__main__':sfConfig['__modules__']['sfp__stor_stdout']['opts']['_eventtypes'] = typesif args.f:if args.f and not args.t:- print "You can only use -f with -t. Use --help for guidance."+ print("You can only use -f with -t. Use --help for guidance.")sys.exit(-1)sfConfig['__modules__']['sfp__stor_stdout']['opts']['_showonlyrequested'] = Trueif args.F:@@ -316,14 +316,14 @@ if __name__ == '__main__':modlist.append(mod)if len(modlist) == 0:- print "Based on your criteria, no modules were enabled."+ print("Based on your criteria, no modules were enabled.")sys.exit(-1)modlist += ["sfp__stor_db", "sfp__stor_stdout"]# Run the scanif not args.q:- print "[*] Modules enabled (" + str(len(modlist)) + "): " + ",".join(modlist)+ print("[*] Modules enabled (" + str(len(modlist)) + "): " + ",".join(modlist))cfg = sf.configUnserialize(dbh.configGet(), sfConfig)scanId = sf.genScanInstanceGUID(target)@@ -349,15 +349,15 @@ if __name__ == '__main__':continueif info[5] in [ "ERROR-FAILED", "ABORT-REQUESTED", "ABORTED", "FINISHED" ]:if not args.q:- print "[*] Scan completed with status " + info[5]+ print("[*] Scan completed with status " + info[5])sys.exit(0)time.sleep(1)sys.exit(0)# Start the web server so you can start looking at results- print "Starting web server at http://" + sfConfig['__webaddr'] + \- ":" + str(sfConfig['__webport']) + sfConfig['__docroot'] + " ..."+ url = 'http://' + sfConfig['__webaddr'] + ":" + str(sfConfig['__webport']) + sfConfig['__docroot']+ print('Starting web server at %s ...' % url)cherrypy.config.update({'server.socket_host': sfConfig['__webaddr'],@@ -377,7 +377,7 @@ if __name__ == '__main__':passwd_file = sf.myPath() + '/passwd'if os.path.isfile(passwd_file):if not os.access(passwd_file, os.R_OK):- print "Could not read passwd file. Permission denied."+ print("Could not read passwd file. Permission denied.")sys.exit(-1)secrets = dict()@@ -386,19 +386,19 @@ if __name__ == '__main__':for line in pw.readlines():if ':' not in line:- print "Incorrect format of passwd file, must be username:password on each line."+ print("Incorrect format of passwd file, must be username:password on each line.")sys.exit(-1)u, p = line.strip().split(":")if not u or not p:- print "Incorrect format of passwd file, must be username:password on each line."+ print("Incorrect format of passwd file, must be username:password on each line.")sys.exit(-1)secrets[u] = pif secrets:- print "Enabling authentication based on supplied passwd file."+ print("Enabling authentication based on supplied passwd file.")conf['/'] = {'tools.auth_digest.on': True,'tools.auth_digest.realm': sfConfig['__webaddr'],@@ -406,20 +406,20 @@ if __name__ == '__main__':'tools.auth_digest.key': random.randint(0, 99999999)}else:- print "Warning: passwd file contains no passwords. Authentication disabled."+ print("Warning: passwd file contains no passwords. Authentication disabled.")key_path = sf.myPath() + '/spiderfoot.key'crt_path = sf.myPath() + '/spiderfoot.crt'if os.path.isfile(key_path) and os.path.isfile(crt_path):if not os.access(crt_path, os.R_OK):- print "Could not read spiderfoot.crt file. Permission denied."+ print("Could not read spiderfoot.crt file. Permission denied.")sys.exit(-1)if not os.access(key_path, os.R_OK):- print "Could not read spiderfoot.key file. Permission denied."+ print("Could not read spiderfoot.key file. Permission denied.")sys.exit(-1)- print "Enabling SSL based on supplied key and certificate file."+ print("Enabling SSL based on supplied key and certificate file.")cherrypy.server.ssl_module = 'builtin'cherrypy.server.ssl_certificate = crt_pathcherrypy.server.ssl_private_key = key_pathdiff --git a/sfcli.py b/sfcli.pyindex 5800f720..7d9a13bf 100644--- a/sfcli.py+++ b/sfcli.py@@ -120,7 +120,7 @@ class SpiderFootCli(cmd.Cmd):cout = msgsout = msg- print cout+ print(cout)if self.ownopts['cli.spool']:f = codecs.open(self.ownopts['cli.spool_file'], "a", encoding="utf-8")@@ -228,7 +228,7 @@ class SpiderFootCli(cmd.Cmd):# we have a dict keycn = cv = r[c]- #print str(cn) + ", " + str(c) + ", " + str(v)+ #print(str(cn) + ", " + str(c) + ", " + str(v))if len(v) > maxsize.get(cn, 0):maxsize[cn] = len(v)i += 1@@ -316,7 +316,7 @@ class SpiderFootCli(cmd.Cmd):#out += "\n"out.append("\n")- #print "time: " + str(time.time() - ts)+ #print("time: " + str(time.time() - ts))#return ""return ''.join(out)@@ -1131,7 +1131,7 @@ class SpiderFootCli(cmd.Cmd):def do_EOF(self, line):"""EOF (Ctrl-D)Exit the SpiderFoot CLI."""- print "\n",+ print("\n")return Trueif __name__ == "__main__":@@ -1156,7 +1156,7 @@ if __name__ == "__main__":try:cin = open(args.e, "r")except BaseException as e:- print "Unable to open " + args.e + ":" + " (" + str(e) + ")"+ print("Unable to open " + args.e + ":" + " (" + str(e) + ")")sys.exit(-1)else:cin = sys.stdin@@ -1174,7 +1174,7 @@ if __name__ == "__main__":s.ownopts['cli.password'] = pf.readlines()[0].strip('\n')pf.close()except BaseException as e:- print "Unable to open " + args.P + ":" + " (" + str(e) + ")"+ print("Unable to open " + args.P + ":" + " (" + str(e) + ")")sys.exit(-1)if args.k:s.ownopts['cli.color'] = Falsediff --git a/sfdb.py b/sfdb.pyindex f3c4a717..eca1e5eb 100644--- a/sfdb.py+++ b/sfdb.py@@ -259,7 +259,7 @@ class SpiderFootDb:returnif init:- print "Attempting to verify database and update if necessary..."+ print("Attempting to verify database and update if necessary...")for qry in self.createTypeQueries:try:self.dbh.execute(qry)@@ -334,8 +334,8 @@ class SpiderFootDb:qry += " ORDER BY c.data"try:- #print qry- #print str(qvars)+ #print(qry)+ #print(str(qvars))self.dbh.execute(qry, qvars)return self.dbh.fetchall()except sqlite3.Error as e:@@ -705,7 +705,7 @@ class SpiderFootDb:sfEvent.confidence, sfEvent.visibility, sfEvent.risk,sfEvent.module, storeData, sfEvent.sourceEventHash]- #print "STORING: " + str(qvals)+ #print("STORING: " + str(qvals))try:self.dbh.execute(qry, qvals)@@ -834,7 +834,7 @@ class SpiderFootDb:parentId = row[9]childId = row[8]datamap[childId] = row- #print childId + " = " + str(row)+ #print(childId + " = " + str(row))if parentId in pc:if childId not in pc[parentId]:diff --git a/sflib.py b/sflib.pyindex c277cb67..82cbade9 100644--- a/sflib.py+++ b/sflib.py@@ -162,15 +162,15 @@ class SpiderFoot:for [parent, id] in parents[entity]:if parent in entities:if entity != parent:- #print "Adding entity parent: " + parent+ #print("Adding entity parent: " + parent)mapping.add((entity, parent))else:ppids = list()- #print "Checking " + parent + " for entityship."+ #print("Checking " + parent + " for entityship.")next_parents = get_next_parent_entities(parent, ppids)for next_parent in next_parents:if entity != next_parent:- #print "Adding next entity parent: " + next_parent+ #print("Adding next entity parent: " + next_parent)mapping.add((entity, next_parent))return mapping@@ -291,7 +291,7 @@ class SpiderFoot:return hashStrdef _dblog(self, level, message, component=None):- #print str(self.GUID) + ":" + str(level) + ":" + str(message) + ":" + str(component)+ #print(str(self.GUID) + ":" + str(level) + ":" + str(message) + ":" + str(component))return self.dbh.scanLogEvent(self.GUID, level, message, component)def error(self, error, exception=True):@@ -299,20 +299,20 @@ class SpiderFoot:return Noneif self.dbh is None:- print '[Error] ' + error+ print('[Error] ' + error)else:self._dblog("ERROR", error)if self.opts.get('__logstdout'):- print "[Error] " + error+ print("[Error] " + error)if exception:raise BaseException("Internal Error Encountered: " + error)def fatal(self, error):if self.dbh is None:- print '[Fatal] ' + error+ print('[Fatal] ' + error)else:self._dblog("FATAL", error)- print str(inspect.stack())+ print(str(inspect.stack()))sys.exit(-1)def status(self, message):@@ -320,11 +320,11 @@ class SpiderFoot:return Noneif self.dbh is None:- print "[Status] " + message+ print("[Status] " + message)else:self._dblog("STATUS", message)if self.opts.get('__logstdout'):- print "[*] " + message+ print("[*] " + message)def info(self, message):if not self.opts['__logging']:@@ -347,11 +347,11 @@ class SpiderFoot:modName = mod.__name__if self.dbh is None:- print '[' + modName + '] ' + message+ print('[' + modName + '] ' + message)else:self._dblog("INFO", message, modName)if self.opts.get('__logstdout'):- print "[*] " + message+ print("[*] " + message)returndef debug(self, message):@@ -376,11 +376,11 @@ class SpiderFoot:modName = mod.__name__if self.dbh is None:- print '[' + modName + '] ' + message+ print('[' + modName + '] ' + message)else:self._dblog("DEBUG", message, modName)if self.opts.get('__logstdout'):- print "[d:" + modName +"] " + message+ print("[d:" + modName +"] " + message)returndef myPath(self):@@ -825,7 +825,7 @@ class SpiderFoot:# tree that can be digested by d3 for visualizations.def dataParentChildToTree(self, data):def get_children(needle, haystack):- #print "called"+ #print("called")ret = list()if needle not in haystack.keys():@@ -835,7 +835,7 @@ class SpiderFoot:return Nonefor c in haystack[needle]:- #print "found child of " + needle + ": " + c+ #print("found child of " + needle + ": " + c)ret.append({"name": c, "children": get_children(c, haystack)})return ret@@ -858,7 +858,7 @@ class SpiderFoot:breakif root is None:- #print "*BUG*: Invalid structure - needs to go back to one root."+ #print("*BUG*: Invalid structure - needs to go back to one root.")final = {}else:final = {"name": root, "children": get_children(root, data)}@@ -1107,8 +1107,8 @@ class SpiderFoot:else:result['content'] = unicode(content, 'utf-8', errors='replace')- #print "FOR: " + url- #print "HEADERS: " + str(result['headers'])+ #print("FOR: " + url)+ #print("HEADERS: " + str(result['headers']))result['realurl'] = fullPage.geturl()result['code'] = str(fullPage.getcode())result['status'] = 'OK'@@ -1421,7 +1421,7 @@ class SpiderFootPlugin(object):# Gets the current target this module is acting againstdef getTarget(self):if self._currentTarget is None:- print "Internal Error: Module called getTarget() but no target set."+ print("Internal Error: Module called getTarget() but no target set.")sys.exit(-1)return self._currentTarget@@ -1453,7 +1453,7 @@ class SpiderFootPlugin(object):storeOnly = False # Under some conditions, only store and don't notifyif sfEvent.data is None or (type(sfEvent.data) is unicode and len(sfEvent.data) == 0):- #print "No data to send for " + eventName + " to " + listener.__module__+ #print("No data to send for " + eventName + " to " + listener.__module__)return Noneif self.checkForStop():@@ -1478,23 +1478,23 @@ class SpiderFootPlugin(object):if prevEvent.sourceEvent is not None:if prevEvent.sourceEvent.eventType == sfEvent.eventType and \prevEvent.sourceEvent.data.lower() == sfEvent.data.lower():- #print "Skipping notification of " + sfEvent.eventType + " / " + sfEvent.data+ #print("Skipping notification of " + sfEvent.eventType + " / " + sfEvent.data)storeOnly = TruebreakprevEvent = prevEvent.sourceEventself._listenerModules.sort()for listener in self._listenerModules:- #print listener.__module__ + ": " + listener.watchedEvents().__str__()+ #print(listener.__module__ + ": " + listener.watchedEvents().__str__())if eventName not in listener.watchedEvents() and '*' not in listener.watchedEvents():- #print listener.__module__ + " not listening for " + eventName+ #print(listener.__module__ + " not listening for " + eventName)continueif storeOnly and "__stor" not in listener.__module__:- #print "Storing only for " + sfEvent.eventType + " / " + sfEvent.data+ #print("Storing only for " + sfEvent.eventType + " / " + sfEvent.data)continue- #print "Notifying " + eventName + " to " + listener.__module__+ #print("Notifying " + eventName + " to " + listener.__module__)listener._currentEvent = sfEvent# Check if we've been asked to stop in the meantime, so that@@ -1502,7 +1502,7 @@ class SpiderFootPlugin(object):if self.checkForStop():return None- #print "EVENT: " + str(sfEvent)+ #print("EVENT: " + str(sfEvent))try:listener.handleEvent(sfEvent)except BaseException as e:@@ -1569,7 +1569,7 @@ class SpiderFootTarget(object):self.targetValue = targetValueself.targetAliases = list()else:- print "Internal Error: Invalid target type."+ print("Internal Error: Invalid target type.")sys.exit(-1)def getType(self):@@ -1695,9 +1695,9 @@ class SpiderFootEvent(object):self.sourceEvent = sourceEventif type(data) in [ list, dict ]:- print "FATAL: Only string events are accepted, not lists or dicts."- print "FATAL: Offending module: " + module- print "FATAL: Offending type: " + eventType+ print("FATAL: Only string events are accepted, not lists or dicts.")+ print("FATAL: Offending module: " + module)+ print("FATAL: Offending type: " + eventType)sys.exit(-1)if type(data) != unicode and data != None:diff --git a/sfscan.py b/sfscan.pyindex bc010248..339b7491 100644--- a/sfscan.py+++ b/sfscan.py@@ -49,8 +49,8 @@ class SpiderFootScanner(threading.Thread):# Set the status of the currently running scan (if any)def setStatus(self, status, started=None, ended=None):if self.ts is None:- print "Internal Error: Status set attempted before " + \- "SpiderFootScanner was ready."+ print("Internal Error: Status set attempted before " + \+ "SpiderFootScanner was ready.")exit(-1)self.ts.status = statusdiff --git a/sfwebui.py b/sfwebui.pyindex 56e5f2af..4445edcf 100644--- a/sfwebui.py+++ b/sfwebui.py@@ -53,14 +53,14 @@ class SpiderFootWebUi:'error_page.404': self.error_page_404})- print ""- print ""- print "*************************************************************"- print " Use SpiderFoot by starting your web browser of choice and "- print " browse to http://" + addr + ":" + str(self.config['__webport']) + self.docroot- print "*************************************************************"- print ""- print ""+ print("")+ print("")+ print("*************************************************************")+ print(" Use SpiderFoot by starting your web browser of choice and ")+ print(" browse to http://" + addr + ":" + str(self.config['__webport']) + self.docroot)+ print("*************************************************************")+ print("")+ print("")def error_page_404(self, status, message, traceback, version):templ = Template(filename='dyn/error.tmpl', lookup=self.lookup)@@ -335,7 +335,7 @@ class SpiderFootWebUi:# Wait until the scan has initializedwhile globalScanStatus.getStatus(newId) == None:- print "[info] Waiting for the scan to initialize..."+ print("[info] Waiting for the scan to initialize...")time.sleep(1)templ = Template(filename='dyn/scaninfo.tmpl', lookup=self.lookup)@@ -379,7 +379,7 @@ class SpiderFootWebUi:# Wait until the scan has initializedwhile globalScanStatus.getStatus(newId) == None:- print "[info] Waiting for the scan to initialize..."+ print("[info] Waiting for the scan to initialize...")time.sleep(1)templ = Template(filename='dyn/scanlist.tmpl', lookup=self.lookup)@@ -803,7 +803,7 @@ class SpiderFootWebUi:# Wait until the scan has initializedwhile globalScanStatus.getStatus(scanId) is None:- print "[info] Waiting for the scan to initialize..."+ print("[info] Waiting for the scan to initialize...")time.sleep(1)if not cli: