def main():
"""
arg1 - path to files
arg2 - path to res dir
"""
ben_files = []
corrupted_files = []
for file_name in os.listdir(sys.argv[1]):
path_to_file = join(sys.argv[1], file_name)
if not os.path.isfile(path_to_file): continue
print "Try to ent-split file", file_name
try:
ben_files.append([file_name, build_tree(
get_execution_block(path_to_file))])
except pefile.PEFormatError:
print "Can't process file"
corrupted_files.append(file_name)
for ben_file in ben_files:
ben_file.append(quad_fourier(ben_file[1]))
ben_sorted_groups = []
for ben_file in ben_files:
was_found = False
if(ben_file[2][0] == 0.0): continue
for group in ben_sorted_groups:
if abs(group[0][0] - ben_file[2][0]) / group[0][0] < limit and \
abs(group[0][1] - ben_file[2][1]) / group[0][1] < limit:
was_found = True
group[1].append(ben_file[0])
break
if not was_found:
ben_sorted_groups.append([ben_file[2], [ben_file[0]]])
unsorted_groups = filter(lambda x: len(x[1]) == 1, ben_sorted_groups)
ben_sorted_groups = filter(lambda x: len(x[1]) > 1, ben_sorted_groups)
res_dir = sys.argv[2]
for group in ben_sorted_groups:
dir_name = join(res_dir, "[{0}]V={1},E={2}".format(len(group[1]), "%.2f"%group[0][0], "%.2f"%group[0][1]))
os.mkdir(join(dir_name))
for file_name in group[1]:
shutil.copyfile(join(sys.argv[1], file_name), join(dir_name, os.path.basename(file_name)))
评论列表
文章目录