-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalyze_key.py
More file actions
42 lines (32 loc) · 1.24 KB
/
Copy pathanalyze_key.py
File metadata and controls
42 lines (32 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import struct
import sys
def analyze_dsc_key(dsc_path):
"""Extract and display the encryption key from a DSC file"""
with open(dsc_path, 'rb') as f:
data = f.read()
if len(data) < 32:
print("Error: File too small to be a valid DSC file")
return
# Read header
format_str = data[0:16]
key = struct.unpack('<I', data[16:20])[0]
original_size = struct.unpack('<I', data[20:24])[0]
dec_count = struct.unpack('<I', data[24:28])[0]
print(f"File: {dsc_path}")
print(f"Format: {format_str.decode('ascii', errors='ignore').rstrip(chr(0))}")
print(f"\nEncryption Key: 0x{key:08X}")
print(f"Original Size: {original_size:,} bytes")
print(f"Symbol Count: {dec_count:,}")
print(f"Compressed Size: {len(data):,} bytes")
print(f"Compression Ratio: {len(data) / original_size * 100:.1f}%")
print(f"\nUse this key for compression:")
print(f" python dsc_compressor.py <input> <output> {key:08X}")
def main():
if len(sys.argv) < 2:
print("Usage: python analyze_key.py <dsc_file>")
print("Example: python analyze_key.py 01_prologue1")
sys.exit(1)
dsc_file = sys.argv[1]
analyze_dsc_key(dsc_file)
if __name__ == "__main__":
main()