Exemple #1
0
def basic_ip_task(plugin_name, project_id, resource_id, resource_type, ip):

    query_result = {}

    # PTR
    try:
        PTR_record = ptr(ip)

        if PTR_record:
            query_result["ptr"] = PTR_record

        ASN_NET_record = asn(ip)

        if "asn" in ASN_NET_record:
            query_result["asn"] = ASN_NET_record["asn"]

        if "network" in ASN_NET_record:
            query_result["network"] = ASN_NET_record["network"]

        # TODO: Probably, we can save some parameters here when object is instantiated
        resource_type = ResourceType(resource_type)

        resource = Resources.get(resource_id, resource_type)
        resource.set_plugin_results(
            plugin_name, project_id, resource_id, resource_type, query_result
        )

    except Exception as e:
        tb1 = traceback.TracebackException.from_exception(e)
        print("".join(tb1.format()))
Exemple #2
0
def maltiverse_task(plugin_name, project_id, resource_id, resource_type, target):
    try:
        query_result = None
        resource_type = ResourceType(resource_type)
        if resource_type == ResourceType.IPv4:
            query_result = maltiverse_ip(target)
        elif resource_type == ResourceType.DOMAIN:
            query_result = maltiverse_domain(target)
        elif resource_type == ResourceType.URL:
            query_result = maltiverse_url(target)
        elif resource_type == ResourceType.HASH:
            query_result = maltiverse_hash(target)
        else:
            print("Maltiverse resource type does not found")

        if not query_result:
            return

        print(query_result)

        # TODO: See if ResourceType.__str__ can be use for serialization
        resource = Resources.get(resource_id, resource_type)
        resource.set_plugin_results(
            plugin_name, project_id, resource_id, resource_type, query_result
        )

    except Exception as e:
        tb1 = traceback.TracebackException.from_exception(e)
        print("".join(tb1.format()))
Exemple #3
0
def threatcrowd_task(plugin_name, project_id, resource_id, resource_type, target):
    try:
        resource_type = ResourceType(resource_type)
        if resource_type == ResourceType.IPv4:
            query_result = threatcrowd_ip(target)
        elif resource_type == ResourceType.DOMAIN:
            query_result = threatcrowd_domain(target)
        elif resource_type == ResourceType.EMAIL:
            query_result = threatcrowd_email(target)
        elif resource_type == ResourceType.HASH:
            query_result = threatcrowd_hash(target)
        else:
            print("ThreatCrowd resource type does not found")

        if not query_result:
            return

        # TODO: See if ResourceType.__str__ can be use for serialization
        resource = Resources.get(resource_id, resource_type)
        resource.set_plugin_results(
            plugin_name, project_id, resource_id, resource_type, query_result
        )

    except Exception as e:
        tb1 = traceback.TracebackException.from_exception(e)
        print("".join(tb1.format()))
Exemple #4
0
def geoip_task(plugin_name, project_id, resource_id, resource_type, ip):
    try:
        query_result = geoip(ip)
        if not query_result:
            return

        # TODO: See if ResourceType.__str__ can be use for serialization
        resource_type = ResourceType(resource_type)
        resource = Resources.get(resource_id, resource_type)
        resource.set_plugin_results(
            plugin_name, project_id, resource_id, resource_type, query_result
        )

    except Exception as e:
        tb1 = traceback.TracebackException.from_exception(e)
        print("".join(tb1.format()))
Exemple #5
0
def virustotal_task(plugin_name, project_id, resource_id, resource_type, target):
    try:
        query_result = None

        resource_type = ResourceType(resource_type)
        query_result = virustotal(target, resource_type)

        # TODO: See if ResourceType.__str__ can be use for serialization
        resource = Resources.get(resource_id, resource_type)
        resource.set_plugin_results(
            plugin_name, project_id, resource_id, resource_type, query_result
        )

    except Exception as e:
        tb1 = traceback.TracebackException.from_exception(e)
        print("".join(tb1.format()))
Exemple #6
0
def botscout_task(plugin_name, project_id, resource_id, resource_type, ip):
    try:
        resource_type = ResourceType(resource_type)
        if resource_type == ResourceType.DOMAIN:
            query_result = botscout_ip(ip)
        else:
            print("BotScout resource type does not found")

        resource = Resources.get(resource_id, resource_type)
        resource.set_plugin_results(
            plugin_name, project_id, resource_id, resource_type, query_result
        )

    except Exception as e:
        tb1 = traceback.TracebackException.from_exception(e)
        print("".join(tb1.format()))
Exemple #7
0
def threatminer_task(plugin_name, project_id, resource_id, resource_type, domain):
    try:
        resource_type = ResourceType(resource_type)
        if resource_type == ResourceType.DOMAIN:
            query_result = threatminer_domain(domain, "1")
        else:
            print("threatminer resource type does not found")

        resource = Resources.get(resource_id, resource_type)
        resource.set_plugin_results(
            plugin_name, project_id, resource_id, resource_type, query_result
        )

    except Exception as e:
        tb1 = traceback.TracebackException.from_exception(e)
        print("".join(tb1.format()))
