Skip to content

Commit 46e60f8

Browse files
committed
Added better output
1 parent 06db6d2 commit 46e60f8

2 files changed

Lines changed: 32 additions & 5 deletions

File tree

diffrays/analyzer.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def analyze_binary(db_path: str, version: str, debug: bool = False):
6363

6464

6565
def run_diff(old_path, new_path, db_path):
66-
66+
print("[+] Analyzing the binaries using IDA PRO!")
6767
conn = init_db(db_path)
6868
try:
6969
# Explore and save OLD metadata
@@ -93,17 +93,20 @@ def run_diff(old_path, new_path, db_path):
9393
log.warning(f"Could not count functions in {old_path}: {e}")
9494

9595
old_count = 0
96+
print()
9697
for name, compressed, addr, blocks, signature in analyze_binary(old_path, "old"):
9798
try:
9899
insert_function_with_meta(conn, "old", name, compressed, addr, blocks, signature)
99100
except Exception:
100101
insert_function(conn, "old", name, compressed)
101102
old_count += 1
102-
print(f"[*] {old_path} : {old_count}/{old_total}", end="\r", flush=True)
103+
104+
print(f"[*] Exporting {old_path} : {old_count}/{old_total}", end="\r", flush=True)
103105

104-
print() # newline after progress
105106
log.info(f"Decompiled {old_count} functions from old binary")
106107

108+
print()
109+
print("-"*100)
107110
# Explore and save NEW metadata
108111
try:
109112
new_info = explore_database(new_path)
@@ -129,15 +132,17 @@ def run_diff(old_path, new_path, db_path):
129132
log.warning(f"Could not count functions in {new_path}: {e}")
130133

131134
new_count = 0
135+
print()
132136
for name, compressed, addr, blocks, signature in analyze_binary(new_path, "new"):
133137
try:
134138
insert_function_with_meta(conn, "new", name, compressed, addr, blocks, signature)
135139
except Exception:
136140
insert_function(conn, "new", name, compressed)
137141
new_count += 1
138-
print(f"[*] {new_path} : {new_count}/{new_total}", end="\r", flush=True)
142+
print(f"[*] Exporting {new_path} : {new_count}/{new_total}", end="\r", flush=True)
139143

140144
print()
145+
print("-"*100)
141146
log.info(f"Decompiled {new_count} functions from new binary")
142147
log.info(f"Total functions processed: {old_count + new_count}")
143148

@@ -148,4 +153,5 @@ def run_diff(old_path, new_path, db_path):
148153

149154
finally:
150155
conn.close()
151-
print(f"Database written to {db_path}")
156+
print()
157+
print(f"[+] Database written to {db_path}")

diffrays/explorer.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,26 @@
66
import zlib
77
import ida_domain
88

9+
def print_metadata(full_meta: dict) -> None:
10+
metadata = full_meta["metadata"]
911

12+
print(f"\n=== Analyzing: {metadata['module']} ===")
13+
print()
14+
print(f"Path : {metadata['path']}")
15+
print(f"Base Address : 0x{metadata['base_address']:X}")
16+
print(f"Minimum EA : 0x{full_meta['minimum_ea']:X}")
17+
print(f"Maximum EA : 0x{full_meta['maximum_ea']:X}")
18+
print(f"Function Count : {full_meta['function_count']}")
19+
print(f"File Size : {metadata['filesize']} bytes")
20+
print(f"MD5 : {metadata['md5']}")
21+
print(f"SHA256 : {metadata['sha256']}")
22+
print(f"CRC32 : {metadata['crc32']}")
23+
print(f"Architecture : {metadata['architecture']}")
24+
print(f"Bitness : {metadata['bitness']}")
25+
print(f"Format : {metadata['format']}")
26+
print(f"Load Time : {metadata['load_time']}")
27+
print(f"Compiler Info : {metadata['compiler_information']}")
28+
print(f"Execution Mode : {metadata['execution_mode']}")
1029

1130

1231
def _compress_metadata(metadata: Dict[str, Any]) -> bytes:
@@ -40,6 +59,8 @@ def explore_database(binary_path: str) -> Dict[str, Any]:
4059
"metadata": metadata_dict,
4160
}
4261

62+
print_metadata(full_meta)
63+
4364
compressed_blob = _compress_metadata(full_meta)
4465

4566
log.info(

0 commit comments

Comments
 (0)