yuxin
1
想要提取提取游戏剧情中的文字,找到了文件(可能是.nani)但AssetStudio选中文件就报错
目前发现 10203.nani 这个资源能打开,其他不知道咋办
文件都是UnityFS 开头的
libil2cpp.so,global-metadata.dat这俩个文件的DLL也都提取出来了,但奈何对C不了解,这几天一直查资料也找不到方法,希望大佬能帮帮忙 (┬┬﹏┬┬)
游戏网站:
游戏资源:
libil2cpp.so,global-metadata.dat以及DLL链接:
https://wwuk.lanzouo.com/iODdc2pdg82h
以上就是我能提供的东西了
试了几个文件使用unitypy可以正常读取,似乎是assetstudio的问题
对的,是AS的问题,这个版本的AS问题很多,非必要时不建议用
这款游戏中的 PNG 文件在后续版本中被加密了。
请问能够对其进行解密吗?
例子 https://lilyange.webaccel.saikyo.biz/img/character/chara1001_icon
由于该角色是在加密之前实装的,因此PNG文件也保留了下来。
yuxin
7
以下是原理
derived = pbkdf2_hmac("sha1", b"RkBixyx5", b"zNck9u3Y", 1000, 32)
key, iv = derived[:16], derived[16:]
plain = AES128CBC(key, iv).decrypt(payload) # 整段就是密文
plain = pkcs7_unpad(plain)
以下为测试用例
import argparse
import hashlib
import sys
import urllib.request
from pathlib import Path
from urllib.parse import urlparse
PASSWORD = b"RkBixyx5"
SALT = b"zNck9u3Y"
ITERATIONS = 1000
TIMEOUT = 30
# Windows 终端默认按代码页输出,中文提示可能乱码;统一按 UTF-8 写。
for _stream in (sys.stdout, sys.stderr):
if hasattr(_stream, "reconfigure"):
_stream.reconfigure(encoding="utf-8")
def image_suffix(data: bytes):
if data.startswith(b"\x89PNG\r\n\x1a\n"):
return ".png"
if data.startswith(b"\xff\xd8"):
return ".jpg"
if data.startswith((b"GIF87a", b"GIF89a")):
return ".gif"
if data[:4] == b"RIFF" and data[8:12] == b"WEBP":
return ".webp"
return None
def decrypt(payload: bytes):
if len(payload) < 32 or len(payload) % 16:
return None
try:
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
except ImportError:
sys.exit("需要安装 cryptography:pip install cryptography")
derived = hashlib.pbkdf2_hmac("sha1", PASSWORD, SALT, ITERATIONS, 32)
decryptor = Cipher(algorithms.AES(derived[:16]), modes.CBC(derived[16:])).decryptor()
plain = decryptor.update(payload) + decryptor.finalize()
pad = plain[-1]
if not 1 <= pad <= 16 or plain[-pad:] != bytes([pad]) * pad:
return None
return plain[:-pad]
def load(source: str) -> bytes:
if source.startswith(("http://", "https://")):
request = urllib.request.Request(source, headers={"User-Agent": "Mozilla/5.0"})
with urllib.request.urlopen(request, timeout=TIMEOUT) as response:
return response.read()
return Path(source).read_bytes()
def default_name(source: str, suffix: str) -> str:
if source.startswith(("http://", "https://")):
stem = Path(urlparse(source).path).name or "image"
else:
stem = Path(source).name
return Path(stem).stem + suffix
def main() -> int:
parser = argparse.ArgumentParser(description="解密单个 CDN 图片容器。")
parser.add_argument("source", help="图片 URL 或本地文件")
parser.add_argument("-o", "--out", help="输出文件或目录(默认:./<名称><后缀>)")
args = parser.parse_args()
payload = load(args.source)
suffix = image_suffix(payload)
if suffix is None:
plain = decrypt(payload)
if plain is None:
print("不是已知图片,也不是可解密的容器", file=sys.stderr)
return 1
suffix = image_suffix(plain)
if suffix is None:
print("解密结果不是已知图片(口令或盐不对?)", file=sys.stderr)
return 1
payload = plain
out = Path(args.out) if args.out else Path(default_name(args.source, suffix))
if out.is_dir():
out = out / default_name(args.source, suffix)
out.parent.mkdir(parents=True, exist_ok=True)
out.write_bytes(payload)
print(f"{len(payload):>8} 字节 -> {out} ({suffix})", flush=True)
return 0
if __name__ == "__main__":
raise SystemExit(main())
用法
# 解 URL(默认输出到当前目录,按魔数自动补扩展名)
python decrypt_image.py https://lilyange.webaccel.saikyo.biz/img/character/chara1001_icon
# 解本地文件到指定路径 / 已存在的目录
python decrypt_image.py some_encrypted.bin -o out.png
python decrypt_image.py some_encrypted.bin -o ./out_dir