判断空指令

This commit is contained in:
huihun 2024-04-22 13:14:01 +08:00
parent 61a44a27c5
commit b2b6a2b7a6
3 changed files with 7 additions and 3 deletions

View File

@ -105,8 +105,11 @@ def generate_inst_vec(inst, method="mean"):
def bb2vec(item):
tmp = generate_inst_vec(item['opcode'], method="mean")
return item['addr'], list(np.mean(tmp.detach().numpy(), axis=0).astype(float))
try:
tmp = generate_inst_vec(item['opcode'], method="mean")
return True, item['addr'], list(np.mean(tmp.detach().numpy(), axis=0).astype(float))
except Exception as e:
return False, item['addr'], item['opcode'], e
if __name__ == "__main__":

View File

@ -247,7 +247,6 @@ def exe_to_json(file_path):
logger.error(f"cfg错误{cfg_Operation_message}")
return
# json写入
os.makedirs(output_path, exist_ok=True)
save_json(os.path.join(output_path, file_fingerprint + '.jsonl'), json_obj)
logger.info(f"解析完成,文件名{file_path}")
return

View File

@ -82,6 +82,8 @@ def multi_thread_disorder(func, thread_num=THREAD_FULL, **args):
def save_json(filename, data):
data = json.dumps(data)
# 确保路径存在
os.makedirs(os.path.dirname(filename), exist_ok=True)
file = open(filename, 'w')
file.write(data)
file.close()