解包求助 游戏名:造梦大乱斗

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

class DreamBattleRoyale:
    Key = npbuff(b'jiaozi2013', dtype=uint8)
    KeyLen = len(Key)
    SignA = b'\x89\x50\x4e\x47\x0d\x0a\x1a\x0a'
    SignB = b'\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82'

    @classmethod
    def Decrypt(cls, png: Union[Path, str]):
        with open(png, 'rb') as f:
            if f.read(7) != b'jiaozhi':
                return
            datarr = npbuff(f.read(), dtype=uint8)
        length = len(datarr)
        data = (datarr ^ npfill(cls.Key, (length // cls.KeyLen) + 1)[:length]).tobytes()
        with open(png, 'wb') as f:
            f.write(b''.join((cls.SignA, data, cls.SignB)))

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

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

批量解密代码

3 个赞