《夜行档案》解包求助

from pathlib import Path
from typing import Union
from numpy import uint8, frombuffer as npbuff, tile as npfill

def Decrypt(bundle: Union[Path, str]):
    with open(bundle, 'rb') as f:
        size = 0xDC
        darr = npbuff(f.read(size), dtype=uint8)
        karr = npbuff(bytes(i ^ j for i, j in zip(b'Unit', darr[:4])), dtype=uint8)
        data = (darr ^ npfill(karr, (size // 4) + 1)[:size]).tobytes()
        if not data.startswith(b'UnityFS\x00'):
            print(f'解密错误 ---- {bundle}')
            return
        data += f.read()
    with open(f'{bundle}.dec', 'wb') as f:
        f.write(data)

def batch(bundle_path: str = '', ext: str = '*.dat', subfolder: bool = False):
    path = Path(bundle_path) if bundle_path else Path.cwd()
    need = [i for i in (path.rglob(ext) if subfolder else path.glob(ext))]
    for i in need:
        Decrypt(i)

if __name__ == '__main__':
    path = r'D:\测试' # 指定游戏文件所在文件夹
    ext = '*.dat' # 指定要解密的文件类型后缀
    subfolder = True # 是否查找子文件夹内的文件
    batch(path, ext, subfolder)

它只是xor了文件前220字节

1 个赞