Skip to content

SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.

New module for identifying use of Javascript frameworks.

smicallef4fd01385e5af
diff --git a/evtypes.sql b/evtypes.sql
index 868a62b6..48525b48 100644
--- a/evtypes.sql
+++ b/evtypes.sql
@@ -22,7 +22,8 @@ INSERT INTO tbl_event_types (event, event_descr, event_raw) VALUES ('TCP_PORT_OP
INSERT INTO tbl_event_types (event, event_descr, event_raw) VALUES ('URL_FORM', 'URL (Form)', 0);
INSERT INTO tbl_event_types (event, event_descr, event_raw) VALUES ('URL_FLASH', 'URL (Uses Flash)', 0);
INSERT INTO tbl_event_types (event, event_descr, event_raw) VALUES ('URL_JAVASCRIPT', 'URL (Uses Javascript)', 0);
-INSERT INTO tbl_event_types (event, event_descr, event_raw) VALUES ('URL_JAVA_APPLET', 'URL (Uses Java applet)', 0);
+INSERT INTO tbl_event_types (event, event_descr, event_raw) VALUES ('URL_JAVASCRIPT_FRAMEWORK', 'URL (Uses a Javascript Framework)', 0);
+INSERT INTO tbl_event_types (event, event_descr, event_raw) VALUES ('URL_JAVA_APPLET', 'URL (Uses Java Applet)', 0);
INSERT INTO tbl_event_types (event, event_descr, event_raw) VALUES ('URL_STATIC', 'URL (Purely Static)', 0);
INSERT INTO tbl_event_types (event, event_descr, event_raw) VALUES ('URL_PASSWORD', 'URL (Accepts Passwords)', 0);
INSERT INTO tbl_event_types (event, event_descr, event_raw) VALUES ('URL_UPLOAD', 'URL (Accepts Uploads)', 0);
diff --git a/modules/sfp_webframework.py b/modules/sfp_webframework.py
new file mode 100644
index 00000000..56387e3e
--- /dev/null
+++ b/modules/sfp_webframework.py
@@ -0,0 +1,106 @@
+#-------------------------------------------------------------------------------
+# Name: sfp_webframework
+# Purpose: Identify the usage of popular web frameworks.
+#
+# Author: Steve Micallef <[email protected]>
+#
+# Created: 25/05/2013
+# Copyright: (c) Steve Micallef 2013
+# Licence: GPL
+#-------------------------------------------------------------------------------
+
+import re
+import sys
+from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
+
+# SpiderFoot standard lib (must be initialized in setup)
+sf = None
+
+regexps = dict({
+ "jQuery": list(['jquery']), # unlikely false positive
+ "YUI": list(['\/yui\/', 'yui\-', 'yui\.']),
+ "Prototype": list(['\/prototype\/', 'prototype\-', 'prototype\.']),
+ "ZURB Foundation": list(['\/foundation\/', 'foundation\-', 'foundation\.']),
+ "Bootstrap": list(['\/bootstrap\/', 'bootstrap\-', 'bootstrap\.']),
+ "ExtJS": list(['[\'\"\=]ext\.js', 'extjs', '\/ext\/*\.js']),
+ "Mootools": list(['\/mootools\/', 'mootools\-', 'mootools\.']),
+ "Dojo": list(['\/dojo\/', '[\'\"\=]dojo\-', '[\'\"\=]dojo\.'])
+})
+
+class sfp_webframework(SpiderFootPlugin):
+ """Identify the usage of popular web frameworks like jQuery, YUI and others."""
+
+ # Default options
+ opts = { }
+
+ # Option descriptions
+ optdescs = {
+ # For each option in opts you should have a key/value pair here
+ # describing it. It will end up in the UI to explain the option
+ # to the end-user.
+ }
+
+ # Target
+ baseDomain = None # calculated from the URL in setup
+ results = dict()
+
+ def setup(self, sfc, target, userOpts=dict()):
+ global sf
+
+ sf = sfc
+ self.baseDomain = target
+ self.results = dict()
+
+ for opt in userOpts.keys():
+ self.opts[opt] = userOpts[opt]
+
+ # What events is this module interested in for input
+ # * = be notified about all events.
+ def watchedEvents(self):
+ return ["RAW_DATA"]
+
+ # Handle events sent to this module
+ def handleEvent(self, event):
+ eventName = event.eventType
+ srcModuleName = event.module
+ eventData = event.data
+
+ # We only want web content
+ if srcModuleName != "sfp_spider":
+ return None
+
+ # If you are processing RAW_DATA, this is how you would get the
+ # source of that raw data (e.g. a URL.)
+ eventSource = event.sourceEvent.data
+
+ sf.debug("Received event, " + eventName + ", from " + srcModuleName)
+
+ if eventSource not in self.results.keys():
+ self.results[eventSource] = list()
+
+ # We only want web content for pages on the target site
+ if not sf.urlBaseUrl(eventSource).endswith(self.baseDomain):
+ sf.debug("Not collecting web content information for external sites.")
+ return None
+
+ for regexpGrp in regexps.keys():
+ if regexpGrp in self.results[eventSource]:
+ next
+
+ for regex in regexps[regexpGrp]:
+ matches = re.findall(regex, eventData, re.IGNORECASE)
+ if len(matches) > 0 and regexpGrp not in self.results[eventSource]:
+ sf.info("Matched " + regexpGrp + " in content from " + eventSource)
+ self.results[eventSource].append(regexpGrp)
+ evt = SpiderFootEvent("URL_JAVASCRIPT_FRAMEWORK", regexpGrp,
+ self.__name__, event.sourceEvent)
+ self.notifyListeners(evt)
+
+ return None
+
+ # If you intend for this module to act on its own (e.g. not solely rely
+ # on events from other modules, then you need to have a start() method
+ # and within that method call self.checkForStop() to see if you've been
+ # politely asked by the controller to stop your activities (user abort.)
+
+# End of sfp_webframework class
diff --git a/sfdb.py b/sfdb.py
index 9bbaf77e..68117472 100644
--- a/sfdb.py
+++ b/sfdb.py
@@ -93,6 +93,7 @@ class SpiderFootDb:
"INSERT INTO tbl_event_types (event, event_descr, event_raw) VALUES ('URL_FORM', 'URL (Form)', 0)",
"INSERT INTO tbl_event_types (event, event_descr, event_raw) VALUES ('URL_FLASH', 'URL (Uses Flash)', 0)",
"INSERT INTO tbl_event_types (event, event_descr, event_raw) VALUES ('URL_JAVASCRIPT', 'URL (Uses Javascript)', 0)",
+ "INSERT INTO tbl_event_types (event, event_descr, event_raw) VALUES ('URL_JAVASCRIPT_FRAMEWORK', 'URL (Uses a Javascript Framework)', 0)",
"INSERT INTO tbl_event_types (event, event_descr, event_raw) VALUES ('URL_JAVA_APPLET', 'URL (Uses Java applet)', 0)",
"INSERT INTO tbl_event_types (event, event_descr, event_raw) VALUES ('URL_STATIC', 'URL (Purely Static)', 0)",
"INSERT INTO tbl_event_types (event, event_descr, event_raw) VALUES ('URL_PASSWORD', 'URL (Accepts Passwords)', 0)",
@@ -255,7 +256,7 @@ class SpiderFootDb:
def scanResultEvent(self, instanceId, eventType='ALL'):
qry = "SELECT ROUND(c.generated) AS generated, c.data, \
s.data as 'source_data', \
- c.module, c.type, c.confidence, c.visibility, c.risk \
+ c.module, c.type, c.confidence, c.visibility, c.risk, c.hash \
FROM tbl_scan_results c, tbl_scan_results s \
WHERE c.scan_instance_id = ? AND c.source_event_hash = s.hash AND \
s.scan_instance_id = c.scan_instance_id"