Skip to content

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

Bug fixes, data quality improvements.

smicallef878bebd94272
diff --git a/modules/sfp_countryname.py b/modules/sfp_countryname.py
index 7054d1b1..4cf2dd16 100644
--- a/modules/sfp_countryname.py
+++ b/modules/sfp_countryname.py
@@ -232,14 +232,32 @@ class sfp_countryname(SpiderFootPlugin):
for countryName in abbvCountryCodes.values():
# Look for country name in source data
- matchCountries = re.findall("[\s,'\"]" + countryName + "[\s,'\"]", srcData, re.IGNORECASE)
+ # Spaces are not included since New Jersey and others
+ # will get interpreted as Jersey, etc.
+ matchCountries = re.findall("[,'\"\:\=\[\(\[\n\t\r\.] ?" + countryName + "[,'\"\:\=\[\(\[\n\t\r\.]", srcData, re.IGNORECASE)
if len(matchCountries) > 0:
# Get country name from first index of list
# Extract only the text part of the country code
matchCountry = matchCountries[0].strip(",").strip("'").strip("\"").strip()
countries.append(matchCountry)
-
+
+ if len(matchCountries) > 0:
+ # Get country name from first index of list
+ # Extract only the text part of the country code
+ matchCountry = matchCountries[0].strip(",").strip("'").strip("\"").strip()
+ countries.append(matchCountry)
+
+ # Look for "Country: ", usually found in Whois records
+ matchCountries = re.findall("country: (.*)", srcData, re.IGNORECASE)
+ if matchCountries:
+ for m in matchCountries:
+ m = m.strip()
+ if m in abbvCountryCodes:
+ countries.append(abbvCountryCodes[m])
+ if m in abbvCountryCodes.values():
+ countries.append(m)
+
# If any countries are found
if len(countries) > 0:
return countries
@@ -293,16 +311,16 @@ class sfp_countryname(SpiderFootPlugin):
countryNames.extend(tempDataList)
# Check if countryNames is empty
- if None in countryNames:
- countryNames.remove(None)
- if len(countryNames) == 0 :
+ if len(countryNames) == 0:
return None
# Convert list to set to remove duplicates
countryNames = set(countryNames)
for countryName in countryNames:
- self.sf.debug("Found country name : " + countryName)
+ if countryName == '' or countryName == None:
+ continue
+ self.sf.debug("Found country name: " + countryName)
evt = SpiderFootEvent(evttype, countryName, self.__name__, event)
if event.moduleDataSource:
diff --git a/modules/sfp_shodan.py b/modules/sfp_shodan.py
index 3d104807..56ee1c22 100644
--- a/modules/sfp_shodan.py
+++ b/modules/sfp_shodan.py
@@ -218,6 +218,11 @@ class sfp_shodan(SpiderFootPlugin):
if 'data' in rec:
self.sf.info("Found SHODAN data for " + eventData)
+ ports = list()
+ banners = list()
+ asns = list()
+ products = list()
+ vulnlist = list()
for r in rec['data']:
port = str(r.get('port'))
banner = r.get('banner')
@@ -228,32 +233,51 @@ class sfp_shodan(SpiderFootPlugin):
if port is not None:
# Notify other modules of what you've found
cp = addr + ":" + port
+ if cp in ports:
+ continue
+ else:
+ ports.append(cp)
evt = SpiderFootEvent("TCP_PORT_OPEN", cp,
self.__name__, pevent)
self.notifyListeners(evt)
if banner is not None:
+ if banner in banners:
+ continue
+ else:
+ banners.append(banner)
# Notify other modules of what you've found
evt = SpiderFootEvent("TCP_PORT_OPEN_BANNER", banner,
self.__name__, pevent)
self.notifyListeners(evt)
if product is not None:
+ if product in products:
+ continue
+ else:
+ products.append(product)
evt = SpiderFootEvent("SOFTWARE_USED", product,
self.__name__, pevent)
self.notifyListeners(evt)
if asn is not None:
+ if asn in asns:
+ continue
+ else:
+ asns.append(asn)
evt = SpiderFootEvent("BGP_AS_MEMBER", asn.replace("AS", ""),
self.__name__, pevent)
self.notifyListeners(evt)
if vulns is not None:
- for vuln in list(vulns.keys()):
+ for vuln in vulns.keys():
+ if vuln in vulnlist:
+ continue
+ else:
+ vulnlist.append(vuln)
evt = SpiderFootEvent('VULNERABILITY', vuln,
self.__name__, pevent)
self.notifyListeners(evt)
-
return None
# End of sfp_shodan class
diff --git a/sflib.py b/sflib.py
index 75a33fe5..2eba3720 100644
--- a/sflib.py
+++ b/sflib.py
@@ -1471,6 +1471,7 @@ class SpiderFoot:
for link in urlsRel:
if type(link) != str:
link = str(link)
+ link = link.strip()
linkl = link.lower()
absLink = None
@@ -1569,6 +1570,8 @@ class SpiderFoot:
#self.debug("fetchUrl: No url")
return None
+ url = url.strip()
+
proxies = dict()
if self.opts['_socks1type']:
neverProxyNames = [ self.opts['_socks2addr'] ]
@@ -1628,7 +1631,11 @@ class SpiderFoot:
hdr = self.getSession().head(url, headers=header, proxies=proxies,
verify=verify, timeout=timeout)
size = int(hdr.headers.get('content-length', 0))
- result['realurl'] = hdr.headers.get('location', url)
+ newloc = hdr.headers.get('location', url).strip()
+ # Relative re-direct
+ if newloc.startswith("/") or newloc.startswith("../"):
+ newloc = self.urlBaseUrl(url) + newloc
+ result['realurl'] = newloc
result['code'] = str(hdr.status_code)
if headOnly: