# -*- coding: utf-8 -*- """ Created on Sun Jul 15 01:05:58 2018 @author: Nzix """ import binascii import struct import base64 import json import os import re from Crypto.Cipher import AES from mutagen import mp3, flac, id3 def validate_name(file_name): # pattern = r"[\/\\\:\*\?\"\<\>\|]" # file_name = re.sub(pattern, "_", file_name) # return file_name pattern = {u'\\': u'\', u'/': u'/', u':': u':', u'*': u'*', u'?': u'?', u'"': u'"', u'<': u'<', u'>': u'>', u'|': u'|'} for character in pattern: file_name = file_name.replace(character, pattern[character]) return file_name # def validate_collision(file_name): # index = 1 # while os.path.exists(file_name): # file_name = '({})'.format(index).join(os.path.splitext(file_name)) # index += 1 # return file_name def dump(file_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]))] f = open(file_path,'rb') # magic header header = f.read(8) assert binascii.b2a_hex(header) == b'4354454e4644414d' # key data f.seek(2, 1) key_length = f.read(4) key_length = struct.unpack(' 1: files = sys.argv[1:] else: files = [file_name for file_name in os.listdir('.') if os.path.splitext(file_name)[-1] == '.ncm'] if not files: print('please input file path!') for file_name in files: try: dump(file_name) print(os.path.split(file_name)[-1]) except Exception as e: print(e) pass