Пример #1
0
from gym_malware.envs.utils.pefeatures import PEFeatureExtractor

# bytez = interface.fetch_file("Backdoor.Win32.Hupigon.zay")
# features = PEFeatureExtractor().extract2(bytez)
# features2 = PEFeatureExtractor().extract(bytez)
# print(features.__len__())
# print(features2.__len__())

# bytez = interface.fetch_file("VirusShare_0b3c009aa4e461a00c0b3755976b485e")
# # print(bytez)
# features = PEFeatureExtractor().extract(bytez)
# print(features.__len__())
# print(features)

file_list = interface.get_available_sha256()
np.set_printoptions(threshold=1e6)

# run the tests
extractor = PEFeatureExtractor()
index = 0
for sha256 in file_list:
    print("{}:[file]:{}".format(index + 1, sha256))
    bytez = interface.fetch_file(sha256)

    index = index + 1
    print(extractor.extract2(bytez))
    print(extractor.extract2(bytez).shape)

    if index > 1:
        break
Пример #2
0
except FileNotFoundError:
    # if you want to use the cloud interface, you must populate your own params.json
    # file.  Look at params.json.in for a template, which takes the following form
    __private_data = {
        "url": "http://my.av.api",  # route to RESTful API interface
        "username": "******",  # Username
        "password": "******",  # password
        "version": "1.0",  # version
        "threshold": 0.90  # threshold
    }
    # you may also need to change get_score_remote and/or get_label_remote below

# for local model
from gym_malware.envs.utils.pefeatures import PEFeatureExtractor
from sklearn.externals import joblib
feature_extractor = PEFeatureExtractor()
local_model = joblib.load(os.path.join(module_path, 'gradient_boosting.pkl'))
local_model_threshold = 0.90


class ClassificationFailure(Exception):
    pass


class FileRetrievalFailure(Exception):
    pass


def fetch_file(sha256):
    location = os.path.join(SAMPLE_PATH, sha256)
    try: