def malware_samples(self, indicator, source): if source == "VTO": scraper = VirusTotalScraper() malware = scraper.get_malware(indicator) # elif source == "TEX": scraper = ThreatExpertScraper() malware = scraper.run(indicator) else: malware = [] for entry in malware: try: record_entry = IndicatorRecord(record_type="MR", info_source=source, info_date=entry['date'], info=OrderedDict({"md5": entry['md5'], "sha1": entry['sha1'], "sha256": entry['sha256'], "indicator": entry['C2'], "link": entry['link']})) record_entry.save() except Exception as e: print(e)
def malware_samples(indicator, record_source): record_type = RecordType.MR if record_source is RecordSource.VTO: scraper = VirusTotalScraper() malware = scraper.get_malware(indicator) elif record_source is RecordSource.TEX: scraper = ThreatExpertScraper() malware = scraper.run(indicator) else: malware = [] for entry in malware: try: date = entry['date'] info = OrderedDict({"md5": entry['md5'], "sha1": entry['sha1'], "sha256": entry['sha256'], "indicator": entry['C2'], "link": entry['link']}) save_record(record_type, record_source, info, date=date) except Exception: logger.exception("Error saving %s (%s) record from %s", record_type.name, record_type.title, record_source.title)