SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
Bug fixes
smicallefe692cbe2f12b
diff --git a/modules/sfp_dns.py b/modules/sfp_dns.pynew file mode 100644index 00000000..1936fbc0--- /dev/null+++ b/modules/sfp_dns.py@@ -0,0 +1,65 @@+#-------------------------------------------------------------------------------+# Name: sfp_dns+# Purpose: SpiderFoot plug-in for gathering IP addresses from sub-domains+# and hostnames identified, and optionally affiliates.+#+# Author: Steve Micallef <[email protected]>+#+# Created: 16/09/2012+# Copyright: (c) Steve Micallef 2012+# Licence: GPL+#-------------------------------------------------------------------------------++import sys+import re+import socket+from sflib import SpiderFoot, SpiderFootPlugin++# SpiderFoot standard lib (must be initialized in __init__)+sf = None++class sfp_dns(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 ["SUBDOMAIN", "AFFILIATE"]++ # Handle events sent to this module+ def handleEvent(self, srcModuleName, eventName, eventSource, eventData):+ sf.debug("Received event, " + eventName + ", from " + srcModuleName)+++ sf.debug("Found IP Address: " + match)+ self.notifyListeners("IP_ADDRESS", eventSource, match)++ return None++# End of sfp_dns class++if __name__ == '__main__':+ print "This module cannot be run stand-alone."+ exit(-1)diff --git a/modules/sfp_spider.py b/modules/sfp_spider.pyindex 74714ef0..4028d643 100644--- a/modules/sfp_spider.py+++ b/modules/sfp_spider.py@@ -27,10 +27,11 @@ class sfp_spider(SpiderFootPlugin):# options specific to this module'robotsonly': False, # only follow links specified by robots.txt'pause': 0, # number of seconds to pause between fetches- 'maxpages': 100, # max number of pages to fetch+ 'maxpages': 10000, # max number of pages to fetch'maxlevels': 10, # max number of levels to traverse within a site'filterfiles': ['png','gif','jpg','jpeg','tiff', 'tif', 'js', 'css',- 'pdf','tif','ico','flv'], # Extensions to not fetch+ 'pdf','tif','ico','flv', 'mp4', 'mp3', 'avi', 'mpg',+ 'mpeg', 'iso', 'dat', 'mov'], # Extensions to not fetch'filterusers': True, # Don't follow /~user directories'noexternal': True, # Should links to external sites be ignored? (**dangerous if False**)'nosubs': False # Should links to subdomains be ignored?@@ -212,7 +213,8 @@ class sfp_spider(SpiderFootPlugin):totalFetched += 1if totalFetched >= self.opts['maxpages']:- sf.debug("Maximum number of pages (" + str(self.opts['maxpages']) + ") reached.")+ sf.debug("Maximum number of pages (" + str(self.opts['maxpages']) ++ ") reached.")keepSpidering = Falsebreak@@ -227,11 +229,13 @@ class sfp_spider(SpiderFootPlugin):levelsTraversed += 1sf.debug("Now at traversal level: " + str(levelsTraversed))if levelsTraversed >= self.opts['maxlevels']:- sf.debug("Maximum number of levels (" + str(self.opts['maxlevels']) + ") reached.")+ sf.debug("Maximum number of levels (" + str(self.opts['maxlevels']) ++ ") reached.")keepSpidering = False# We've reached the end of our journey..if len(nextLinks) == 0:+ sf.debug("No more links found to spider, finishing..")keepSpidering = Falsereturndiff --git a/modules/sfp_xref.py b/modules/sfp_xref.pyindex 4a10e919..b30c44bd 100644--- a/modules/sfp_xref.py+++ b/modules/sfp_xref.py@@ -95,13 +95,18 @@ class sfp_xref(SpiderFootPlugin):return None# Search for mentions of our domain in the external site's data- matches = re.findall("(" + self.baseDomain + ")", res['content'], re.IGNORECASE)+ matches = re.findall("([\.\'\/\"\ ]" + self.baseDomain + ")", res['content'],+ re.IGNORECASE)+ # If the domain wasn't found in the affiliate, and checkbase is set,+ # fetch the base URL of the affiliate to check for a xref. Don't bother+ # if forcebase was set, as we would've already checked that anyway.if not self.opts['forcebase'] and len(matches) > 0 and self.opts['checkbase']:# Check the base url to see if there is an affiliationurl = sf.urlBaseUrl(eventData)res = sf.fetchUrl(url)- matches = re.findall("(" + self.baseDomain + ")", res['content'], re.IGNORECASE)+ matches = re.findall("([\.\'\/\"\ ]" + self.baseDomain + ")",+ res['content'], re.IGNORECASE)if len(matches) > 0:if self.results.has_key(url):diff --git a/sf.py b/sf.pyold mode 100644new mode 100755index 755c1d70..905745df--- a/sf.py+++ b/sf.py@@ -40,28 +40,28 @@ moduleConfig = {'enabled': True},'sfp_mail': {- 'enabled': False+ 'enabled': True},'sfp_websvr': {- 'enabled': False+ 'enabled': True},'sfp_stor_print': {'enabled': False},'sfp_subdomain': {- 'enabled': False+ 'enabled': True},'sfp_xref': {- 'enabled': False+ 'enabled': True},'sfp_similar': {- 'enabled': False+ 'enabled': True},'sfp_pageinfo': {- 'enabled': False+ 'enabled': True},'sfp_googlesearch': {- 'enabled': False+ 'enabled': True}}@@ -122,6 +122,10 @@ def main(url):sfdb.close()if __name__ == '__main__':+ if len(sys.argv) == 1:+ print "You must specify a target URL."+ sys.exit(-1)+# Process command-line options here (more advanced eventually..)seedUrl = sys.argv[1]