Skip to content

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

sfp_cleanbrowsing: Use Family, Adult and Security DNS servers (#1506)

bcoles70cccbdc0007
diff --git a/modules/sfp_cleanbrowsing.py b/modules/sfp_cleanbrowsing.py
index 2d2d3def..3817f2d2 100644
--- a/modules/sfp_cleanbrowsing.py
+++ b/modules/sfp_cleanbrowsing.py
@@ -72,19 +72,47 @@ class sfp_cleanbrowsing(SpiderFootPlugin):
def producedEvents(self):
return [
+ "BLACKLISTED_INTERNET_NAME",
+ "BLACKLISTED_AFFILIATE_INTERNET_NAME",
+ "BLACKLISTED_COHOST",
"MALICIOUS_INTERNET_NAME",
"MALICIOUS_AFFILIATE_INTERNET_NAME",
- "MALICIOUS_COHOST"
+ "MALICIOUS_COHOST",
]
- def queryAddr(self, qaddr):
+ def queryFamilyDNS(self, qaddr):
res = dns.resolver.Resolver()
- # Family Filter
res.nameservers = ["185.228.168.168", "185.228.168.169"]
- # Adult Filter
- # res.nameservers = ["185.228.168.10", "185.228.169.11"]
- # Security Filter
- # res.nameservers = ["185.228.168.9", "185.228.169.9"]
+
+ try:
+ addrs = res.resolve(qaddr)
+ self.debug(f"Addresses returned: {addrs}")
+ except Exception:
+ self.debug(f"Unable to resolve {qaddr}")
+ return False
+
+ if addrs:
+ return True
+ return False
+
+ def queryAdultDNS(self, qaddr):
+ res = dns.resolver.Resolver()
+ res.nameservers = ["185.228.168.10", "185.228.169.11"]
+
+ try:
+ addrs = res.resolve(qaddr)
+ self.debug(f"Addresses returned: {addrs}")
+ except Exception:
+ self.debug(f"Unable to resolve {qaddr}")
+ return False
+
+ if addrs:
+ return True
+ return False
+
+ def querySecurityDNS(self, qaddr):
+ res = dns.resolver.Resolver()
+ res.nameservers = ["185.228.168.9", "185.228.169.9"]
try:
addrs = res.resolve(qaddr)
@@ -108,30 +136,64 @@ class sfp_cleanbrowsing(SpiderFootPlugin):
self.results[eventData] = True
+ if eventName == "INTERNET_NAME":
+ malicious_type = "MALICIOUS_INTERNET_NAME"
+ blacklist_type = "BLACKLISTED_INTERNET_NAME"
+ elif eventName == "AFFILIATE_INTERNET_NAME":
+ malicious_type = "MALICIOUS_AFFILIATE_INTERNET_NAME"
+ blacklist_type = "BLACKLISTED_AFFILIATE_INTERNET_NAME"
+ elif eventName == "CO_HOSTED_SITE":
+ malicious_type = "MALICIOUS_COHOST"
+ blacklist_type = "BACKLISTED_COHOST"
+ else:
+ self.debug(f"Unexpected event type {eventName}, skipping")
+
# Check that it resolves first, as it becomes a valid
# malicious host only if NOT resolved by CleanBrowsing DNS.
if not self.sf.resolveHost(eventData) and not self.sf.resolveHost6(eventData):
return
- found = self.queryAddr(eventData)
+ family = self.queryFamilyDNS(eventData)
+ adult = self.queryAdultDNS(eventData)
+ security = self.querySecurityDNS(eventData)
# Host was found, not blocked
- if found:
+ if family and adult and security:
return
self.debug(f"{eventData} was blocked by CleanBrowsing DNS")
- typ = "MALICIOUS_" + eventName
-
- if eventName == "CO_HOSTED_SITE":
- typ = "MALICIOUS_COHOST"
-
- evt = SpiderFootEvent(
- typ,
- f"Blocked by CleanBrowsing DNS [{eventData}]",
- self.__name__,
- event
- )
- self.notifyListeners(evt)
+ if not security:
+ evt = SpiderFootEvent(
+ blacklist_type,
+ f"CleanBrowsing DNS - Security [{eventData}]",
+ self.__name__,
+ event
+ )
+ self.notifyListeners(evt)
+
+ evt = SpiderFootEvent(
+ malicious_type,
+ f"CleanBrowsing DNS - Security [{eventData}]",
+ self.__name__,
+ event
+ )
+ self.notifyListeners(evt)
+ elif not adult:
+ evt = SpiderFootEvent(
+ blacklist_type,
+ f"CleanBrowsing DNS - Adult [{eventData}]",
+ self.__name__,
+ event
+ )
+ self.notifyListeners(evt)
+ elif not family:
+ evt = SpiderFootEvent(
+ blacklist_type,
+ f"CleanBrowsing DNS - Family [{eventData}]",
+ self.__name__,
+ event
+ )
+ self.notifyListeners(evt)
# End of sfp_cleanbrowsing class
diff --git a/test/unit/modules/test_sfp_cleanbrowsing.py b/test/unit/modules/test_sfp_cleanbrowsing.py
index cc353c3b..a109cb4a 100644
--- a/test/unit/modules/test_sfp_cleanbrowsing.py
+++ b/test/unit/modules/test_sfp_cleanbrowsing.py
@@ -46,11 +46,11 @@ class TestModulecleanbrowsing(unittest.TestCase):
module.setTarget(target)
def new_notifyListeners(self, event):
- expected = 'MALICIOUS_INTERNET_NAME'
+ expected = 'BLACKLISTED_INTERNET_NAME'
if str(event.eventType) != expected:
raise Exception(f"{event.eventType} != {expected}")
- expected = 'Blocked by CleanBrowsing DNS [pornhub.com]'
+ expected = 'CleanBrowsing DNS - Adult [pornhub.com]'
if str(event.data) != expected:
raise Exception(f"{event.data} != {expected}")