Skip to content

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

[PEP 8] - Style Violation Fixes Part 2

Gormogona7068c6650e4
diff --git a/modules/sfp_shodan.py b/modules/sfp_shodan.py
index e66f1c6b..44f89e0b 100644
--- a/modules/sfp_shodan.py
+++ b/modules/sfp_shodan.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
# Name: sfp_shodan
# Purpose: Query SHODAN for identified IP addresses.
#
@@ -8,25 +8,26 @@
# Created: 19/03/2014
# Copyright: (c) Steve Micallef
# Licence: GPL
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
import json
from netaddr import IPNetwork
from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
+
class sfp_shodan(SpiderFootPlugin):
"""SHODAN:Obtain information from SHODAN about identified IP addresses."""
# Default options
- opts = {
- "apikey": "",
+ opts = {
+ "apikey": "",
'netblocklookup': True,
'maxnetblock': 24
}
# Option descriptions
optdescs = {
- "apikey": "Your SHODAN API Key.",
+ "apikey": "Your SHODAN API Key.",
'netblocklookup': "Look up all IPs on netblocks deemed to be owned by your target for possible hosts on the same target subdomain/domain?",
'maxnetblock': "If looking up owned netblocks, the maximum netblock size to look up all IPs within (CIDR value, 24 = /24, 16 = /16, etc.)"
}
@@ -49,13 +50,13 @@ class sfp_shodan(SpiderFootPlugin):
# What events this module produces
def producedEvents(self):
- return ["OPERATING_SYSTEM", "DEVICE_TYPE",
- "TCP_PORT_OPEN", "TCP_PORT_OPEN_BANNER"]
+ return ["OPERATING_SYSTEM", "DEVICE_TYPE",
+ "TCP_PORT_OPEN", "TCP_PORT_OPEN_BANNER"]
def query(self, qry):
res = self.sf.fetchUrl("https://api.shodan.io/shodan/host/" + qry + \
- "?key=" + self.opts['apikey'],
- timeout=self.opts['_fetchtimeout'], useragent="SpiderFoot")
+ "?key=" + self.opts['apikey'],
+ timeout=self.opts['_fetchtimeout'], useragent="SpiderFoot")
if res['content'] is None:
self.sf.info("No SHODAN info found for " + qry)
return None
@@ -80,7 +81,7 @@ class sfp_shodan(SpiderFootPlugin):
self.sf.error("You enabled sfp_shodan but did not set an API key!", False)
return None
- # Don't look up stuff twice
+ # Don't look up stuff twice
if self.results.has_key(eventData):
self.sf.debug("Skipping " + eventData + " as already mapped.")
return None
@@ -90,8 +91,8 @@ class sfp_shodan(SpiderFootPlugin):
if eventName == 'NETBLOCK_OWNER' and self.opts['netblocklookup']:
if IPNetwork(eventData).prefixlen < self.opts['maxnetblock']:
self.sf.debug("Network size bigger than permitted: " + \
- str(IPNetwork(eventData).prefixlen) + " > " + \
- str(self.opts['maxnetblock']))
+ str(IPNetwork(eventData).prefixlen) + " > " + \
+ str(self.opts['maxnetblock']))
return None
qrylist = list()
@@ -113,13 +114,13 @@ class sfp_shodan(SpiderFootPlugin):
if rec.get('os') is not None:
# Notify other modules of what you've found
evt = SpiderFootEvent("OPERATING_SYSTEM", rec.get('os') + \
- " (" + addr +")", self.__name__, event)
+ " (" + addr + ")", self.__name__, event)
self.notifyListeners(evt)
if rec.get('devtype') is not None:
# Notify other modules of what you've found
evt = SpiderFootEvent("DEVICE_TYPE", rec.get('devtype') + \
- " (" + addr +")", self.__name__, event)
+ " (" + addr + ")", self.__name__, event)
self.notifyListeners(evt)
if rec.has_key('data'):
@@ -131,14 +132,14 @@ class sfp_shodan(SpiderFootPlugin):
if port is not None:
# Notify other modules of what you've found
cp = addr + ":" + port
- evt = SpiderFootEvent("TCP_PORT_OPEN", cp,
- self.__name__, event)
+ evt = SpiderFootEvent("TCP_PORT_OPEN", cp,
+ self.__name__, event)
self.notifyListeners(evt)
if banner is not None:
# Notify other modules of what you've found
- evt = SpiderFootEvent("TCP_PORT_OPEN_BANNER", banner,
- self.__name__, event)
+ evt = SpiderFootEvent("TCP_PORT_OPEN_BANNER", banner,
+ self.__name__, event)
self.notifyListeners(evt)
return None
diff --git a/modules/sfp_similar.py b/modules/sfp_similar.py
index d85df69b..279fb6ef 100644
--- a/modules/sfp_similar.py
+++ b/modules/sfp_similar.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
# Name: sfp_similar
# Purpose: SpiderFoot plug-in for identifying domains that look similar
# to the one being queried.
@@ -9,7 +9,7 @@
# Created: 06/04/2012
# Copyright: (c) Steve Micallef 2012
# Licence: GPL
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
import re
import time
@@ -38,21 +38,22 @@ whoisUrlN = "http://www.whois.net/domain-keyword-search/{0}/{1}"
whoisLastPageIndicator = "Next >"
whoisIncrement = 16
+
class sfp_similar(SpiderFootPlugin):
"""Similar Domains:Search various sources to identify similar looking domain names."""
# Default options
opts = {
- 'source': 'ALL', # domaintools, namedroppers or ALL
- 'method': 'left,right', # left and/or right (doesn't apply to whois.com)
- 'activeonly': True # Only report domains that have content (try to fetch the page)
+ 'source': 'ALL', # domaintools, namedroppers or ALL
+ 'method': 'left,right', # left and/or right (doesn't apply to whois.com)
+ 'activeonly': True # Only report domains that have content (try to fetch the page)
}
# Option descriptions
optdescs = {
- 'source': "Provider to use: 'domaintools', 'namedroppers' or 'ALL'.",
- 'method': "Pattern search method to use: 'left,right', 'left' or 'right'.",
- 'activeonly': "Only report domains that have content (try to fetch the page)?"
+ 'source': "Provider to use: 'domaintools', 'namedroppers' or 'ALL'.",
+ 'method': "Pattern search method to use: 'left,right', 'left' or 'right'.",
+ 'activeonly': "Only report domains that have content (try to fetch the page)?"
}
# Internal results tracking
@@ -66,21 +67,20 @@ class sfp_similar(SpiderFootPlugin):
self.opts[opt] = userOpts[opt]
def findDomains(self, keyword, content):
- pat = re.compile("([a-z0-9\-]*" + keyword + "[a-z0-9\-]*\.[a-z]+)",
- re.IGNORECASE)
+ pat = re.compile("([a-z0-9\-]*" + keyword + "[a-z0-9\-]*\.[a-z]+)", re.IGNORECASE)
matches = re.findall(pat, content)
return matches
# What events is this module interested in for input
def watchedEvents(self):
- return [ "INTERNET_NAME" ]
+ return ["INTERNET_NAME"]
# What events this module produces
# This is to support the end user in selecting modules based on events
# produced.
def producedEvents(self):
- return [ "SIMILARDOMAIN" ]
+ return ["SIMILARDOMAIN"]
# Fetch and loop through Whois.com results, updating our results data. Stop
# once we've reached the end.
@@ -99,8 +99,8 @@ class sfp_similar(SpiderFootPlugin):
if self.checkForStop():
return None
- whois = self.sf.fetchUrl(fetchPage, timeout=self.opts['_fetchtimeout'],
- useragent=self.opts['_useragent'])
+ whois = self.sf.fetchUrl(fetchPage, timeout=self.opts['_fetchtimeout'],
+ useragent=self.opts['_useragent'])
if whois['content'] is None:
return None
@@ -121,7 +121,7 @@ class sfp_similar(SpiderFootPlugin):
def scrapeDomaintools(self, keyword, position, sourceEvent):
reachedEnd = False
- i = 1 # Using 0 will cause the first page to appear twice
+ i = 1 # Using 0 will cause the first page to appear twice
while not reachedEnd:
if position == "LEFT":
fetchPage = domtoolUrlLeft.format(keyword, i)
@@ -131,8 +131,8 @@ class sfp_similar(SpiderFootPlugin):
if self.checkForStop():
return None
- domtool = self.sf.fetchUrl(fetchPage, timeout=self.opts['_fetchtimeout'],
- useragent=self.opts['_useragent'])
+ domtool = self.sf.fetchUrl(fetchPage, timeout=self.opts['_fetchtimeout'],
+ useragent=self.opts['_useragent'])
if domtool['content'] is None:
return None
@@ -156,7 +156,7 @@ class sfp_similar(SpiderFootPlugin):
def scrapeNamedroppers(self, keyword, position, sourceEvent):
reachedEnd = False
- i = 1 # Using 0 will cause the first page to appear twice
+ i = 1 # Using 0 will cause the first page to appear twice
while not reachedEnd:
if position == "LEFT":
fetchPage = namedropUrlLeft.format(keyword, i)
@@ -166,8 +166,8 @@ class sfp_similar(SpiderFootPlugin):
if self.checkForStop():
return None
- namedrop = self.sf.fetchUrl(fetchPage, timeout=self.opts['_fetchtimeout'],
- useragent=self.opts['_useragent'])
+ namedrop = self.sf.fetchUrl(fetchPage, timeout=self.opts['_fetchtimeout'],
+ useragent=self.opts['_useragent'])
if namedrop['content'] is None:
return None
@@ -196,8 +196,8 @@ class sfp_similar(SpiderFootPlugin):
if self.checkForStop():
return None
- pageContent = self.sf.fetchUrl('http://' + result,
- timeout=self.opts['_fetchtimeout'], useragent=self.opts['_useragent'])
+ pageContent = self.sf.fetchUrl('http://' + result,
+ timeout=self.opts['_fetchtimeout'], useragent=self.opts['_useragent'])
if pageContent['content'] is not None:
evt = SpiderFootEvent("SIMILARDOMAIN", result, self.__name__, source)
self.notifyListeners(evt)
diff --git a/modules/sfp_social.py b/modules/sfp_social.py
index 052b0d5d..95d553ac 100644
--- a/modules/sfp_social.py
+++ b/modules/sfp_social.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
# Name: sfp_social`
# Purpose: Identify the usage of popular social networks
#
@@ -8,7 +8,7 @@
# Created: 26/05/2013
# Copyright: (c) Steve Micallef 2013
# Licence: GPL
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
import re
from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
@@ -16,21 +16,22 @@ from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
regexps = dict({
"LinkedIn (Individual)": list(['.*linkedin.com/in/([a-zA-Z0-9_]+$)']),
"LinkedIn (Company)": list(['.*linkedin.com/company/([a-zA-Z0-9_]+$)']),
- "Github": list(['.*github.com/([a-zA-Z0-9_]+)\/']),
- "Google+": list(['.*plus.google.com/([0-9]+$)']),
- "Facebook": list(['.*facebook.com/([a-zA-Z0-9_]+$)']),
- "YouTube": list(['.*youtube.com/([a-zA-Z0-9_]+$)']),
- "Twitter": list(['.*twitter.com/([a-zA-Z0-9_]{1,15}$)',
- '.*twitter.com/#!/([a-zA-Z0-9_]{1,15}$)'
- ]),
- "SlideShare": list(['.*slideshare.net/([a-zA-Z0-9_]+$)'])
+ "Github": list(['.*github.com/([a-zA-Z0-9_]+)\/']),
+ "Google+": list(['.*plus.google.com/([0-9]+$)']),
+ "Facebook": list(['.*facebook.com/([a-zA-Z0-9_]+$)']),
+ "YouTube": list(['.*youtube.com/([a-zA-Z0-9_]+$)']),
+ "Twitter": list(['.*twitter.com/([a-zA-Z0-9_]{1,15}$)',
+ '.*twitter.com/#!/([a-zA-Z0-9_]{1,15}$)'
+ ]),
+ "SlideShare": list(['.*slideshare.net/([a-zA-Z0-9_]+$)'])
})
+
class sfp_social(SpiderFootPlugin):
"""Social Networks:Identify presence on social media networks such as LinkedIn, Twitter and others."""
# Default options
- opts = { }
+ opts = {}
# Option descriptions
optdescs = {
@@ -57,7 +58,7 @@ class sfp_social(SpiderFootPlugin):
# This is to support the end user in selecting modules based on events
# produced.
def producedEvents(self):
- return [ "SOCIAL_MEDIA" ]
+ return ["SOCIAL_MEDIA"]
# Handle events sent to this module
def handleEvent(self, event):
@@ -78,7 +79,7 @@ class sfp_social(SpiderFootPlugin):
if bits is not None:
self.sf.info("Matched " + regexpGrp + " in " + eventData)
evt = SpiderFootEvent("SOCIAL_MEDIA", regexpGrp + ": " + \
- bits.group(1), self.__name__, event)
+ bits.group(1), self.__name__, event)
self.notifyListeners(evt)
return None
diff --git a/modules/sfp_socialprofiles.py b/modules/sfp_socialprofiles.py
index 4ef3358d..33a46b3a 100644
--- a/modules/sfp_socialprofiles.py
+++ b/modules/sfp_socialprofiles.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
# Name: sfp_socialprofiles
# Purpose: Obtains social media profiles of any identified human names.
#
@@ -8,7 +8,7 @@
# Created: 12/04/2014
# Copyright: (c) Steve Micallef 2014
# Licence: GPL
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
import random
import re
@@ -19,14 +19,15 @@ from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
sites = {
# Search string to use, domain name the profile will sit on within
# those search results.
- "Facebook": ['+intitle:%22{0}%22%20+site:facebook.com',
- '"(https?://[a-z\.]*facebook.[a-z\.]+/[^\"<> ]+)"' ],
- "Google+": ['+intitle:%22{0}%22%20+site:plus.google.com',
- '"(https?://plus.google.[a-z\.]+/\d+[^\"<>\/ ]+)"' ],
- "LinkedIn": ['+intitle:%22{0}%22%20+site:linkedin.com',
- '"(https?://[a-z\.]*linkedin.[a-z\.]+/[^\"<> ]+)"' ]
+ "Facebook": ['+intitle:%22{0}%22%20+site:facebook.com',
+ '"(https?://[a-z\.]*facebook.[a-z\.]+/[^\"<> ]+)"'],
+ "Google+": ['+intitle:%22{0}%22%20+site:plus.google.com',
+ '"(https?://plus.google.[a-z\.]+/\d+[^\"<>\/ ]+)"'],
+ "LinkedIn": ['+intitle:%22{0}%22%20+site:linkedin.com',
+ '"(https?://[a-z\.]*linkedin.[a-z\.]+/[^\"<> ]+)"']
}
+
class sfp_socialprofiles(SpiderFootPlugin):
"""Social Media Profiles:Identify the social media profiles for human names identified."""
@@ -56,13 +57,13 @@ class sfp_socialprofiles(SpiderFootPlugin):
# What events is this module interested in for input
def watchedEvents(self):
- return [ "HUMAN_NAME" ]
+ return ["HUMAN_NAME"]
# What events this module produces
# This is to support the end user in selecting modules based on events
# produced.
def producedEvents(self):
- return [ "SOCIAL_MEDIA" ]
+ return ["SOCIAL_MEDIA"]
def yahooCleaner(self, string):
ret = "\"" + urllib.unquote(string.group(1)) + "\""
@@ -95,18 +96,18 @@ class sfp_socialprofiles(SpiderFootPlugin):
if self.opts['method'].lower() == "google":
results = self.sf.googleIterate(searchStr, dict(limit=self.opts['pages'],
- useragent=self.opts['_useragent'],
- timeout=self.opts['_fetchtimeout']))
+ useragent=self.opts['_useragent'],
+ timeout=self.opts['_fetchtimeout']))
if self.opts['method'].lower() == "yahoo":
results = self.sf.yahooIterate(searchStr, dict(limit=self.opts['pages'],
- useragent=self.opts['_useragent'],
- timeout=self.opts['_fetchtimeout']))
+ useragent=self.opts['_useragent'],
+ timeout=self.opts['_fetchtimeout']))
if self.opts['method'].lower() == "bing":
results = self.sf.bingIterate(searchStr, dict(limit=self.opts['pages'],
- useragent=self.opts['_useragent'],
- timeout=self.opts['_fetchtimeout']))
+ useragent=self.opts['_useragent'],
+ timeout=self.opts['_fetchtimeout']))
if results is None:
self.sf.info("No data returned from " + self.opts['method'] + ".")
@@ -123,8 +124,8 @@ class sfp_socialprofiles(SpiderFootPlugin):
instances = list()
# Yahoo requires some additional parsing
if self.opts['method'].lower() == "yahoo":
- res = re.sub("RU=(.[^\/]+)\/RK=", self.yahooCleaner,
- results[key], 0)
+ res = re.sub("RU=(.[^\/]+)\/RK=", self.yahooCleaner,
+ results[key], 0)
else:
res = results[key]
@@ -144,7 +145,7 @@ class sfp_socialprofiles(SpiderFootPlugin):
# for a firm relationship.
if self.opts['tighten']:
pres = self.sf.fetchUrl(match, timeout=self.opts['_fetchtimeout'],
- useragent=self.opts['_useragent'])
+ useragent=self.opts['_useragent'])
if pres['content'] is None:
continue
@@ -152,19 +153,19 @@ class sfp_socialprofiles(SpiderFootPlugin):
found = False
for kw in self.keywords:
if re.search("[^a-zA-Z\-\_]" + kw + \
- "[^a-zA-Z\-\_]", pres['content'], re.IGNORECASE):
+ "[^a-zA-Z\-\_]", pres['content'], re.IGNORECASE):
found = True
if not found:
continue
self.sf.info("Social Media Profile found at " + site + ": " + match)
- evt = SpiderFootEvent("SOCIAL_MEDIA", match,
- self.__name__, event)
+ evt = SpiderFootEvent("SOCIAL_MEDIA", match,
+ self.__name__, event)
self.notifyListeners(evt)
# Submit the bing results for analysis
- evt = SpiderFootEvent("SEARCH_ENGINE_WEB_CONTENT", res,
- self.__name__, event)
+ evt = SpiderFootEvent("SEARCH_ENGINE_WEB_CONTENT", res,
+ self.__name__, event)
self.notifyListeners(evt)
# End of sfp_socialprofiles class
diff --git a/modules/sfp_spider.py b/modules/sfp_spider.py
index 7df41b55..fcc8ec4a 100644
--- a/modules/sfp_spider.py
+++ b/modules/sfp_spider.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
# Name: sfp_spider
# Purpose: SpiderFoot plug-in for spidering sites and returning meta data
# for other plug-ins to consume.
@@ -9,46 +9,47 @@
# Created: 25/03/2012
# Copyright: (c) Steve Micallef 2012
# Licence: GPL
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
import time
from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
+
class sfp_spider(SpiderFootPlugin):
"""Spider:Spidering of web-pages to extract content for searching. """
# Default options
opts = {
- 'robotsonly': False, # only follow links specified by robots.txt
- 'pause': 1, # number of seconds to pause between fetches
- 'maxpages': 100, # max number of pages to fetch
- 'maxlevels': 3, # max number of levels to traverse within a site
- 'usecookies': True, # Use cookies?
- 'start': [ 'http://', 'https://' ],
- 'filterfiles': ['png','gif','jpg','jpeg','tiff', 'tif', 'tar',
- 'pdf','ico','flv', 'mp4', 'mp3', 'avi', 'mpg', 'gz',
+ 'robotsonly': False, # only follow links specified by robots.txt
+ 'pause': 1, # number of seconds to pause between fetches
+ 'maxpages': 100, # max number of pages to fetch
+ 'maxlevels': 3, # max number of levels to traverse within a site
+ 'usecookies': True, # Use cookies?
+ 'start': ['http://', 'https://'],
+ 'filterfiles': ['png', 'gif', 'jpg', 'jpeg', 'tiff', 'tif', 'tar',
+ 'pdf', 'ico', 'flv', 'mp4', 'mp3', 'avi', 'mpg', 'gz',
'mpeg', 'iso', 'dat', 'mov', 'swf', 'rar', 'exe', 'zip',
'bin', 'bz2', 'xsl', 'doc', 'docx', 'ppt', 'pptx', 'xls',
'xlsx', 'csv'],
- '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?
- 'noparents': True
+ '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?
+ 'noparents': True
}
# Option descriptions
optdescs = {
- 'robotsonly': "Only follow links specified by robots.txt?",
- 'pause': "Number of seconds to pause between fetches.",
- 'usecookies': "Accept and use cookies?",
- 'start': "Prepend targets with these until you get a hit, to start spidering.",
- 'maxpages': "Maximum number of pages to fetch per target identified.",
- 'maxlevels': "Maximum levels to traverse per target identified.",
- 'filterfiles': "File extensions to ignore (don't fetch them.)",
- 'filterusers': "Skip spidering of /~user directories?",
- 'noexternal': "Skip spidering of external sites? (**dangerous if False**)",
- 'nosubs': "Skip spidering of subdomains of the target?",
- 'noparents': "Skip spidering of parent domains of your target?"
+ 'robotsonly': "Only follow links specified by robots.txt?",
+ 'pause': "Number of seconds to pause between fetches.",
+ 'usecookies': "Accept and use cookies?",
+ 'start': "Prepend targets with these until you get a hit, to start spidering.",
+ 'maxpages': "Maximum number of pages to fetch per target identified.",
+ 'maxlevels': "Maximum levels to traverse per target identified.",
+ 'filterfiles': "File extensions to ignore (don't fetch them.)",
+ 'filterusers': "Skip spidering of /~user directories?",
+ 'noexternal': "Skip spidering of external sites? (**dangerous if False**)",
+ 'nosubs': "Skip spidering of subdomains of the target?",
+ 'noparents': "Skip spidering of parent domains of your target?"
}
# If using robots.txt, this will get populated with filter rules
@@ -80,8 +81,8 @@ class sfp_spider(SpiderFootPlugin):
self.sf.debug("Restoring cookies for " + site + ": " + str(self.siteCookies[site]))
cookies = self.siteCookies[site]
# Fetch the contents of the supplied URL (object returned)
- fetched = self.sf.fetchUrl(url, False, cookies,
- self.opts['_fetchtimeout'], self.opts['_useragent'])
+ fetched = self.sf.fetchUrl(url, False, cookies,
+ self.opts['_fetchtimeout'], self.opts['_useragent'])
self.fetchedPages[url] = True
# Track cookies a site has sent, then send the back in subsquent requests
@@ -101,9 +102,9 @@ class sfp_spider(SpiderFootPlugin):
# Store the content for the redirect so that it isn't fetched again
self.fetchedPages[fetched['realurl']] = True
# Notify modules about the new link
- self.urlEvents[fetched['realurl']] = self.linkNotify(fetched['realurl'],
- self.urlEvents[url])
- url = fetched['realurl'] # override the URL if we had a redirect
+ self.urlEvents[fetched['realurl']] = self.linkNotify(fetched['realurl'],
+ self.urlEvents[url])
+ url = fetched['realurl'] # override the URL if we had a redirect
# Extract links from the content
links = self.sf.parseLinks(url, fetched['content'], self.getTarget().getNames())
@@ -132,19 +133,19 @@ class sfp_spider(SpiderFootPlugin):
# Optionally skip external sites (typical behaviour..)
if self.opts['noexternal'] and not \
- self.getTarget().matches(linkFQDN):
+ self.getTarget().matches(linkFQDN):
self.sf.debug('Ignoring external site: ' + link)
continue
# Optionally skip sub-domain sites
if self.opts['nosubs'] and not \
- self.getTarget().matches(linkFQDN, includeChildren=False):
+ self.getTarget().matches(linkFQDN, includeChildren=False):
self.sf.debug("Ignoring subdomain: " + link)
continue
# Optionally skip parent domain sites
if self.opts['noparents'] and not \
- self.getTarget().matches(linkFQDN, includeParents=False):
+ self.getTarget().matches(linkFQDN, includeParents=False):
self.sf.debug("Ignoring parent domain: " + link)
continue
@@ -184,30 +185,30 @@ class sfp_spider(SpiderFootPlugin):
# Notify listening modules about raw data and others
def contentNotify(self, url, httpresult, parentEvent=None):
- event = SpiderFootEvent("TARGET_WEB_CONTENT", httpresult['content'],
- self.__name__, parentEvent)
+ event = SpiderFootEvent("TARGET_WEB_CONTENT", httpresult['content'],
+ self.__name__, parentEvent)
self.notifyListeners(event)
event = SpiderFootEvent("WEBSERVER_HTTPHEADERS", httpresult['headers'],
- self.__name__, parentEvent)
+ self.__name__, parentEvent)
self.notifyListeners(event)
event = SpiderFootEvent("HTTP_CODE", str(httpresult['code']),
- self.__name__, parentEvent)
+ self.__name__, parentEvent)
self.notifyListeners(event)
# Trigger spidering off the following events..
# Spidering and search engines provide LINKED_URL_INTERNAL, and DNS lookups
# provide INTERNET_NAME.
def watchedEvents(self):
- return [ "LINKED_URL_INTERNAL", "INTERNET_NAME" ]
+ return ["LINKED_URL_INTERNAL", "INTERNET_NAME"]
# What events this module produces
# This is to support the end user in selecting modules based on events
# produced.
def producedEvents(self):
- return [ "WEBSERVER_HTTPHEADERS", "HTTP_CODE", "LINKED_URL_INTERNAL",
- "LINKED_URL_EXTERNAL", "TARGET_WEB_CONTENT" ]
+ return ["WEBSERVER_HTTPHEADERS", "HTTP_CODE", "LINKED_URL_INTERNAL",
+ "LINKED_URL_EXTERNAL", "TARGET_WEB_CONTENT"]
# Some other modules may request we spider things
def handleEvent(self, event):
@@ -224,7 +225,7 @@ class sfp_spider(SpiderFootPlugin):
self.sf.debug("Received event, " + eventName + ", from " + srcModuleName)
if eventData in self.urlEvents.keys():
- self.sf.debug("Ignoring " + eventData + " as already spidered or is being spidered.")
+ self.sf.debug("Ignoring " + eventData + " as already spidered or is being spidered.")
return None
else:
self.urlEvents[eventData] = event
@@ -232,12 +233,12 @@ class sfp_spider(SpiderFootPlugin):
# Determine where to start spidering from if it's a INTERNET_NAME event
if eventName == "INTERNET_NAME":
for prefix in self.opts['start']:
- res = self.sf.fetchUrl(prefix + eventData, timeout=self.opts['_fetchtimeout'],
- useragent=self.opts['_useragent'])
+ res = self.sf.fetchUrl(prefix + eventData, timeout=self.opts['_fetchtimeout'],
+ useragent=self.opts['_useragent'])
if res['content'] is not None:
spiderTarget = prefix + eventData
evt = SpiderFootEvent("LINKED_URL_INTERNAL", spiderTarget,
- self.__name__, event)
+ self.__name__, event)
self.notifyListeners(evt)
break
else:
@@ -262,8 +263,8 @@ class sfp_spider(SpiderFootPlugin):
# Are we respecting robots.txt?
if self.opts['robotsonly'] and not self.robotsRules.has_key(targetBase):
- robotsTxt = self.sf.fetchUrl(targetBase + '/robots.txt',
- timeout=self.opts['_fetchtimeout'], useragent=self.opts['_useragent'])
+ robotsTxt = self.sf.fetchUrl(targetBase + '/robots.txt',
+ timeout=self.opts['_fetchtimeout'], useragent=self.opts['_useragent'])
if robotsTxt['content'] is not None:
self.sf.debug('robots.txt contents: ' + robotsTxt['content'])
self.robotsRules[targetBase] = self.sf.parseRobotsTxt(robotsTxt['content'])
@@ -307,7 +308,7 @@ class sfp_spider(SpiderFootPlugin):
totalFetched += 1
if totalFetched >= self.opts['maxpages']:
self.sf.info("Maximum number of pages (" + str(self.opts['maxpages']) + \
- ") reached.")
+ ") reached.")
keepSpidering = False
break
@@ -319,7 +320,7 @@ class sfp_spider(SpiderFootPlugin):
self.sf.info("Now at traversal level: " + str(levelsTraversed))
if levelsTraversed >= self.opts['maxlevels']:
self.sf.info("Maximum number of levels (" + str(self.opts['maxlevels']) + \
- ") reached.")
+ ") reached.")
keepSpidering = False
# We've reached the end of our journey..
@@ -332,4 +333,5 @@ class sfp_spider(SpiderFootPlugin):
keepSpidering = False
return
+
# End of sfp_spider class
diff --git a/modules/sfp_sslcert.py b/modules/sfp_sslcert.py
index aed3fe6e..c220f88c 100644
--- a/modules/sfp_sslcert.py
+++ b/modules/sfp_sslcert.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
# Name: sfp_sslcert
# Purpose: Gather information about SSL certificates behind HTTPS sites.
#
@@ -8,7 +8,7 @@
# Created: 23/08/2013
# Copyright: (c) Steve Micallef
# Licence: GPL
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
import socket
import socks
@@ -17,20 +17,21 @@ import time
import M2Crypto
from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
+
class sfp_sslcert(SpiderFootPlugin):
"""SSL:Gather information about SSL certificates used by the target's HTTPS sites."""
# Default options
- opts = {
- "tryhttp": True,
- "ssltimeout": 5,
+ opts = {
+ "tryhttp": True,
+ "ssltimeout": 5,
"certexpiringdays": 30
}
# Option descriptions
- optdescs = {
- "tryhttp": "Also try to HTTPS-connect to HTTP sites and hostnames.",
- "ssltimeout": "Seconds before giving up trying to HTTPS connect.",
+ optdescs = {
+ "tryhttp": "Also try to HTTPS-connect to HTTP sites and hostnames.",
+ "ssltimeout": "Seconds before giving up trying to HTTPS connect.",
"certexpiringdays": "Number of days in the future a certificate expires to consider it as expiring."
}
@@ -58,9 +59,9 @@ class sfp_sslcert(SpiderFootPlugin):
# This is to support the end user in selecting modules based on events
# produced.
def producedEvents(self):
- return [ "SSL_CERTIFICATE_ISSUED", "SSL_CERTIFICATE_ISSUER",
- "SSL_CERTIFICATE_MISMATCH", "SSL_CERTIFICATE_EXPIRED",
- "SSL_CERTIFICATE_EXPIRING", "SSL_CERTIFICATE_RAW" ]
+ return ["SSL_CERTIFICATE_ISSUED", "SSL_CERTIFICATE_ISSUER",
+ "SSL_CERTIFICATE_MISMATCH", "SSL_CERTIFICATE_EXPIRED",
+ "SSL_CERTIFICATE_EXPIRING", "SSL_CERTIFICATE_RAW"]
# Handle events sent to this module
def handleEvent(self, event):
@@ -138,7 +139,7 @@ class sfp_sslcert(SpiderFootPlugin):
self.sf.debug("No alternative name found in certificate.")
fqdn_tld = ".".join(fqdn.split(".")[1:]).lower()
- if "dns:"+fqdn not in hosts and "dns:*."+fqdn_tld not in hosts:
+ if "dns:" + fqdn not in hosts and "dns:*." + fqdn_tld not in hosts:
evt = SpiderFootEvent("SSL_CERTIFICATE_MISMATCH", hosts, self.__name__, sevt)
self.notifyListeners(evt)
@@ -150,14 +151,12 @@ class sfp_sslcert(SpiderFootPlugin):
warnexp = now + self.opts['certexpiringdays'] * 86400
if exp <= now:
- evt = SpiderFootEvent("SSL_CERTIFICATE_EXPIRED", expstr, self.__name__,
- sevt)
+ evt = SpiderFootEvent("SSL_CERTIFICATE_EXPIRED", expstr, self.__name__, sevt)
self.notifyListeners(evt)
return None
-
+
if exp <= warnexp:
- evt = SpiderFootEvent("SSL_CERTIFICATE_EXPIRING", expstr, self.__name__,
- sevt)
+ evt = SpiderFootEvent("SSL_CERTIFICATE_EXPIRING", expstr, self.__name__, sevt)
self.notifyListeners(evt)
return None
diff --git a/modules/sfp_stor_print.py b/modules/sfp_stor_print.py
index 73f8d3bc..95f59db4 100644
--- a/modules/sfp_stor_print.py
+++ b/modules/sfp_stor_print.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
# Name: sfp_stor_print
# Purpose: SpiderFoot plug-in for 'storing' events (by printing them to
# the screen. This is used for debugging.
@@ -9,14 +9,15 @@
# Created: 06/04/2012
# Copyright: (c) Steve Micallef 2012
# Licence: GPL
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
from sflib import SpiderFoot, SpiderFootPlugin
+
class sfp_stor_print(SpiderFootPlugin):
# Default options
opts = {
- 'datasize': 100 # Number of characters to print from event data
+ 'datasize': 100 # Number of characters to print from event data
}
# Option descriptions
diff --git a/modules/sfp_strangeheaders.py b/modules/sfp_strangeheaders.py
index a907bbc5..d6c6b867 100644
--- a/modules/sfp_strangeheaders.py
+++ b/modules/sfp_strangeheaders.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
# Name: sfp_strangeheaders
# Purpose: SpiderFoot plug-in for identifying non-standard HTTP headers
# in web server responses.
@@ -9,25 +9,26 @@
# Created: 01/12/2013
# Copyright: (c) Steve Micallef 2013
# Licence: GPL
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
# Standard headers, taken from http://en.wikipedia.org/wiki/List_of_HTTP_header_fields
-headers = [ "access-control-allow-origin","accept-ranges","age","allow","cache-control",
-"connection","content-encoding","content-language","content-length","content-location",
-"content-md5","content-disposition","content-range","content-type","date","etag",
-"expires","last-modified","link","location","p3p","pragma","proxy-authenticate",
-"refresh","retry-after","server","set-cookie","status","strict-transport-security",
-"trailer","transfer-encoding","vary","via","warning","www-authenticate",
-"x-frame-options","x-xss-protection","content-security-policy","x-content-security-policy",
-"x-webkit-csp","x-content-type-options","x-powered-by","x-ua-compatible" ]
+headers = ["access-control-allow-origin", "accept-ranges", "age", "allow", "cache-control",
+ "connection", "content-encoding", "content-language", "content-length", "content-location",
+ "content-md5", "content-disposition", "content-range", "content-type", "date", "etag",
+ "expires", "last-modified", "link", "location", "p3p", "pragma", "proxy-authenticate",
+ "refresh", "retry-after", "server", "set-cookie", "status", "strict-transport-security",
+ "trailer", "transfer-encoding", "vary", "via", "warning", "www-authenticate",
+ "x-frame-options", "x-xss-protection", "content-security-policy", "x-content-security-policy",
+ "x-webkit-csp", "x-content-type-options", "x-powered-by", "x-ua-compatible"]
+
class sfp_strangeheaders(SpiderFootPlugin):
"""Strange Headers:Obtain non-standard HTTP headers returned by web servers."""
# Default options
- opts = { }
+ opts = {}
results = dict()
@@ -46,7 +47,7 @@ class sfp_strangeheaders(SpiderFootPlugin):
# This is to support the end user in selecting modules based on events
# produced.
def producedEvents(self):
- return [ "WEBSERVER_STRANGEHEADER" ]
+ return ["WEBSERVER_STRANGEHEADER"]
# Handle events sent to this module
def handleEvent(self, event):
@@ -69,8 +70,8 @@ class sfp_strangeheaders(SpiderFootPlugin):
for key in eventData:
if key.lower() not in headers:
val = key + ": " + eventData[key]
- evt = SpiderFootEvent("WEBSERVER_STRANGEHEADER", val,
- self.__name__, parentEvent)
+ evt = SpiderFootEvent("WEBSERVER_STRANGEHEADER", val,
+ self.__name__, parentEvent)
self.notifyListeners(evt)
# End of sfp_strangeheaders class
diff --git a/modules/sfp_template.py b/modules/sfp_template.py
index 411aff9b..6d638541 100644
--- a/modules/sfp_template.py
+++ b/modules/sfp_template.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
# Name: sfp_XXX
# Purpose: Description of the plug-in.
#
@@ -8,15 +8,16 @@
# Created: Date
# Copyright: (c) Name
# Licence: GPL
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
+
class sfp_XXX(SpiderFootPlugin):
"""Name:Description"""
# Default options
- opts = { }
+ opts = {}
# Option descriptions
optdescs = {
diff --git a/modules/sfp_tldsearch.py b/modules/sfp_tldsearch.py
index f86aed70..22e15f96 100644
--- a/modules/sfp_tldsearch.py
+++ b/modules/sfp_tldsearch.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
# Name: sfp_tldsearch
# Purpose: SpiderFoot plug-in for identifying the existence of this target
# on other TLDs.
@@ -9,28 +9,29 @@
# Created: 31/08/2013
# Copyright: (c) Steve Micallef 2013
# Licence: GPL
-#-------------------------------------------------------------------------------
+# -------------------------------------------------------------------------------
import socket
import random
import threading
from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
+
class sfp_tldsearch(SpiderFootPlugin):
"""TLD Search:Search all Internet TLDs for domains with the same name as the target (this can be slow.)"""
# Default options
opts = {
- 'activeonly': True, # Only report domains that have content (try to fetch the page)
- 'skipwildcards': True,
- 'maxthreads': 100
+ 'activeonly': True, # Only report domains that have content (try to fetch the page)
+ 'skipwildcards': True,
+ 'maxthreads': 100
}
# Option descriptions
optdescs = {
- 'activeonly': "Only report domains that have content (try to fetch the page)?",
- "skipwildcards": "Skip TLDs and sub-TLDs that have wildcard DNS.",
- "maxthreads": "Number of simultaneous DNS resolutions to perform at once."
+ 'activeonly': "Only report domains that have content (try to fetch the page)?",
+ "skipwildcards": "Skip TLDs and sub-TLDs that have wildcard DNS.",
+ "maxthreads": "Number of simultaneous DNS resolutions to perform at once."
}
# Internal results tracking
@@ -48,13 +49,13 @@ class sfp_tldsearch(SpiderFootPlugin):
# What events is this module interested in for input
def watchedEvents(self):
- return [ "INTERNET_NAME" ]
+ return ["INTERNET_NAME"]
# What events this module produces
# This is to support the end user in selecting modules based on events
# produced.
def producedEvents(self):
- return [ "SIMILARDOMAIN" ]
+ return ["SIMILARDOMAIN"]
def tryTld(self, target):
try:
@@ -72,7 +73,7 @@ class sfp_tldsearch(SpiderFootPlugin):
# Spawn threads for scanning
self.sf.info("Spawning threads to check TLDs: " + str(tldList))
for tld in tldList:
- tn = 'sfp_tldsearch_' + str(random.randint(0,999999999))
+ tn = 'sfp_tldsearch_' + str(random.randint(0, 999999999))
t.append(threading.Thread(name=tn, target=self.tryTld, args=(tld,)))
t[i].start()
i += 1
@@ -102,7 +103,7 @@ class sfp_tldsearch(SpiderFootPlugin):
return None
pageContent = self.sf.fetchUrl('http://' + result,
- timeout=self.opts['_fetchtimeout'], useragent=self.opts['_useragent'])
+ timeout=self.opts['_fetchtimeout'], useragent=self.opts['_useragent'])
if pageContent['content'] is not None:
evt = SpiderFootEvent("SIMILARDOMAIN", result, self.__name__, source)
self.notifyListeners(evt)