示例#1
0
 def get_content(self):
     """
     Returns Item content
     """
     return item_basic.get_item_content(self.id)
示例#2
0
    publisher.info("Script Tracker_Yara started")

    config_section = 'Tracker_Yara'
    module_name = "Tracker_Yara"
    p = Process(config_section)

    full_item_url = p.config.get("Notifications", "ail_domain") + full_item_url

    # Load Yara rules
    rules = Tracker.reload_yara_rules()

    # Regex Frequency
    while True:
        item_id = p.get_from_set()
        if item_id is not None:
            item_content = item_basic.get_item_content(item_id)
            yara_match = rules.match(data=item_content,
                                     callback=yara_rules_match,
                                     which_callbacks=yara.CALLBACK_MATCHES,
                                     timeout=60)
            if yara_match:
                print(f'{item_id}: {yara_match}')

        else:
            time.sleep(5)

        # refresh YARA list
        if last_refresh < Tracker.get_tracker_last_updated_by_type('yara'):
            rules = Tracker.reload_yara_rules()
            last_refresh = time.time()
            print('Tracked set refreshed')
示例#3
0
def get_item_content(item_id):
    return item_basic.get_item_content(item_id)
def main():
    publisher.port = 6380
    publisher.channel = "Script"

    config_section = 'DomClassifier'

    p = Process(config_section)
    addr_dns = p.config.get("DomClassifier", "dns")

    publisher.info("""ZMQ DomainClassifier is Running""")

    c = DomainClassifier.domainclassifier.Extract(rawtext="",
                                                  nameservers=[addr_dns])

    cc = p.config.get("DomClassifier", "cc")
    cc_tld = p.config.get("DomClassifier", "cc_tld")

    while True:
        try:
            item_id = p.get_from_set()

            if item_id is None:
                publisher.debug("Script DomClassifier is idling 1s")
                time.sleep(1)
                continue

            item_content = item_basic.get_item_content(item_id)
            mimetype = item_basic.get_item_mimetype(item_id)
            item_basename = item_basic.get_basename(item_id)
            item_source = item_basic.get_source(item_id)
            item_date = item_basic.get_item_date(item_id)

            if mimetype.split('/')[0] == "text":
                c.text(rawtext=item_content)
                c.potentialdomain()
                c.validdomain(passive_dns=True, extended=False)
                print(c.vdomain)

                if c.vdomain and d4.is_passive_dns_enabled():
                    for dns_record in c.vdomain:
                        p.populate_set_out(dns_record)

                localizeddomains = c.include(expression=cc_tld)
                if localizeddomains:
                    print(localizeddomains)
                    publisher.warning(
                        f"DomainC;{item_source};{item_date};{item_basename};Checked {localizeddomains} located in {cc_tld};{item_id}"
                    )
                localizeddomains = c.localizedomain(cc=cc)

                if localizeddomains:
                    print(localizeddomains)
                    publisher.warning(
                        f"DomainC;{item_source};{item_date};{item_basename};Checked {localizeddomains} located in {cc};{item_id}"
                    )

        except IOError:
            print("CRC Checksum Failed on :", item_id)
            publisher.error(
                f"Duplicate;{item_source};{item_date};{item_basename};CRC Checksum Failed"
            )