SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
Added a standard module template. Added a module for classifying pages.
Steve Micallefeffb7d7ff2f6
diff --git a/modules/sfp_pageinfo.py b/modules/sfp_pageinfo.pynew file mode 100644index 00000000..54f0e8f0--- /dev/null+++ b/modules/sfp_pageinfo.py@@ -0,0 +1,93 @@+#-------------------------------------------------------------------------------+# Name: sfp_pageinfo+# Purpose: SpiderFoot plug-in for scanning retreived content by other+# modules (such as sfp_spider) and building up information about+# the page, such as whether it uses Javascript plug-ins, has+# forms, and more.+#+# Author: Steve Micallef <[email protected]>+#+# Created: 02/05/2012+# Copyright: (c) Steve Micallef 2012+# Licence: GPL+#-------------------------------------------------------------------------------++import sys+import re+from sflib import SpiderFoot, SpiderFootPlugin++# SpiderFoot standard lib (must be initialized in __init__)+sf = None++# Indentify pages that use Javascript libs, handle passwords, have forms,+# permit file uploads and more to come.+regexps = dict({+ 'WEBCONTENT_JAVASCRIPT': list(['text/javascript', '<script']),+ 'WEBCONTENT_FORM': list(['<form ', 'method=[PG]']),+ 'WEBCONTENT_PASSWORD': list(['type=[\"\']*password']),+ 'WEBCONTENT_UPLOAD': list(['type=[\"\']*file'])+})++results = dict()++class sfp_pageinfo(SpiderFootPlugin):+ # Default options+ opts = {+ # These must always be set+ '_debug': True,+ '_debugfilter': ''+ }++ # URL this instance is working on+ seedUrl = None+ baseDomain = None # calculated from the URL in __init__++ def __init__(self, url, userOpts=dict()):+ global sf+ self.seedUrl = url++ for opt in userOpts.keys():+ self.opts[opt] = userOpts[opt]++ # For error reporting, debug, etc.+ sf = SpiderFoot(self.opts)++ # Extract the 'meaningful' part of the FQDN from the URL+ self.baseDomain = sf.urlBaseDom(self.seedUrl)+ sf.debug('Base Domain: ' + self.baseDomain)++ # What events is this module interested in for input+ def watchedEvents(self):+ return ["WEBCONTENT"]++ # Handle events sent to this module+ def handleEvent(self, srcModuleName, eventName, eventSource, eventData):+ sf.debug("Received event, " + eventName + ", from " + srcModuleName)++ if eventSource not in results.keys():+ results[eventSource] = list()+ else:+ return None++ for regexpGrp in regexps.keys():+ for regex in regexps[regexpGrp]:+ matches = re.findall(regex, eventData, re.IGNORECASE)+ if len(matches) > 0:+ sf.debug("Matched " + regex + " in content from " + eventSource)+ self.notifyListeners(regexpGrp, eventSource, eventData)+ results[eventSource].append(regexpGrp)+ # Don't bother checking other regexps in this regexp group+ break++ # If no regexps were matched, consider this a static page+ if len(results[eventSource]) == 0:+ sf.debug("Treating " + eventSource + " as WEBCONTENT_STATIC")+ self.notifyListeners("WEBCONTENT_STATIC", eventSource, eventData)++ return None++# End of sfp_pageinfo class++if __name__ == '__main__':+ print "This module cannot be run stand-alone."+ exit(-1)diff --git a/modules/sfp_template.py b/modules/sfp_template.pynew file mode 100644index 00000000..48d5637d--- /dev/null+++ b/modules/sfp_template.py@@ -0,0 +1,59 @@+#-------------------------------------------------------------------------------+# Name: sfp_XXX+# Purpose: Template for plug-ins to use.+#+# Author: Steve Micallef <[email protected]>+#+# Created: 02/05/2012+# Copyright: (c) Steve Micallef 2012+# Licence: GPL+#-------------------------------------------------------------------------------++import sys+import re+from sflib import SpiderFoot, SpiderFootPlugin++# SpiderFoot standard lib (must be initialized in __init__)+sf = None++class sfp_XXX(SpiderFootPlugin):+ # Default options+ opts = {+ # These must always be set+ '_debug': True,+ '_debugfilter': ''+ }++ # URL this instance is working on+ seedUrl = None+ baseDomain = None # calculated from the URL in __init__++ def __init__(self, url, userOpts=dict()):+ global sf+ self.seedUrl = url++ for opt in userOpts.keys():+ self.opts[opt] = userOpts[opt]++ # For error reporting, debug, etc.+ sf = SpiderFoot(self.opts)++ # Extract the 'meaningful' part of the FQDN from the URL+ self.baseDomain = sf.urlBaseDom(self.seedUrl)+ sf.debug('Base Domain: ' + self.baseDomain)++ # What events is this module interested in for input+ def watchedEvents(self):+ return ["WEBCONTENT"]++ # Handle events sent to this module+ def handleEvent(self, srcModuleName, eventName, eventSource, eventData):+ sf.debug("Received event, " + eventName + ", from " + srcModuleName)++ return None++# End of sfp_XXX class++if __name__ == '__main__':+ print "This module cannot be run stand-alone."+ exit(-1)diff --git a/sf.py b/sf.pyindex 748e2517..456a4d28 100644--- a/sf.py+++ b/sf.py@@ -12,7 +12,7 @@import imp# URL to start from. This will be set either by the CLI or UI-seedUrl = 'http://www.telstra.com.au'+seedUrl = 'http://www.binarypool.com'# These are all hard-coded for now, but will eventually# be set by the UI or CLI@@ -20,7 +20,7 @@ seedUrl = 'http://www.telstra.com.au'# These can be overriden on a per-module basissfConfig = {'_debug': True, # Debug- '_debugfilter': 'xref', # Filter out debug strings+ '_debugfilter': 'pageinfo', # Filter out debug strings'_blocknotif': False, # Block notifications'_useragent': 'SpiderFoot/2.0', # User-Agent to use for HTTP requests'_fetchtimeout': 1, # number of seconds before giving up on a fetch@@ -40,16 +40,19 @@ moduleConfig = {'enabled': False},'sfp_stor_print': {- 'enabled': False+ 'enabled': True},'sfp_subdomain': {'enabled': False},'sfp_xref': {- 'enabled': True+ 'enabled': False},'sfp_similar': {'enabled': False+ },+ 'sfp_pageinfo': {+ 'enabled': True}}@@ -84,8 +87,8 @@ def main(url):if listenerModule != module and listenerModule.watchedEvents() != None:module.registerListener(listenerModule)+ # Start the modules sequentially.for module in moduleInstances.values():- # If the module extends the Thread class, then start it as a threadmodule.start()if __name__ == '__main__':