From f4a56637f8c58fce70626acbc7f9c8795501495f Mon Sep 17 00:00:00 2001 From: reiyawea Date: Tue, 16 Oct 2018 19:57:45 +0800 Subject: [PATCH] Update ncmdump.py Remove some redundent parts --- ncmdump.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/ncmdump.py b/ncmdump.py index 01babde..3cbae8f 100644 --- a/ncmdump.py +++ b/ncmdump.py @@ -5,7 +5,6 @@ Created on Sun Jul 15 01:05:58 2018 @author: Nzix """ -import binascii import struct import base64 import json @@ -16,23 +15,22 @@ from mutagen import mp3, flac, id3 def dump(input_path, output_path = None): output_path = (lambda path, meta : os.path.splitext(path)[0] + '.' + meta['format']) if not output_path else output_path - core_key = binascii.a2b_hex('687A4852416D736F356B496E62617857') - meta_key = binascii.a2b_hex('2331346C6A6B5F215C5D2630553C2728') - unpad = lambda s : s[0:-(s[-1] if type(s[-1]) == int else ord(s[-1]))] + core_key = b'hzHRAmso5kInbaxW' + meta_key = rb"#14ljk_!\]&0U<'(" + unpad = lambda s : s[0:-s[-1]] f = open(input_path,'rb') # magic header - header = f.read(8) - assert binascii.b2a_hex(header) == b'4354454e4644414d' + header = f.read(10) + assert header[:8] == b'CTENFDAM' # key data - f.seek(2, 1) key_length = f.read(4) key_length = struct.unpack('