Skip to content

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

Unicode support and more tolerant error handling.

Steve Micallef6992a1a425b2
diff --git a/dyn/scaninfo.tmpl b/dyn/scaninfo.tmpl
index a7e0fba5..462fd158 100644
--- a/dyn/scaninfo.tmpl
+++ b/dyn/scaninfo.tmpl
@@ -1,3 +1,4 @@
+## -*- coding: utf-8 -*-
<%include file="HEADER.tmpl"/>
<h2>${name} &nbsp;<img id=loader src=${docroot}/static/img/loader.gif></h2>
<div class="btn-toolbar">
@@ -172,12 +173,8 @@
table += "<td>" + data[i][8] + "</td>";
}
table += "<td><pre style='border: 0px; background-color: inherit'>";
- //table += "<a href='${docroot}/entityinfo?id=" + data[i][7] + "'>" + data[i][1] + "</a>";
table += sf.replace_sfurltag(data[i][1]);
// for debug
- //table += "</pre></td><td><pre style='border: 0px; background-color: inherit'>" + data[i][7];
- //table += "</pre></td><td><pre style='border: 0px; background-color: inherit'>" + data[i][5];
- //table += "</pre></td><td><pre style='border: 0px; background-color: inherit'>" + data[i][6];
table += "</pre></td><td><pre style='border: 0px; background-color: inherit'>";
table += sf.replace_sfurltag(data[i][2]);
table += "</pre></td><td><pre style='border: 0px; background-color: inherit'>" + data[i][3];
diff --git a/modules/sfp_abusech.py b/modules/sfp_abusech.py
index 7acdf06e..edb31ab1 100644
--- a/modules/sfp_abusech.py
+++ b/modules/sfp_abusech.py
@@ -229,14 +229,19 @@ class sfp_abusech(SpiderFootPlugin):
self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
return url
else:
- # Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ try:
+ # Check for the domain and the hostname
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
diff --git a/modules/sfp_alienvaultiprep.py b/modules/sfp_alienvaultiprep.py
index 5168cbd7..c6875226 100644
--- a/modules/sfp_alienvaultiprep.py
+++ b/modules/sfp_alienvaultiprep.py
@@ -51,11 +51,11 @@ class sfp_alienvaultiprep(SpiderFootPlugin):
# Be sure to completely clear any class variables in setup()
# or you run the risk of data persisting between scan runs.
- results = list()
+ results = dict()
def setup(self, sfc, userOpts=dict()):
self.sf = sfc
- self.results = list()
+ self.results = dict()
# Clear / reset any other class member variables here
# or you risk them persisting between threads.
@@ -177,13 +177,18 @@ class sfp_alienvaultiprep(SpiderFootPlugin):
return url
else:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ try:
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
@@ -211,7 +216,7 @@ class sfp_alienvaultiprep(SpiderFootPlugin):
self.sf.debug("Skipping " + eventData + ", already checked.")
return None
else:
- self.results.append(eventData)
+ self.results[eventData] = True
if eventName == 'CO_HOSTED_SITE' and not self.opts.get('checkcohosts', False):
return None
diff --git a/modules/sfp_badipscom.py b/modules/sfp_badipscom.py
index c56f3943..11349e27 100644
--- a/modules/sfp_badipscom.py
+++ b/modules/sfp_badipscom.py
@@ -47,11 +47,11 @@ class sfp_badipscom(SpiderFootPlugin):
# Be sure to completely clear any class variables in setup()
# or you run the risk of data persisting between scan runs.
- results = list()
+ results = dict()
def setup(self, sfc, userOpts=dict()):
self.sf = sfc
- self.results = list()
+ self.results = dict()
# Clear / reset any other class member variables here
# or you risk them persisting between threads.
@@ -176,13 +176,18 @@ class sfp_badipscom(SpiderFootPlugin):
return url
else:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ try:
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
@@ -210,7 +215,7 @@ class sfp_badipscom(SpiderFootPlugin):
self.sf.debug("Skipping " + eventData + ", already checked.")
return None
else:
- self.results.append(eventData)
+ self.results[eventData] = True
if eventName == 'CO_HOSTED_SITE' and not self.opts.get('checkcohosts', False):
return None
diff --git a/modules/sfp_bambenek.py b/modules/sfp_bambenek.py
index a24d0641..bc834daf 100644
--- a/modules/sfp_bambenek.py
+++ b/modules/sfp_bambenek.py
@@ -190,8 +190,8 @@ class sfp_bambenek(SpiderFootPlugin):
else:
try:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
for line in data['content'].split('\n'):
if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
re.match(rxTgt, line, re.IGNORECASE):
diff --git a/modules/sfp_bitcash.py b/modules/sfp_bitcash.py
index ddf2e023..155cd3b7 100644
--- a/modules/sfp_bitcash.py
+++ b/modules/sfp_bitcash.py
@@ -47,11 +47,11 @@ class sfp_bitcash(SpiderFootPlugin):
# Be sure to completely clear any class variables in setup()
# or you run the risk of data persisting between scan runs.
- results = list()
+ results = dict()
def setup(self, sfc, userOpts=dict()):
self.sf = sfc
- self.results = list()
+ self.results = dict()
# Clear / reset any other class member variables here
# or you risk them persisting between threads.
@@ -173,13 +173,18 @@ class sfp_bitcash(SpiderFootPlugin):
return url
else:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ try:
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
@@ -207,7 +212,7 @@ class sfp_bitcash(SpiderFootPlugin):
self.sf.debug("Skipping " + eventData + ", already checked.")
return None
else:
- self.results.append(eventData)
+ self.results[eventData] = True
if eventName == 'CO_HOSTED_SITE' and not self.opts.get('checkcohosts', False):
return None
diff --git a/modules/sfp_blocklistde.py b/modules/sfp_blocklistde.py
index c7920f8e..1742d672 100644
--- a/modules/sfp_blocklistde.py
+++ b/modules/sfp_blocklistde.py
@@ -50,11 +50,11 @@ class sfp_blocklistde(SpiderFootPlugin):
# Be sure to completely clear any class variables in setup()
# or you run the risk of data persisting between scan runs.
- results = list()
+ results = dict()
def setup(self, sfc, userOpts=dict()):
self.sf = sfc
- self.results = list()
+ self.results = dict()
# Clear / reset any other class member variables here
# or you risk them persisting between threads.
@@ -177,13 +177,18 @@ class sfp_blocklistde(SpiderFootPlugin):
return url
else:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ try:
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
@@ -211,7 +216,7 @@ class sfp_blocklistde(SpiderFootPlugin):
self.sf.debug("Skipping " + eventData + ", already checked.")
return None
else:
- self.results.append(eventData)
+ self.results[eventData] = True
if eventName == 'CO_HOSTED_SITE' and not self.opts.get('checkcohosts', False):
return None
diff --git a/modules/sfp_censys.py b/modules/sfp_censys.py
index ebacade3..11ffc270 100644
--- a/modules/sfp_censys.py
+++ b/modules/sfp_censys.py
@@ -72,7 +72,7 @@ class sfp_censys(SpiderFootPlugin):
headers = {
'Authorization': "Basic " + base64.b64encode(self.opts['censys_api_key_uid'] + ":" + self.opts['censys_api_key_secret'])
}
- url = censys_url + "/" + querytype.format(qry)
+ url = censys_url + "/" + querytype.format(qry.encode('utf-8', errors='replace'))
res = self.sf.fetchUrl(url , timeout=self.opts['_fetchtimeout'],
useragent="SpiderFoot", headers=headers)
diff --git a/modules/sfp_cinsscore.py b/modules/sfp_cinsscore.py
index a5e0e446..ba2800f4 100644
--- a/modules/sfp_cinsscore.py
+++ b/modules/sfp_cinsscore.py
@@ -5,7 +5,7 @@
#
#
-# Created: 30/05/2018
+# Created: 13/05/2018
# Copyright: (c) Steve Micallef, 2018
# Licence: GPL
# -------------------------------------------------------------------------------
@@ -18,7 +18,7 @@ malchecks = {
'cinsscore.com List': {
'id': '_cinsscore',
'type': 'list',
- 'checks': ['ip', 'netblock'],
+ 'checks': ['ip'],
'url': 'http://cinsscore.com/list/ci-badguys.txt'
}
}
@@ -48,11 +48,11 @@ class sfp_cinsscore(SpiderFootPlugin):
# Be sure to completely clear any class variables in setup()
# or you run the risk of data persisting between scan runs.
- results = list()
+ results = dict()
def setup(self, sfc, userOpts=dict()):
self.sf = sfc
- self.results = list()
+ self.results = dict()
# Clear / reset any other class member variables here
# or you risk them persisting between threads.
@@ -175,13 +175,18 @@ class sfp_cinsscore(SpiderFootPlugin):
return url
else:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ try:
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
@@ -209,7 +214,7 @@ class sfp_cinsscore(SpiderFootPlugin):
self.sf.debug("Skipping " + eventData + ", already checked.")
return None
else:
- self.results.append(eventData)
+ self.results[eventData] = True
if eventName == 'CO_HOSTED_SITE' and not self.opts.get('checkcohosts', False):
return None
diff --git a/modules/sfp_cleantalk.py b/modules/sfp_cleantalk.py
index 5155182f..4fad9f91 100644
--- a/modules/sfp_cleantalk.py
+++ b/modules/sfp_cleantalk.py
@@ -175,13 +175,18 @@ class sfp_cleantalk(SpiderFootPlugin):
return url
else:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ try:
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
diff --git a/modules/sfp_coinblocker.py b/modules/sfp_coinblocker.py
index 5f32d3e0..a489c4eb 100644
--- a/modules/sfp_coinblocker.py
+++ b/modules/sfp_coinblocker.py
@@ -188,14 +188,19 @@ class sfp_coinblocker(SpiderFootPlugin):
self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
return url
else:
+ try:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
diff --git a/modules/sfp_cryptoioc.py b/modules/sfp_cryptoioc.py
index f4003235..7f1a70f7 100644
--- a/modules/sfp_cryptoioc.py
+++ b/modules/sfp_cryptoioc.py
@@ -180,13 +180,18 @@ class sfp_cryptoioc(SpiderFootPlugin):
return url
else:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ try:
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
diff --git a/modules/sfp_cybercrimetracker.py b/modules/sfp_cybercrimetracker.py
index 4ae97755..9a8525a2 100644
--- a/modules/sfp_cybercrimetracker.py
+++ b/modules/sfp_cybercrimetracker.py
@@ -177,8 +177,8 @@ class sfp_cybercrimetracker(SpiderFootPlugin):
else:
# Check for the domain and the hostname
try:
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
for line in data['content'].split('\n'):
if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
re.match(rxTgt, line, re.IGNORECASE):
diff --git a/modules/sfp_cymon.py b/modules/sfp_cymon.py
index 6c3e22ea..e037ea3c 100644
--- a/modules/sfp_cymon.py
+++ b/modules/sfp_cymon.py
@@ -91,7 +91,7 @@ class sfp_cymon(SpiderFootPlugin):
headers = {
'Authorization': "Token " + self.opts['cymon_api_key']
}
- url = cymon_url + "/" + querytype.format(qry)
+ url = cymon_url + "/" + querytype.format(qry.encode('utf-8', errors='replace'))
res = self.sf.fetchUrl(url , timeout=self.opts['_fetchtimeout'],
useragent="SpiderFoot", headers=headers)
diff --git a/modules/sfp_dnsbrute.py b/modules/sfp_dnsbrute.py
index 99830d94..7562bde9 100644
--- a/modules/sfp_dnsbrute.py
+++ b/modules/sfp_dnsbrute.py
@@ -98,6 +98,7 @@ class sfp_dnsbrute(SpiderFootPlugin):
return self.resolveCache[hostname]
try:
+ hostname = hostname.encode("idna")
addrs = self.sf.normalizeDNS(socket.gethostbyname_ex(hostname))
self.resolveCache[hostname] = addrs
self.sf.debug("Resolved " + hostname + " to: " + str(addrs))
@@ -169,6 +170,9 @@ class sfp_dnsbrute(SpiderFootPlugin):
return None
self.events[eventDataHash] = True
+ # Handle Unicode characters in the name
+ eventData = eventData.encode("idna")
+
if eventName == "INTERNET_NAME" and not self.getTarget().matches(eventData, includeChildren=False):
if not self.opts['numbersuffix']:
return None
diff --git a/modules/sfp_dnsneighbor.py b/modules/sfp_dnsneighbor.py
index c6e0b4fa..6c4ba82b 100644
--- a/modules/sfp_dnsneighbor.py
+++ b/modules/sfp_dnsneighbor.py
@@ -169,6 +169,7 @@ class sfp_dnsneighbor(SpiderFootPlugin):
return self.resolveCache[hostname]
try:
+ hostname = hostname.encode("idna")
addrs = self.sf.normalizeDNS(socket.gethostbyname_ex(hostname))
self.resolveCache[hostname] = addrs
self.sf.debug("Resolved " + hostname + " to: " + str(addrs))
diff --git a/modules/sfp_dnsresolve.py b/modules/sfp_dnsresolve.py
index 3deafe83..9b6c2d57 100644
--- a/modules/sfp_dnsresolve.py
+++ b/modules/sfp_dnsresolve.py
@@ -15,6 +15,7 @@ import socket
import re
import dns
import urllib2
+import encodings
from netaddr import IPAddress, IPNetwork
from sflib import SpiderFoot, SpiderFootPlugin, SpiderFootEvent
@@ -88,6 +89,9 @@ class sfp_dnsresolve(SpiderFootPlugin):
target.setAlias(host, "IP_ADDRESS")
else:
target.setAlias(host, "INTERNET_NAME")
+ idnahost = host.encode("idna")
+ if idnahost != host:
+ target.setAlias(idnahost, "INTERNET_NAME")
# If the target was a hostname/sub-domain, we can
# add the domain as an alias for the target. But
# not if the target was an IP or subnet.
@@ -120,7 +124,8 @@ class sfp_dnsresolve(SpiderFootPlugin):
def producedEvents(self):
return ["IP_ADDRESS", "INTERNET_NAME", "AFFILIATE_INTERNET_NAME",
"AFFILIATE_IPADDR", "DOMAIN_NAME", "IPV6_ADDRESS",
- "DOMAIN_NAME_PARENT", "CO_HOSTED_SITE_DOMAIN", "AFFILIATE_DOMAIN"]
+ "DOMAIN_NAME_PARENT", "CO_HOSTED_SITE_DOMAIN", "AFFILIATE_DOMAIN",
+ "INTERNET_NAME_UNRESOLVED"]
# Handle events sent to this module
def handleEvent(self, event):
@@ -265,6 +270,8 @@ class sfp_dnsresolve(SpiderFootPlugin):
return self.resolveCache[hostname]
try:
+ # IDNA-encode the hostname in case it contains unicode
+ hostname = hostname.encode("idna")
addrs = self.sf.normalizeDNS(socket.gethostbyname_ex(hostname))
self.resolveCache[hostname] = addrs
self.sf.debug("Resolved " + hostname + " to: " + str(addrs))
diff --git a/modules/sfp_fortinet.py b/modules/sfp_fortinet.py
index 6df801d5..96a0751c 100644
--- a/modules/sfp_fortinet.py
+++ b/modules/sfp_fortinet.py
@@ -44,11 +44,11 @@ class sfp_fortinet(SpiderFootPlugin):
# Be sure to completely clear any class variables in setup()
# or you run the risk of data persisting between scan runs.
- results = list()
+ results = dict()
def setup(self, sfc, userOpts=dict()):
self.sf = sfc
- self.results = list()
+ self.results = dict()
# Clear / reset any other class member variables here
# or you risk them persisting between threads.
@@ -171,13 +171,18 @@ class sfp_fortinet(SpiderFootPlugin):
return url
else:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ try:
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
@@ -205,7 +210,7 @@ class sfp_fortinet(SpiderFootPlugin):
self.sf.debug("Skipping " + eventData + ", already checked.")
return None
else:
- self.results.append(eventData)
+ self.results[eventData] = True
if eventName == 'CO_HOSTED_SITE' and not self.opts.get('checkcohosts', False):
return None
diff --git a/modules/sfp_isc.py b/modules/sfp_isc.py
index 5dcdd7f3..64b4105b 100644
--- a/modules/sfp_isc.py
+++ b/modules/sfp_isc.py
@@ -44,11 +44,11 @@ class sfp_isc(SpiderFootPlugin):
# Be sure to completely clear any class variables in setup()
# or you run the risk of data persisting between scan runs.
- results = list()
+ results = dict()
def setup(self, sfc, userOpts=dict()):
self.sf = sfc
- self.results = list()
+ self.results = dict()
# Clear / reset any other class member variables here
# or you risk them persisting between threads.
@@ -169,13 +169,18 @@ class sfp_isc(SpiderFootPlugin):
return url
else:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ try:
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
@@ -203,7 +208,7 @@ class sfp_isc(SpiderFootPlugin):
self.sf.debug("Skipping " + eventData + ", already checked.")
return None
else:
- self.results.append(eventData)
+ self.results[eventData] = True
if eventName == 'CO_HOSTED_SITE' and not self.opts.get('checkcohosts', False):
return None
diff --git a/modules/sfp_malc0de.py b/modules/sfp_malc0de.py
index 744d6aa9..895f515e 100644
--- a/modules/sfp_malc0de.py
+++ b/modules/sfp_malc0de.py
@@ -48,11 +48,11 @@ class sfp_malc0de(SpiderFootPlugin):
# Be sure to completely clear any class variables in setup()
# or you run the risk of data persisting between scan runs.
- results = list()
+ results = dict()
def setup(self, sfc, userOpts=dict()):
self.sf = sfc
- self.results = list()
+ self.results = dict()
# Clear / reset any other class member variables here
# or you risk them persisting between threads.
@@ -175,13 +175,18 @@ class sfp_malc0de(SpiderFootPlugin):
return url
else:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ try:
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
@@ -209,7 +214,7 @@ class sfp_malc0de(SpiderFootPlugin):
self.sf.debug("Skipping " + eventData + ", already checked.")
return None
else:
- self.results.append(eventData)
+ self.results[eventData] = True
if eventName == 'CO_HOSTED_SITE' and not self.opts.get('checkcohosts', False):
return None
diff --git a/modules/sfp_malwaredomainlist.py b/modules/sfp_malwaredomainlist.py
index 9161fd91..74e77a6c 100644
--- a/modules/sfp_malwaredomainlist.py
+++ b/modules/sfp_malwaredomainlist.py
@@ -33,10 +33,6 @@ malchecks = {
class sfp_malwaredomainlist(SpiderFootPlugin):
"""malwaredomainlist.com:Investigate,Passive:Reputation Systems::Check if a host/domain, IP or netblock is malicious according to malwaredomainlist.com."""
-
-
-
-
# Default options
opts = {
'malwaredomainlistdomain': True,
@@ -62,11 +58,11 @@ class sfp_malwaredomainlist(SpiderFootPlugin):
# Be sure to completely clear any class variables in setup()
# or you run the risk of data persisting between scan runs.
- results = list()
+ results = dict()
def setup(self, sfc, userOpts=dict()):
self.sf = sfc
- self.results = list()
+ self.results = dict()
# Clear / reset any other class member variables here
# or you risk them persisting between threads.
@@ -191,13 +187,18 @@ class sfp_malwaredomainlist(SpiderFootPlugin):
return url
else:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ try:
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
@@ -225,7 +226,7 @@ class sfp_malwaredomainlist(SpiderFootPlugin):
self.sf.debug("Skipping " + eventData + ", already checked.")
return None
else:
- self.results.append(eventData)
+ self.results[eventData] = True
if eventName == 'CO_HOSTED_SITE' and not self.opts.get('checkcohosts', False):
return None
diff --git a/modules/sfp_malwaredomains.py b/modules/sfp_malwaredomains.py
index 14fb9efe..d5b388e3 100644
--- a/modules/sfp_malwaredomains.py
+++ b/modules/sfp_malwaredomains.py
@@ -46,11 +46,11 @@ class sfp_malwaredomains(SpiderFootPlugin):
# Be sure to completely clear any class variables in setup()
# or you run the risk of data persisting between scan runs.
- results = list()
+ results = dict()
def setup(self, sfc, userOpts=dict()):
self.sf = sfc
- self.results = list()
+ self.results = dict()
# Clear / reset any other class member variables here
# or you risk them persisting between threads.
@@ -172,13 +172,18 @@ class sfp_malwaredomains(SpiderFootPlugin):
return url
else:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ try:
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
@@ -206,7 +211,7 @@ class sfp_malwaredomains(SpiderFootPlugin):
self.sf.debug("Skipping " + eventData + ", already checked.")
return None
else:
- self.results.append(eventData)
+ self.results[eventData] = True
if eventName == 'CO_HOSTED_SITE' and not self.opts.get('checkcohosts', False):
return None
diff --git a/modules/sfp_multiproxy.py b/modules/sfp_multiproxy.py
index 0dfa95f0..469d3bb7 100644
--- a/modules/sfp_multiproxy.py
+++ b/modules/sfp_multiproxy.py
@@ -45,11 +45,11 @@ class sfp_multiproxy(SpiderFootPlugin):
# Be sure to completely clear any class variables in setup()
# or you run the risk of data persisting between scan runs.
- results = list()
+ results = dict()
def setup(self, sfc, userOpts=dict()):
self.sf = sfc
- self.results = list()
+ self.results = dict()
# Clear / reset any other class member variables here
# or you risk them persisting between threads.
@@ -171,13 +171,18 @@ class sfp_multiproxy(SpiderFootPlugin):
return url
else:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ try:
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
@@ -205,7 +210,7 @@ class sfp_multiproxy(SpiderFootPlugin):
self.sf.debug("Skipping " + eventData + ", already checked.")
return None
else:
- self.results.append(eventData)
+ self.results[eventData] = True
if eventName == 'CO_HOSTED_SITE' and not self.opts.get('checkcohosts', False):
return None
diff --git a/modules/sfp_nothink.py b/modules/sfp_nothink.py
index 4efce179..2b2a76ac 100644
--- a/modules/sfp_nothink.py
+++ b/modules/sfp_nothink.py
@@ -38,10 +38,6 @@ malchecks = {
class sfp_nothink(SpiderFootPlugin):
"""Nothink.org:Investigate,Passive:Reputation Systems::Check if a host/domain, netblock or IP is malicious according to Nothink.org."""
-
-
-
-
# Default options
opts = {
'nothinkssh': True,
@@ -69,11 +65,11 @@ class sfp_nothink(SpiderFootPlugin):
# Be sure to completely clear any class variables in setup()
# or you run the risk of data persisting between scan runs.
- results = list()
+ results = dict()
def setup(self, sfc, userOpts=dict()):
self.sf = sfc
- self.results = list()
+ self.results = dict()
# Clear / reset any other class member variables here
# or you risk them persisting between threads.
@@ -198,13 +194,18 @@ class sfp_nothink(SpiderFootPlugin):
return url
else:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ try:
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
@@ -232,7 +233,7 @@ class sfp_nothink(SpiderFootPlugin):
self.sf.debug("Skipping " + eventData + ", already checked.")
return None
else:
- self.results.append(eventData)
+ self.results[eventData] = True
if eventName == 'CO_HOSTED_SITE' and not self.opts.get('checkcohosts', False):
return None
diff --git a/modules/sfp_openphish.py b/modules/sfp_openphish.py
index e9cc3dbb..e79d1014 100644
--- a/modules/sfp_openphish.py
+++ b/modules/sfp_openphish.py
@@ -47,11 +47,11 @@ class sfp_openphish(SpiderFootPlugin):
# Be sure to completely clear any class variables in setup()
# or you run the risk of data persisting between scan runs.
- results = list()
+ results = dict()
def setup(self, sfc, userOpts=dict()):
self.sf = sfc
- self.results = list()
+ self.results = dict()
# Clear / reset any other class member variables here
# or you risk them persisting between threads.
@@ -173,13 +173,18 @@ class sfp_openphish(SpiderFootPlugin):
return url
else:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ try:
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
@@ -207,7 +212,7 @@ class sfp_openphish(SpiderFootPlugin):
self.sf.debug("Skipping " + eventData + ", already checked.")
return None
else:
- self.results.append(eventData)
+ self.results[eventData] = True
if eventName == 'CO_HOSTED_SITE' and not self.opts.get('checkcohosts', False):
return None
diff --git a/modules/sfp_phishtank.py b/modules/sfp_phishtank.py
index 1d5efd9b..a76f9241 100644
--- a/modules/sfp_phishtank.py
+++ b/modules/sfp_phishtank.py
@@ -47,11 +47,11 @@ class sfp_phishtank(SpiderFootPlugin):
# Be sure to completely clear any class variables in setup()
# or you run the risk of data persisting between scan runs.
- results = list()
+ results = dict()
def setup(self, sfc, userOpts=dict()):
self.sf = sfc
- self.results = list()
+ self.results = dict()
# Clear / reset any other class member variables here
# or you risk them persisting between threads.
@@ -173,13 +173,18 @@ class sfp_phishtank(SpiderFootPlugin):
return url
else:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ try:
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
@@ -207,7 +212,7 @@ class sfp_phishtank(SpiderFootPlugin):
self.sf.debug("Skipping " + eventData + ", already checked.")
return None
else:
- self.results.append(eventData)
+ self.results[eventData] = True
if eventName == 'CO_HOSTED_SITE' and not self.opts.get('checkcohosts', False):
return None
diff --git a/modules/sfp_sublist3r.py b/modules/sfp_sublist3r.py
index 54e4c4ee..a18fe895 100644
--- a/modules/sfp_sublist3r.py
+++ b/modules/sfp_sublist3r.py
@@ -51,6 +51,7 @@ class sfp_sublist3r(SpiderFootPlugin):
# Verify a host resolves
def resolveHost(self, host):
try:
+ host = host.encode("idna")
addrs = socket.gethostbyname_ex(host)
except BaseException as e:
self.sf.debug("Unable to resolve " + host + ": " + str(e))
diff --git a/modules/sfp_threatexpert.py b/modules/sfp_threatexpert.py
index e58e5591..0515841a 100644
--- a/modules/sfp_threatexpert.py
+++ b/modules/sfp_threatexpert.py
@@ -51,11 +51,11 @@ class sfp_threatexpert(SpiderFootPlugin):
# Be sure to completely clear any class variables in setup()
# or you run the risk of data persisting between scan runs.
- results = list()
+ results = dict()
def setup(self, sfc, userOpts=dict()):
self.sf = sfc
- self.results = list()
+ self.results = dict()
# Clear / reset any other class member variables here
# or you risk them persisting between threads.
@@ -179,13 +179,18 @@ class sfp_threatexpert(SpiderFootPlugin):
return url
else:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ try:
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
@@ -213,7 +218,7 @@ class sfp_threatexpert(SpiderFootPlugin):
self.sf.debug("Skipping " + eventData + ", already checked.")
return None
else:
- self.results.append(eventData)
+ self.results[eventData] = True
if eventName == 'CO_HOSTED_SITE' and not self.opts.get('checkcohosts', False):
return None
diff --git a/modules/sfp_torexits.py b/modules/sfp_torexits.py
index c33ad6a9..e72c6327 100644
--- a/modules/sfp_torexits.py
+++ b/modules/sfp_torexits.py
@@ -49,11 +49,11 @@ class sfp_torexits(SpiderFootPlugin):
# Be sure to completely clear any class variables in setup()
# or you run the risk of data persisting between scan runs.
- results = list()
+ results = dict()
def setup(self, sfc, userOpts=dict()):
self.sf = sfc
- self.results = list()
+ self.results = dict()
self.__dataSource__ = "torproject.org"
# Clear / reset any other class member variables here
@@ -177,13 +177,18 @@ class sfp_torexits(SpiderFootPlugin):
return url
else:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ try:
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
@@ -211,7 +216,7 @@ class sfp_torexits(SpiderFootPlugin):
self.sf.debug("Skipping " + eventData + ", already checked.")
return None
else:
- self.results.append(eventData)
+ self.results[eventData] = True
if eventName == 'CO_HOSTED_SITE' and not self.opts.get('checkcohosts', False):
return None
diff --git a/modules/sfp_torserver.py b/modules/sfp_torserver.py
index bee5aaa9..87b38d2e 100644
--- a/modules/sfp_torserver.py
+++ b/modules/sfp_torserver.py
@@ -48,11 +48,11 @@ class sfp_torserver(SpiderFootPlugin):
# Be sure to completely clear any class variables in setup()
# or you run the risk of data persisting between scan runs.
- results = list()
+ results = dict()
def setup(self, sfc, userOpts=dict()):
self.sf = sfc
- self.results = list()
+ self.results = dict()
self.__dataSource__ = "blutmagie.de"
# Clear / reset any other class member variables here
@@ -176,13 +176,18 @@ class sfp_torserver(SpiderFootPlugin):
return url
else:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ try:
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
@@ -210,7 +215,7 @@ class sfp_torserver(SpiderFootPlugin):
self.sf.debug("Skipping " + eventData + ", already checked.")
return None
else:
- self.results.append(eventData)
+ self.results[eventData] = True
if eventName == 'CO_HOSTED_SITE' and not self.opts.get('checkcohosts', False):
return None
diff --git a/modules/sfp_totalhash.py b/modules/sfp_totalhash.py
index 0c9fb338..872ec99a 100644
--- a/modules/sfp_totalhash.py
+++ b/modules/sfp_totalhash.py
@@ -46,11 +46,11 @@ class sfp_totalhash(SpiderFootPlugin):
# Be sure to completely clear any class variables in setup()
# or you run the risk of data persisting between scan runs.
- results = list()
+ results = dict()
def setup(self, sfc, userOpts=dict()):
self.sf = sfc
- self.results = list()
+ self.results = dict()
# Clear / reset any other class member variables here
# or you risk them persisting between threads.
@@ -175,13 +175,18 @@ class sfp_totalhash(SpiderFootPlugin):
return url
else:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ try:
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
@@ -209,7 +214,7 @@ class sfp_totalhash(SpiderFootPlugin):
self.sf.debug("Skipping " + eventData + ", already checked.")
return None
else:
- self.results.append(eventData)
+ self.results[eventData] = True
if eventName == 'CO_HOSTED_SITE' and not self.opts.get('checkcohosts', False):
return None
diff --git a/modules/sfp_virustotal.py b/modules/sfp_virustotal.py
index dd74547f..36099521 100644
--- a/modules/sfp_virustotal.py
+++ b/modules/sfp_virustotal.py
@@ -80,6 +80,7 @@ class sfp_virustotal(SpiderFootPlugin):
# Verify a host resolves
def resolveHost(self, host):
try:
+ host = host.encode("idna")
addrs = socket.gethostbyname_ex(host)
except BaseException as e:
self.sf.debug("Unable to resolve " + host + ": " + str(e))
diff --git a/modules/sfp_voipbl.py b/modules/sfp_voipbl.py
index 35ee55fe..ae3c2a67 100644
--- a/modules/sfp_voipbl.py
+++ b/modules/sfp_voipbl.py
@@ -28,12 +28,6 @@ malchecks = {
class sfp_voipbl(SpiderFootPlugin):
"""VoIPBL OpenPBX IPs:Investigate,Passive:Reputation Systems::Check if an IP or netblock is an open PBX according to VoIPBL OpenPBX IPs."""
-
-
-
-
-
-
# Default options
opts = {
'_voipbl': True,
@@ -54,11 +48,11 @@ class sfp_voipbl(SpiderFootPlugin):
# Be sure to completely clear any class variables in setup()
# or you run the risk of data persisting between scan runs.
- results = list()
+ results = dict()
def setup(self, sfc, userOpts=dict()):
self.sf = sfc
- self.results = list()
+ self.results = dict()
# Clear / reset any other class member variables here
# or you risk them persisting between threads.
@@ -181,13 +175,18 @@ class sfp_voipbl(SpiderFootPlugin):
return url
else:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ try:
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
@@ -215,7 +214,7 @@ class sfp_voipbl(SpiderFootPlugin):
self.sf.debug("Skipping " + eventData + ", already checked.")
return None
else:
- self.results.append(eventData)
+ self.results[eventData] = True
if eventName == 'CO_HOSTED_SITE' and not self.opts.get('checkcohosts', False):
return None
diff --git a/modules/sfp_vxvault.py b/modules/sfp_vxvault.py
index a119d904..5b3eecb7 100644
--- a/modules/sfp_vxvault.py
+++ b/modules/sfp_vxvault.py
@@ -47,11 +47,11 @@ class sfp_vxvault(SpiderFootPlugin):
# Be sure to completely clear any class variables in setup()
# or you run the risk of data persisting between scan runs.
- results = list()
+ results = dict()
def setup(self, sfc, userOpts=dict()):
self.sf = sfc
- self.results = list()
+ self.results = dict()
# Clear / reset any other class member variables here
# or you risk them persisting between threads.
@@ -176,13 +176,18 @@ class sfp_vxvault(SpiderFootPlugin):
return url
else:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ try:
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
@@ -210,7 +215,7 @@ class sfp_vxvault(SpiderFootPlugin):
self.sf.debug("Skipping " + eventData + ", already checked.")
return None
else:
- self.results.append(eventData)
+ self.results[eventData] = True
if eventName == 'CO_HOSTED_SITE' and not self.opts.get('checkcohosts', False):
return None
diff --git a/modules/sfp_watchguard.py b/modules/sfp_watchguard.py
index 2b4d29dd..68632969 100644
--- a/modules/sfp_watchguard.py
+++ b/modules/sfp_watchguard.py
@@ -29,12 +29,6 @@ malchecks = {
class sfp_watchguard(SpiderFootPlugin):
"""Watchguard:Investigate,Passive:Reputation Systems::Check if an IP is malicious according to Watchguard's reputationauthority.org."""
-
-
-
-
-
-
# Default options
opts = {
'_watchguard': True,
@@ -49,11 +43,11 @@ class sfp_watchguard(SpiderFootPlugin):
# Be sure to completely clear any class variables in setup()
# or you run the risk of data persisting between scan runs.
- results = list()
+ results = dict()
def setup(self, sfc, userOpts=dict()):
self.sf = sfc
- self.results = list()
+ self.results = dict()
# Clear / reset any other class member variables here
# or you risk them persisting between threads.
@@ -174,13 +168,18 @@ class sfp_watchguard(SpiderFootPlugin):
return url
else:
# Check for the domain and the hostname
- rxDom = unicode(malchecks[check]['regex']).format(targetDom.decode('string_escape'))
- rxTgt = unicode(malchecks[check]['regex']).format(target.decode('string_escape'))
- for line in data['content'].split('\n'):
- if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
- re.match(rxTgt, line, re.IGNORECASE):
- self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
- return url
+ try:
+ rxDom = unicode(malchecks[check]['regex']).format(targetDom)
+ rxTgt = unicode(malchecks[check]['regex']).format(target)
+ for line in data['content'].split('\n'):
+ if (targetType == "domain" and re.match(rxDom, line, re.IGNORECASE)) or \
+ re.match(rxTgt, line, re.IGNORECASE):
+ self.sf.debug(target + "/" + targetDom + " found in " + check + " list.")
+ return url
+ except BaseException as e:
+ self.sf.debug("Error encountered parsing 2: " + str(e))
+ continue
+
return None
def lookupItem(self, resourceId, itemType, target):
@@ -208,7 +207,7 @@ class sfp_watchguard(SpiderFootPlugin):
self.sf.debug("Skipping " + eventData + ", already checked.")
return None
else:
- self.results.append(eventData)
+ self.results[eventData] = True
if eventName == 'CO_HOSTED_SITE' and not self.opts.get('checkcohosts', False):
return None
diff --git a/modules/sfp_wigle.py b/modules/sfp_wigle.py
index b3aed14c..e0e42164 100644
--- a/modules/sfp_wigle.py
+++ b/modules/sfp_wigle.py
@@ -61,7 +61,7 @@ class sfp_wigle(SpiderFootPlugin):
def getcoords(self, qry):
url = "https://api.wigle.net/api/v2/network/geocode?" + \
- urllib.urlencode({'addresscode': unicode.encode(qry, 'utf-8', errors='replace')})
+ urllib.urlencode({'addresscode': qry.encode('utf-8', errors='replace')})
hdrs = {
"Accept": "application/json",
"Authorization": "Basic " + self.opts['api_key_encoded']
diff --git a/sflib.py b/sflib.py
index e8ea505b..2b7e7440 100644
--- a/sflib.py
+++ b/sflib.py
@@ -281,7 +281,7 @@ class SpiderFoot:
# str(time.time() * 1000) +
# str(random.randint(100000, 999999))
# ).hexdigest()
- rstr = scanName + str(time.time()) + str(random.randint(100000, 999999))
+ rstr = str(time.time()) + str(random.randint(100000, 999999))
hashStr = "%08X" % int(binascii.crc32(rstr) & 0xffffffff)
return hashStr
@@ -294,6 +294,8 @@ class SpiderFoot:
print '[Error] ' + error
else:
self._dblog("ERROR", error)
+ if self.opts.get('__logstdout'):
+ print "[Error] " + error
if exception:
raise BaseException("Internal Error Encountered: " + error)
@@ -310,6 +312,8 @@ class SpiderFoot:
print "[Status] " + message
else:
self._dblog("STATUS", message)
+ if self.opts.get('__logstdout'):
+ print "[*] " + message
def info(self, message):
frm = inspect.stack()[1]
@@ -332,6 +336,8 @@ class SpiderFoot:
print '[' + modName + '] ' + message
else:
self._dblog("INFO", message, modName)
+ if self.opts.get('__logstdout'):
+ print "[*] " + message
return
def debug(self, message):
@@ -357,6 +363,8 @@ class SpiderFoot:
print '[' + modName + '] ' + message
else:
self._dblog("DEBUG", message, modName)
+ if self.opts.get('__logstdout'):
+ print "[d] " + message
return
def myPath(self):
@@ -544,14 +552,14 @@ class SpiderFoot:
regexToType = {
"^\d+\.\d+\.\d+\.\d+$": "IP_ADDRESS",
"^\d+\.\d+\.\d+\.\d+/\d+$": "NETBLOCK_OWNER",
- "^.[a-zA-Z\-0-9\.]+$": "INTERNET_NAME",
"^.*@.*$": "EMAILADDR",
- "^\".*\"$": "HUMAN_NAME"
+ "^\".*\"$": "HUMAN_NAME",
+ ".*\..*": "INTERNET_NAME"
}
# Parse the target and set the targetType
- for rx in regexToType.keys():
- if re.match(rx, target, re.IGNORECASE):
+ for rx in regexToType:
+ if re.match(rx, target, re.IGNORECASE|re.UNICODE):
targetType = regexToType[rx]
break
return targetType
@@ -567,6 +575,8 @@ class SpiderFoot:
for evtype in self.opts['__modules__'][mod]['provides']:
if evtype in events and mod not in modlist:
modlist.append(mod)
+ if "*" in events and mod not in modlist:
+ modlist.append(mod)
return modlist
@@ -577,6 +587,9 @@ class SpiderFoot:
for mod in self.opts['__modules__'].keys():
if self.opts['__modules__'][mod]['consumes'] is None:
continue
+
+ if "*" in self.opts['__modules__'][mod]['consumes'] and mod not in modlist:
+ modlist.append(mod)
for evtype in self.opts['__modules__'][mod]['consumes']:
if evtype in events and mod not in modlist:
@@ -731,9 +744,9 @@ class SpiderFoot:
for addr in res:
if type(addr) == list:
for host in addr:
- ret.append(host)
+ ret.append(unicode(host, 'utf-8', errors='replace'))
else:
- ret.append(addr)
+ ret.append(unicode(addr, 'utf-8', errors='replace'))
return ret
# Return dictionary words and/or names
@@ -902,6 +915,8 @@ class SpiderFoot:
# Remember the regex will return two vars (two groups captured)
junk = linkTuple[0]
link = linkTuple[1]
+ if type(link) != unicode:
+ link = unicode(link, 'utf-8', errors='replace')
linkl = link.lower()
absLink = None
@@ -955,6 +970,9 @@ class SpiderFoot:
return returnLinks
+ def urlEncodeUnicode(self, url):
+ return re.sub('[\x80-\xFF]', lambda c: '%%%02x' % ord(c.group(0)), url)
+
# Fetch a URL, return the response object
def fetchUrl(self, url, fatal=False, cookies=None, timeout=30,
useragent="SpiderFoot", headers=None, noLog=False,
@@ -975,6 +993,9 @@ class SpiderFoot:
if type(url) != unicode:
url = unicode(url, 'utf-8', errors='replace')
+ # Convert any unicode chars in the URL
+ url = self.urlEncodeUnicode(url)
+
try:
header = dict()
if type(useragent) is list:
@@ -1029,6 +1050,7 @@ class SpiderFoot:
if not noLog:
self.info("Fetching: " + url + " [timeout: " + str(timeout) + "]")
+
result['headers'] = dict()
opener = urllib2.build_opener(SmartRedirectHandler())
fullPage = opener.open(req, timeout=timeout)
@@ -1084,10 +1106,8 @@ class SpiderFoot:
# An exception will be raised if the resolution fails
try:
addrs = socket.gethostbyname_ex(randhost + "." + target)
- self.debug(target + " has wildcard DNS.")
return True
except BaseException as e:
- self.debug(target + " does not have wildcard DNS.")
return False
# Scrape Google for content, starting at startUrl and iterating through
@@ -1472,7 +1492,10 @@ class SpiderFootPlugin(object):
# within the same execution context of this thread, not on their own.
def notifyListeners(self, sfEvent):
eventName = sfEvent.eventType
- eventData = sfEvent.data
+ if type(sfEvent.data) == str:
+ eventData = unicode(sfEvent.data, 'utf-8', errors='replace')
+ else:
+ eventData = sfEvent.data
storeOnly = False # Under some conditions, only store and don't notify
if eventData is None or (type(eventData) is unicode and len(eventData) == 0):
@@ -1526,7 +1549,10 @@ class SpiderFootPlugin(object):
return None
#print "EVENT: " + str(sfEvent)
- listener.handleEvent(sfEvent)
+ try:
+ listener.handleEvent(sfEvent)
+ except BaseException as e:
+ self.sf.error("Module encountered an error: " + str(e))
# For modules to use to check for when they should give back control
def checkForStop(self):
@@ -1717,6 +1743,14 @@ class SpiderFootEvent(object):
self.__id = self.eventType + str(self.generated) + self.module + \
str(random.randint(0, 99999999))
+ def asDict(self):
+ return {
+ 'generated': int(self.generated),
+ 'type': self.eventType,
+ 'data': self.data,
+ 'module': self.module
+ }
+
# Unique hash of this event
def getHash(self):
if self.eventType == "ROOT":
diff --git a/sfscan.py b/sfscan.py
index 6bd3348a..8ae55014 100644
--- a/sfscan.py
+++ b/sfscan.py
@@ -34,7 +34,7 @@ class SpiderFootScanner(threading.Thread):
globalOpts, moduleOpts):
# Initialize the thread
- threading.Thread.__init__(self, name="SF_" + scanName + \
+ threading.Thread.__init__(self, name="SF_" + scanId + \
str(random.randint(100000, 999999)))
# Temporary data to be used in startScan
diff --git a/sfwebui.py b/sfwebui.py
index 20dcd0ba..d29aeb02 100644
--- a/sfwebui.py
+++ b/sfwebui.py
@@ -293,7 +293,7 @@ class SpiderFootWebUi:
time.sleep(1)
templ = Template(filename='dyn/scaninfo.tmpl', lookup=self.lookup)
- return templ.render(id=newId, name=scanname, docroot=self.docroot,
+ return templ.render(id=newId, name=unicode(scanname, 'utf-8', errors='replace'), docroot=self.docroot,
status=globalScanStatus.getStatus(newId), pageid="SCANLIST")
rerunscan.exposed = True
@@ -326,8 +326,9 @@ class SpiderFootWebUi:
# Start running a new scan
newId = sf.genScanInstanceGUID(scanname)
- t = SpiderFootScanner(scanname, scantarget.lower(), targetType, newId,
- modlist, cfg, modopts)
+ t = SpiderFootScanner(unicode(scanname, 'utf-8', errors='replace'),
+ unicode(scantarget, 'utf-8', errors='replace').lower(),
+ targetType, newId, modlist, cfg, modopts)
t.start()
# Wait until the scan has initialized
@@ -377,7 +378,8 @@ class SpiderFootWebUi:
templ = Template(filename='dyn/newscan.tmpl', lookup=self.lookup)
return templ.render(pageid='NEWSCAN', types=types, docroot=self.docroot,
modules=self.config['__modules__'], selectedmods=modlist,
- scanname=scanname, scantarget=scantarget)
+ scanname=unicode(scanname, 'utf-8', errors='replace'),
+ scantarget=unicode(scantarget, 'utf-8', errors='replace'))
clonescan.exposed = True
@@ -396,8 +398,8 @@ class SpiderFootWebUi:
if res is None:
return self.error("Scan ID not found.")
- templ = Template(filename='dyn/scaninfo.tmpl', lookup=self.lookup)
- return templ.render(id=id, name=res[0], status=res[5], docroot=self.docroot,
+ templ = Template(filename='dyn/scaninfo.tmpl', lookup=self.lookup, disable_unicode=True, input_encoding='utf-8')
+ return templ.render(id=id, name=cgi.escape(res[0]), status=res[5], docroot=self.docroot,
pageid="SCANLIST")
scaninfo.exposed = True
@@ -857,8 +859,7 @@ class SpiderFootWebUi:
retdata = []
for row in data:
generated = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(row[0] / 1000))
- retdata.append([generated, row[1], row[2],
- cgi.escape(unicode(row[3], errors='replace')), row[4]])
+ retdata.append([generated, row[1], row[2], cgi.escape(row[3]), row[4]])
return json.dumps(retdata)
scanlog.exposed = True