SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.
Python attacksurfacecticybersecurityfootprintinghackinginformation-gatheringinformation-securityinfosecintelligence-gatheringosintosint-frameworkosint-reconnaissanceosint-toolpentestingpythonreconsecurity-toolsthreat-intelligencethreatintel
Use GNQL for Greynoise.
smicallefb6c6eb4d3f6f
diff --git a/modules/sfp_greynoise.py b/modules/sfp_greynoise.pyindex 65a9cfd5..d1b9e019 100644--- a/modules/sfp_greynoise.py+++ b/modules/sfp_greynoise.py@@ -35,9 +35,9 @@ class sfp_greynoise(SpiderFootPlugin):optdescs = {"api_key": "Greynoise API Key.","age_limit_days": "Ignore any records older than this many days. 0 = unlimited.",- 'netblocklookup': "Look up all IPs on netblocks deemed to be owned by your target for possible blacklisted hosts on the same target subdomain/domain?",+ 'netblocklookup': "Look up netblocks deemed to be owned by your target for possible blacklisted 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.)",- 'subnetlookup': "Look up all IPs on subnets which your target is a part of for blacklisting?",+ 'subnetlookup': "Look up subnets which your target is a part of for blacklisting?",'maxsubnet': "If looking up subnets, the maximum subnet size to look up all the IPs within (CIDR value, 24 = /24, 16 = /16, etc.)"#'asnlookup': "Look up ASNs that your target is a member of?"}@@ -74,7 +74,7 @@ class sfp_greynoise(SpiderFootPlugin):ret = Noneheader = { "key": self.opts['api_key'] }- url = "https://" + "enterprise.api.greynoise.io/v2/noise/context/" + qry+ url = "https://" + "enterprise.api.greynoise.io/v2/experimental/gnql?query=" + qryres = self.sf.fetchUrl(url, timeout=self.opts['_fetchtimeout'],useragent="SpiderFoot", headers=header)@@ -91,7 +91,6 @@ class sfp_greynoise(SpiderFootPlugin):return info-# Handle events sent to this moduledef handleEvent(self, event):eventName = event.eventType@@ -135,25 +134,17 @@ class sfp_greynoise(SpiderFootPlugin):str(self.opts['maxsubnet']))return None- qrylist = list()- if eventName.startswith("NETBLOCK_"):- for ipaddr in IPNetwork(eventData):- qrylist.append(str(ipaddr))- self.results[str(ipaddr)] = True- else:- qrylist.append(eventData)+ if eventName == 'IP_ADDRESS' or eventName.startswith('NETBLOCK_'):+ evtType = 'MALICIOUS_IPADDR'+ if eventName == "AFFILIATE_IPADDR":+ evtType = 'MALICIOUS_AFFILIATE_IPADDR'- for addr in qrylist:- if self.checkForStop():- return None-- if eventName == 'IP_ADDRESS' or eventName.startswith('NETBLOCK_'):- evtType = 'MALICIOUS_IPADDR'- if eventName == "AFFILIATE_IPADDR":- evtType = 'MALICIOUS_AFFILIATE_IPADDR'+ ret = self.queryIP(eventData)+ if "data" not in ret:+ return None- rec = self.queryIP(addr)- if rec is not None:+ if len(ret["data"]) > 0:+ for rec in ret["data"]:if rec.get("seen", None):self.sf.debug("Found threat info in Greynoise")lastseen = rec.get("last_seen", "1970-01-01")@@ -162,7 +153,7 @@ class sfp_greynoise(SpiderFootPlugin):age_limit_ts = int(time.time()) - (86400 * self.opts['age_limit_days'])if self.opts['age_limit_days'] > 0 and lastseen_ts < age_limit_ts:self.sf.debug("Record found but too old, skipping.")- continue+ return None# Only report meta data about the target, not affiliatesif rec.get("metadata") and eventName == "IP_ADDRESS":@@ -188,12 +179,12 @@ class sfp_greynoise(SpiderFootPlugin):self.notifyListeners(e)if rec.get("classification"):- descr = "Greynoise [" + addr + "]\n - Classification: " + rec.get("classification")+ descr = "Greynoise [" + eventData + "]\n - Classification: " + rec.get("classification")if rec.get("tags"):descr += ", Tags: " + ", ".join(rec.get("tags"))else:descr += "\n - " + "Raw data: " + str(rec.get("raw_data"))- descr += "\n<SFURL>https://viz.greynoise.io/ip/" + addr + "</SFURL>"+ descr += "\n<SFURL>https://viz.greynoise.io/ip/" + eventData + "</SFURL>"e = SpiderFootEvent(evtType, descr, self.__name__, event)self.notifyListeners(e)