SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
Fetching DNS SPF records and initial seeds of SpiderFoot CLI.
Steve8fa9a79705e5
diff --git a/modules/sfp_dns.py b/modules/sfp_dns.pyindex 938f40bc..4495345c 100644--- a/modules/sfp_dns.py+++ b/modules/sfp_dns.py@@ -134,7 +134,7 @@ class sfp_dns(SpiderFootPlugin):def producedEvents(self):return ["IP_ADDRESS", "INTERNET_NAME", "PROVIDER_MAIL", "DOMAIN_NAME","PROVIDER_DNS", "AFFILIATE_INTERNET_NAME", "RAW_DNS_RECORDS",- "DNS_TEXT", "IPV6_ADDRESS", "DOMAIN_NAME_PARENT"]+ "DNS_TEXT", "DNS_SPF", "IPV6_ADDRESS", "DOMAIN_NAME_PARENT"]# Handle events sent to this moduledef handleEvent(self, event):@@ -473,6 +473,11 @@ class sfp_dns(SpiderFootPlugin):evt = SpiderFootEvent("AFFILIATE_INTERNET_NAME",strdata, self.__name__, parentEvent)self.notifyListeners(evt)+ if rec == "TXT" and "v=spf" in strdata:+ evt = SpiderFootEvent("DNS_SPF", strdata,+ self.__name__, parentEvent)+ self.notifyListeners(evt)+else:strdata = unicode(str(x), 'utf-8', errors='replace')evt = SpiderFootEvent("RAW_DNS_RECORDS", strdata,diff --git a/sfdb.py b/sfdb.pyindex ab79ec79..aa8c608f 100644--- a/sfdb.py+++ b/sfdb.py@@ -118,6 +118,7 @@ class SpiderFootDb:"INSERT INTO tbl_event_types (event, event_descr, event_raw, event_type) VALUES ('DESCRIPTION_ABSTRACT', 'Description - Abstract', 0, 'DESCRIPTOR')","INSERT INTO tbl_event_types (event, event_descr, event_raw, event_type) VALUES ('DEVICE_TYPE', 'Device Type', 0, 'DESCRIPTOR')","INSERT INTO tbl_event_types (event, event_descr, event_raw, event_type) VALUES ('DNS_TEXT', 'DNS TXT Record', 0, 'DATA')",+ "INSERT INTO tbl_event_types (event, event_descr, event_raw, event_type) VALUES ('DNS_SPF', 'DNS SPF Record', 0, 'DATA')","INSERT INTO tbl_event_types (event, event_descr, event_raw, event_type) VALUES ('DOMAIN_NAME', 'Domain Name', 0, 'ENTITY')","INSERT INTO tbl_event_types (event, event_descr, event_raw, event_type) VALUES ('DOMAIN_NAME_PARENT', 'Domain Name (Parent)', 0, 'ENTITY')","INSERT INTO tbl_event_types (event, event_descr, event_raw, event_type) VALUES ('DOMAIN_REGISTRAR', 'Domain Registrar', 0, 'ENTITY')",diff --git a/sfwebui.py b/sfwebui.pyindex 3f1de9d4..bc454dc0 100644--- a/sfwebui.py+++ b/sfwebui.py@@ -517,8 +517,46 @@ class SpiderFootWebUi:resultsetfp.exposed = True+ # For the CLI to fetch a list of event types.+ def eventtypes(self):+ dbh = SpiderFootDb(self.config)+ types = dbh.eventTypes()++ return json.dumps(types)++ eventtypes.exposed = True++ # For the CLI to fetch a list of modules.+ def modules(self):+ modinfo = self.config['__modules__'].keys()+ return json.dumps(modinfo)++ modules.exposed = True++ # For the CLI to test connectivity to this server.+ def ping(self):+ return json.dumps(["SUCCESS", ""])++ ping.exposed = True++ # For the CLI to run queries against the database.+ def query(self, query):+ data = None+ dbh = SpiderFootDb(cfg)+ if not query.startswith("SELECT"):+ return json_dumps(["ERROR", "Non-SELECTs are unpredictable and not recommended."])+ try:+ ret = dbh.execute(query)+ data = ret.fetchall()+ except BaseException as e:+ return json_dumps(["ERROR", str(e)])++ return json_dumps(data)++ query.exposed = True+# Initiate a scan- def startscan(self, scanname, scantarget, modulelist, typelist, usecase):+ def startscan(self, scanname, scantarget, modulelist, typelist, usecase, cli=None):global globalScanStatus# Snapshot the current configuration to be used by the scan@@ -532,10 +570,17 @@ class SpiderFootWebUi:[scanname, scantarget] = self.cleanUserInput([scanname, scantarget])if scanname == "" or scantarget == "":- return self.error("Form incomplete.")+ if not cli:+ return self.error("Form incomplete.")+ else:+ return json.dumps(["ERROR", "Incorrect usage."])if typelist == "" and modulelist == "" and usecase == "":- return self.error("Form incomplete.")+ if not cli:+ return self.error("Form incomplete.")+ else:+ return json.dumps(["ERROR", "Incorrect usage."])+# User selected modulesif modulelist != "":@@ -572,8 +617,12 @@ class SpiderFootWebUi:targetType = sf.targetType(scantarget)if targetType is None:- return self.error("Invalid target type. Could not recognize it as " + \- "an IP address, IP subnet, domain name or host name.")+ if not cli:+ return self.error("Invalid target type. Could not recognize it as " + \+ "an 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)@@ -586,9 +635,12 @@ class SpiderFootWebUi:print "[info] Waiting for the scan to initialize..."time.sleep(1)- templ = Template(filename='dyn/scaninfo.tmpl', lookup=self.lookup)- return templ.render(id=scanId, name=scanname, docroot=self.docroot,- status=globalScanStatus.getStatus(scanId), pageid="SCANLIST")+ if not cli:+ templ = Template(filename='dyn/scaninfo.tmpl', lookup=self.lookup)+ return templ.render(id=scanId, name=scanname, docroot=self.docroot,+ status=globalScanStatus.getStatus(scanId), pageid="SCANLIST")+ else:+ return json.dumps(["SUCCESS", scanId])startscan.exposed = True@@ -633,30 +685,46 @@ class SpiderFootWebUi:# Stop a scan.- def stopscan(self, id):+ def stopscan(self, id, cli=None):global globalScanStatusdbh = SpiderFootDb(self.config)scaninfo = dbh.scanInstanceGet(id)if scaninfo is None:- return self.error("Invalid scan ID.")+ if not cli:+ return self.error("Invalid scan ID.")+ else:+ return json.dumps(["ERROR", "Invalid scan ID."])if globalScanStatus.getStatus(id) is None:- return self.error("That scan is not actually running. A data consistency " + \- "error for this scan probably exists. <a href='/scandelete?id=" + \- id + "&confirm=1'>Click here to delete it.</a>")+ if not cli:+ return self.error("That scan is not actually running. A data consistency " + \+ "error for this scan probably exists. <a href='/scandelete?id=" + \+ id + "&confirm=1'>Click here to delete it.</a>")+ else:+ return json.dumps(["ERROR", "Scan is still running."])if globalScanStatus.getStatus(id) == "ABORTED":- return self.error("The scan is already aborted.")+ if not cli:+ return self.error("The scan is already aborted.")+ else:+ return json.dumps(["ERROR", "Scan already aborted."])+if not globalScanStatus.getStatus(id) == "RUNNING":- return self.error("The running scan is currently in the state '" + \- globalScanStatus.getStatus(id) + "', please try again later or restart " + \- " SpiderFoot.")+ if not cli:+ return self.error("The running scan is currently in the state '" + \+ globalScanStatus.getStatus(id) + "', please try again later or restart " + \+ " SpiderFoot.")+ else:+ return json.dumps(["ERROR", "Scan in an invalid state for stopping."])globalScanStatus.setStatus(id, "ABORT-REQUESTED")- templ = Template(filename='dyn/scanlist.tmpl', lookup=self.lookup)- return templ.render(pageid='SCANLIST', stoppedscan=True, docroot=self.docroot, errors=list())+ if not cli:+ templ = Template(filename='dyn/scanlist.tmpl', lookup=self.lookup)+ return templ.render(pageid='SCANLIST', stoppedscan=True, docroot=self.docroot, errors=list())+ else:+ return json.dumps(["SUCCESS", ""])stopscan.exposed = True