예제 #1
0
def query_classifier(classifier_name, file_paths, seed_sha1 = None):
    expected_sig = None
    logger.info("Received %s query for %d files" % (classifier_name, len(file_paths)))

    query_method = lambda x:query_classifier_cache(classifier_name, x)
    insert_method = lambda *args:insert_classifier_cache(classifier_name, *args)

    if classifier_name == "pdfrate":
        real_query_method = pdfrate
    elif classifier_name == "hidost":
        real_query_method = hidost
    elif classifier_name == "wepawet":
        real_query_method = wepawet
    elif classifier_name == "cuckoo":
        real_query_method = cuckoo
        print "seed_sha1:", seed_sha1
        expected_sig = cuckoo_seed_sigs[seed_sha1]
    elif classifier_name == "hidost_pdfrate":
        real_query_method = hidost_pdfrate
    elif classifier_name == "hidost_pdfrate_sigmoid":
        real_query_method = hidost_pdfrate_sigmoid
    else:
        print "Unknown classifier: %s" % classifier_name
        return None

    results = query(file_paths, real_query_method=real_query_method, \
                     query_method=query_method, insert_method=insert_method, expected_sig=expected_sig)
    assert(len(file_paths) == len(results))

    if classifier_name == "cuckoo":
        bin_ret = ['malicious' if sig == expected_sig else 'benign' for sig in results]
        return bin_ret
    else:
        return results
def query_classifier(classifier_name, file_paths, seed_sha1 = None):
    expected_sig = None
    logger.info("Received %s query for %d files" % (classifier_name, len(file_paths)))

    query_method = lambda x:query_classifier_cache(classifier_name, x)
    insert_method = lambda *args:insert_classifier_cache(classifier_name, *args)
    
    ##print "gent_server2.py----start to load the signatures..."
    cuckoo_sig_pickle = "/home/liangtong/EvadeML-master/lib/36vms_sigs.pickle"
    cuckoo_seed_sigs = pickle.load(open(cuckoo_sig_pickle))
    
    ##print "agent_server2.py----The classifier is: %s." % (classifier_name)
    ##print "agent_server2.py----The file path is..."
    ##print file_paths

    if classifier_name == "pdfrate":
        real_query_method = pdfrate
    elif classifier_name == "hidost":
        ##print classifier_name	      
        real_query_method = hidost
        ##print real_query_method
    elif classifier_name == "wepawet":
        real_query_method = wepawet
    elif classifier_name == "cuckoo":
        real_query_method = cuckoo
        ##print "agent_server2.py----seed_sha1:", seed_sha1
        expected_sig = cuckoo_seed_sigs[seed_sha1]
        ##print "agent_server2.py----sig is as below"
        ##print expected_sig
    elif classifier_name == "hidost_pdfrate":
        real_query_method = hidost_pdfrate
    elif classifier_name == "hidost_pdfrate_sigmoid":
        real_query_method = hidost_pdfrate_sigmoid
    else:
        ##print "agent_server2.py----Unknown classifier: %s" % classifier_name
        return None

    #print "agent_server2.py----real_query_method is: %s. " % (real_query_method)
    ##print real_query_method

    results = query(file_paths, real_query_method=real_query_method, \
                     query_method=query_method, insert_method=insert_method, expected_sig=expected_sig)
    assert(len(file_paths) == len(results))
    #print "agent_server2.py----results is %s" % results
    ##print "agent_server2.py----expected_sig is %s" % expected_sig

    if classifier_name == "cuckoo":
        ##print results[0]
        ##print expected_sig
        bin_ret = ['malicious' if sig == expected_sig else 'benign' for sig in results]
        ##print "agent_server2.py----server begins to return CUCKOO results..."
        ##print  bin_ret
        ##print bin_ret[0]
        return bin_ret
    else:
        ##print "agent_server2.py----server begins to return HIDOST results..."
        #print results
        ##print results[0]
        return results
예제 #3
0
def query_classifier(classifier_name, file_paths, seed_sha1 = None):
    expected_sig = None
    query_method = lambda x:query_classifier_cache(classifier_name, x)
    insert_method = lambda *args:insert_classifier_cache(classifier_name, *args)

    if classifier_name == "pdfrate":
        real_query_method = pdfrate
    elif classifier_name == "cuckoo":
        real_query_method = cuckoo
        print "seed_sha1:", seed_sha1
        cuckoo_sig_pickle = '36vms_sigs.pickle'
        cuckoo_seed_sigs = pickle.load(open(cuckoo_sig_pickle))
        expected_sig = cuckoo_seed_sigs[seed_sha1]
    else:
        print "Unknown classifier: %s" % classifier_name
        return None

    results = query(file_paths, real_query_method=real_query_method, \
                     query_method=query_method, insert_method=insert_method, expected_sig=expected_sig)

    return results