Beispiel #1
0
 def _parse(self):
     for obj in self._raw_threat_intel["data"]:
         # Add as source ip
         try:
             intel = Intel(original=json.dumps(obj),
                           event_type="indicator",
                           event_reference=self._feed_url,
                           event_provider="AbuseIPdb",
                           event_dataset="blacklist",
                           threat_first_seen=None,
                           threat_last_seen=obj["lastReportedAt"],
                           threat_type="ip_address")
             intel.add_source(ip=obj["ipAddress"])
         except Exception:
             pass
         else:
             intel.add_docid()
             self.intel.append(intel)
         # Add as destination ip
         try:
             intel = Intel(original=json.dumps(obj),
                           event_type="indicator",
                           event_reference=self._feed_url,
                           event_provider="AbuseIPdb",
                           event_dataset="blacklist",
                           threat_first_seen=None,
                           threat_last_seen=obj["lastReportedAt"],
                           threat_type="ip_address")
             intel.add_destination(ip=obj["ipAddress"])
         except Exception:
             pass
         else:
             intel.add_docid()
             self.intel.append(intel)
Beispiel #2
0
 def test_add_source(self):
     intel = Intel()
     intel.add_source(ip="1.1.1.1")
     self.assertEqual(intel.intel["source"]["ip"], "1.1.1.1")
     intel = Intel()
     intel.add_source(ip="1.1.1.1", port=443)
     self.assertEqual(intel.intel["source"]["ip"], "1.1.1.1")
     self.assertEqual(intel.intel["source"]["port"], 443)
    def _parse(self):
        for line in self._raw_threat_intel.split("\n"):
            if line[:1] is "#" or len(line) < 2:
                pass
            else:
                # Add as source ip
                try:
                    if "/" in line:
                        type = "ip_range"
                    else:
                        type = "ip_address"

                    intel = Intel(original=line,
                                  event_type="indicator",
                                  event_reference=self._feed_url,
                                  event_provider="EmergingThreats",
                                  event_dataset="fwrules/emerging-Block-IPs",
                                  threat_first_seen=None,
                                  threat_last_seen=None,
                                  threat_type=type)
                    intel.add_source(ip=line)
                except Exception:
                    pass
                else:
                    intel.add_docid()
                    self.intel.append(intel)
                # Add as destination ip
                try:
                    if "/" in line:
                        type = "ip_range"
                    else:
                        type = "ip_address"

                    intel = Intel(original=line,
                                  event_type="indicator",
                                  event_reference=self._feed_url,
                                  event_provider="EmergingThreats",
                                  event_dataset="fwrules/emerging-Block-IPs",
                                  threat_first_seen=None,
                                  threat_last_seen=None,
                                  threat_type=type)
                    intel.add_destination(ip=line)
                except Exception:
                    pass
                else:
                    intel.add_docid()
                    self.intel.append(intel)
Beispiel #4
0
 def _parse(self):
     for line in self._raw_threat_intel.split("\n"):
         if line[:1] is ";":
             pass
         else:
             split_line = line.split(';')
             # Add as source ip
             try:
                 intel = Intel(original=line,
                               event_type="indicator",
                               event_reference=self._feed_url,
                               event_provider="Spamhaus",
                               event_dataset="Spamhaus.ipv6drop",
                               threat_first_seen=None,
                               threat_last_seen=None,
                               threat_type="domain",
                               threat_description=split_line[1])
                 intel.add_source(ip=split_line[0])
                 intel.intel["threat"]["type"] = "IPV6"
             except IndexError:
                 pass
             else:
                 intel.add_docid()
                 self.intel.append(intel)
             # Add as destination ip
             try:
                 intel = Intel(original=line,
                               event_type="indicator",
                               event_reference=self._feed_url,
                               event_provider="Spamhaus",
                               event_dataset="Spamhaus.ipv6drop",
                               threat_first_seen=None,
                               threat_last_seen=None,
                               threat_type="domain",
                               threat_description=split_line[1])
                 intel.add_destination(ip=split_line[0])
                 intel.intel["threat"]["type"] = "IPV6"
             except IndexError:
                 pass
             else:
                 intel.add_docid()
                 self.intel.append(intel)