From 45e10f744047cdfc8eac40a7d7e808a03be6c4c3 Mon Sep 17 00:00:00 2001 From: ilektragiassa <117294049+ilektragiassa@users.noreply.github.com> Date: Wed, 25 Oct 2023 12:04:36 +0200 Subject: [PATCH 1/2] AEGIS-6406 add identation Disassemble only if the folder does not exist --- asm2vec/binary_to_asm.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/asm2vec/binary_to_asm.py b/asm2vec/binary_to_asm.py index 58ccaa1..70218d7 100644 --- a/asm2vec/binary_to_asm.py +++ b/asm2vec/binary_to_asm.py @@ -145,18 +145,18 @@ def convert_to_asm( out_dir = os.path.join(asm_dir, entry.name) if not (os.path.exists(out_dir)): os.mkdir(out_dir) - function_count += bin_to_asm(Path(entry), Path(out_dir), minlen_upper, magic_bytes) - if function_count == 0: - function_count += bin_to_asm(Path(entry), Path(out_dir), minlen_lower, magic_bytes) + function_count += bin_to_asm(Path(entry), Path(out_dir), minlen_upper, magic_bytes) if function_count == 0: - os.rmdir(out_dir) - logging.info('The binary {} was not disassembled'.format(entry.name)) + function_count += bin_to_asm(Path(entry), Path(out_dir), minlen_lower, magic_bytes) + if function_count == 0: + os.rmdir(out_dir) + logging.info('The binary {} was not disassembled'.format(entry.name)) + else: + binary_count += 1 + disassembled_bins.append(entry.name) else: binary_count += 1 disassembled_bins.append(entry.name) - else: - binary_count += 1 - disassembled_bins.append(entry.name) else: not_found += 1 logging.info("[Error] No such file or directory: {}".format(binary_dir)) From 8d1b419e928890b2042b9772dd76cbb9a409be13 Mon Sep 17 00:00:00 2001 From: ilektragiassa <117294049+ilektragiassa@users.noreply.github.com> Date: Wed, 25 Oct 2023 13:09:22 +0200 Subject: [PATCH 2/2] AEGIS-6406 fix function_count Correctly calculate function_count per binary, not cumulatively --- asm2vec/binary_to_asm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/asm2vec/binary_to_asm.py b/asm2vec/binary_to_asm.py index 70218d7..28b573f 100644 --- a/asm2vec/binary_to_asm.py +++ b/asm2vec/binary_to_asm.py @@ -145,9 +145,9 @@ def convert_to_asm( out_dir = os.path.join(asm_dir, entry.name) if not (os.path.exists(out_dir)): os.mkdir(out_dir) - function_count += bin_to_asm(Path(entry), Path(out_dir), minlen_upper, magic_bytes) + function_count = bin_to_asm(Path(entry), Path(out_dir), minlen_upper, magic_bytes) if function_count == 0: - function_count += bin_to_asm(Path(entry), Path(out_dir), minlen_lower, magic_bytes) + function_count = bin_to_asm(Path(entry), Path(out_dir), minlen_lower, magic_bytes) if function_count == 0: os.rmdir(out_dir) logging.info('The binary {} was not disassembled'.format(entry.name))