Exemple #8
0
def phishtank_task(plugin_name, project_id, resource_id, resource_type, url):
    try:
        resource_type = ResourceType(resource_type)
        if resource_type == ResourceType.URL:
            query_result = phishtank_check(url)
        else:
            print("phishtank resource type does not found")

        resource = Resources.get(resource_id, resource_type)
        resource.set_plugin_results(
            plugin_name, project_id, resource_id, resource_type, query_result
        )

    except Exception as e:
        tb1 = traceback.TracebackException.from_exception(e)
        print("".join(tb1.format()))
Exemple #9
0
def whois_task(plugin_name, project_id, resource_id, resource_type, domain):

    try:
        query_result = json.loads(str(whois.whois(domain)))
        resource_type = ResourceType(resource_type)
        # TODO: See if ResourceType.__str__ can be use for serialization
        resource = Resources.get(resource_id, resource_type)
        resource.set_plugin_results(
            plugin_name, project_id, resource_id, resource_type, query_result
        )

    except whois.parser.PywhoisError:
        print(f"Domain {domain} does not exists")

    except Exception as e:
        tb1 = traceback.TracebackException.from_exception(e)
        print("".join(tb1.format()))
Exemple #10
0
def puslsedive_task(
    plugin_name, project_id, resource_id, resource_type, domain_or_hash
):
    try:
        resource_type = ResourceType(resource_type)
        if resource_type == ResourceType.DOMAIN or resource_type == ResourceType.HASH:
            query_result = pulsedive_get_ioc_byvalue(domain_or_hash)
        else:
            print("PulseDive resource type does not found")

        resource = Resources.get(resource_id, resource_type)
        resource.set_plugin_results(
            plugin_name, project_id, resource_id, resource_type, query_result
        )

    except Exception as e:
        tb1 = traceback.TracebackException.from_exception(e)
        print("".join(tb1.format()))
Exemple #11
0
def dns_task(plugin_name, project_id, resource_id, resource_type, domain):

    query_result = {}

    # PTR
    try:
        dns_results = dns(domain)
        query_result = dns_results

        # TODO: Probably, we can save some parameters here when object is instantiated
        resource_type = ResourceType(resource_type)

        resource = Resources.get(resource_id, resource_type)
        resource.set_plugin_results(
            plugin_name, project_id, resource_id, resource_type, query_result
        )

    except Exception as e:
        tb1 = traceback.TracebackException.from_exception(e)
        print("".join(tb1.format()))
Exemple #12
0
def pastebin_task(
    plugin_name, project_id, resource_id, resource_type, target, search_engine
):
    try:
        # We use "googlesearch" subtask to gather results as pastebin.com does not
        # have a in-search engine
        query_result = restricted_googlesearch(search_engine, target)

        # Now, process google results and get the pastes and metadata
        if query_result:
            query_result = pastebin(query_result)

        resource_type = ResourceType(resource_type)
        resource = Resources.get(resource_id, resource_type)
        resource.set_plugin_results(
            plugin_name, project_id, resource_id, resource_type, query_result
        )

    except Exception as e:
        tb1 = traceback.TracebackException.from_exception(e)
        print("".join(tb1.format()))
Exemple #13
0
def hunterio_task(plugin_name, project_id, resource_id, resource_type, target):
    try:
        query_result = None

        resource_type = ResourceType(resource_type)
        if resource_type == ResourceType.DOMAIN:
            query_result = hunterio_domain(target)
        elif resource_type == ResourceType.EMAIL:
            query_result = hunterio_email(target)
        else:
            print("Hunter.io resource type does not found")

        # TODO: See if ResourceType.__str__ can be use for serialization
        resource = Resources.get(resource_id, resource_type)
        resource.set_plugin_results(
            plugin_name, project_id, resource_id, resource_type, query_result
        )

    except Exception as e:
        tb1 = traceback.TracebackException.from_exception(e)
        print("".join(tb1.format()))
Exemple #14
0
def otx_task(plugin_name, project_id, resource_id, resource_type, target):
    try:
        resource_type = ResourceType(resource_type)
        # Check 2nd parameter if it's sent through view (frontend)
        if resource_type == ResourceType.IPv4:
            query_result = otx_iocs_ipv4(target, "general")
        elif resource_type == ResourceType.DOMAIN:
            query_result = otx_iocs_hostname(target, "general")
        elif resource_type == ResourceType.URL:
            query_result = otx_iocs_url(target, "general")
        elif resource_type == ResourceType.HASH:
            query_result = otx_iocs_file(target, "analysis")
        else:
            print("OTX resource type does not found")

        resource = Resources.get(resource_id, resource_type)
        resource.set_plugin_results(
            plugin_name, project_id, resource_id, resource_type, query_result
        )

    except Exception as e:
        tb1 = traceback.TracebackException.from_exception(e)
        print("".join(tb1.format()))