From 65dcfefc052bb9c1244acee3ad2a0a75f3a577bb Mon Sep 17 00:00:00 2001 From: huihun <781165206@qq.com> Date: Thu, 28 Dec 2023 15:43:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E5=9D=97=E5=88=86=E6=8B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/Gencoding.iml | 2 +- .idea/misc.xml | 5 ++++- raw-feature-extractor/print_test.py | 21 +++++++++++---------- raw-feature-extractor/raw_graphs.py | 2 +- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/.idea/Gencoding.iml b/.idea/Gencoding.iml index d9ff559..7ba4311 100644 --- a/.idea/Gencoding.iml +++ b/.idea/Gencoding.iml @@ -4,7 +4,7 @@ - + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 7ba73c2..44f3bc1 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,7 @@ - + + + \ No newline at end of file diff --git a/raw-feature-extractor/print_test.py b/raw-feature-extractor/print_test.py index 2cca783..13df20f 100644 --- a/raw-feature-extractor/print_test.py +++ b/raw-feature-extractor/print_test.py @@ -21,19 +21,15 @@ import pickle # sub_10F20 308 反编译代码有字符串,但是这个特征提取里没有字符串 constant,可能是间接引用的,不识别。看了下所有函数的特征,几乎都没有字符串常量,可能都是写在别的地方然后引用的。 # sub_166C4 393 - - -if __name__ == '__main__': +def main_op(file_path, jsonl_file): done_index = 0 - file_name_list = os.listdir('../A2C/') - res_file = "../sample.jsonl" - sample_file = open(res_file, mode='a') + file_name_list = os.listdir(file_path) + sample_file = open(jsonl_file, mode='a') for file_name in file_name_list: print file_name - file_path = '../A2C/' + file_name - testpath = '../store/' + file_name + '.ida' - if os.path.exists(testpath) and os.path.splitext(file_path)[-1].lower() == '.exe': - fr = open(testpath, 'r') + file_path_temp = file_path + file_name + if os.path.exists(file_path_temp) : + fr = open(file_path_temp, 'r') data1 = pickle.load(fr) # 一个二进制文件的acfgs # funtion num function_number = len(data1.raw_graph_list) @@ -109,3 +105,8 @@ if __name__ == '__main__': print "删除文件" + file_path os.remove(file_path) sample_file.close() + +if __name__ == '__main__': + file_path = "../train_malware_result/" + jsonl_path = "../jsonl_res/malware_result.jsonl" + main_op(file_path, jsonl_path) diff --git a/raw-feature-extractor/raw_graphs.py b/raw-feature-extractor/raw_graphs.py index eb40c2e..0e61b78 100755 --- a/raw-feature-extractor/raw_graphs.py +++ b/raw-feature-extractor/raw_graphs.py @@ -1,7 +1,7 @@ import itertools import sys -sys.path.insert(1, 'C:/Python27/Lib/site-packages') + import networkx as nx # import numpy as np from subprocess import Popen, PIPE