def _parse(self): for line in self._raw_threat_intel.split("\n"): if line[:1] is "#": pass else: try: split_line = line.split('", "') intel = Intel( original=line, event_type="indicator", event_reference=self._feed_url, event_provider="Abuse.ch", event_dataset="MalwareBazaar", threat_first_seen=split_line[0], threat_last_seen=None, threat_type="file_hash" ) intel.add_file(name=split_line[5], extension=split_line[6], mime_type=split_line[7], sha1=split_line[3], sha256=split_line[1], md5=split_line[2]) intel.add_malware(split_line[8]) except Exception as err: print(err) else: intel.add_docid() self.intel.append(intel)
def _parse(self): for line in self._raw_threat_intel.split("\n"): # Add as source ip try: intel = Intel(original=line, event_type="indicator", event_reference=self._feed_url, event_provider="botvrij", event_dataset="botvrij.filenames", threat_first_seen=None, threat_last_seen=None, threat_type="file") intel.add_file(name=line) except Exception: pass else: intel.add_docid() self.intel.append(intel)
def test_add_file(self): intel = Intel() intel.add_file(name="example.exe") self.assertEqual(intel.intel["file"]["name"], "example.exe") intel = Intel() intel.add_file( name="example.exe", sha1="04ea0d99e724bae38f63b34955a669a13da65485", sha256= "4d6feee47b15e24f526f8d9053b04a6ff5cefef4f9df71b8dffede2de31fcc57") self.assertEqual(intel.intel["file"]["name"], "example.exe") self.assertEqual(intel.intel["file"]["hash"]["sha1"], "04ea0d99e724bae38f63b34955a669a13da65485") self.assertEqual( intel.intel["file"]["hash"]["sha256"], "4d6feee47b15e24f526f8d9053b04a6ff5cefef4f9df71b8dffede2de31fcc57") intel = Intel() intel.add_file( name="example.exe", sha1="04ea0d99e724bae38f63b34955a669a13da65485", sha256= "4d6feee47b15e24f526f8d9053b04a6ff5cefef4f9df71b8dffede2de31fcc57", drive_letter="C") self.assertEqual(intel.intel["file"]["name"], "example.exe") self.assertEqual(intel.intel["file"]["drive_letter"], "C") self.assertEqual(intel.intel["file"]["hash"]["sha1"], "04ea0d99e724bae38f63b34955a669a13da65485") self.assertEqual( intel.intel["file"]["hash"]["sha256"], "4d6feee47b15e24f526f8d9053b04a6ff5cefef4f9df71b8dffede2de31fcc57")
def _parse(self): for root, dirs, files in walk("tip/githubclones/eset/malware-ioc"): for file in files: if ".git" in root: continue elif "README" in file: continue elif "samples" in file: lines = "" with open("{}/{}".format(root, file), "r") as iocfile: lines = iocfile.read().split("\n") for line in lines: try: intel = Intel(original=line, event_type="indicator", event_reference=self._feed_url, event_provider="Eset", event_dataset="malware-ioc", threat_first_seen=None, threat_last_seen=None, threat_type="file_hash") if file == "samples.sha1": intel.add_file(sha1=line) elif file == "samples.sha256": intel.add_file(sha256=line) elif file == "samples.md5": intel.add_file(md5=line) except Exception as err: print(err) else: intel.add_docid() self.intel.append(intel)