2024-07-24 03:07:18 +02:00
|
|
|
import argparse
|
2024-07-23 14:13:20 +02:00
|
|
|
from hashlib import blake2b
|
2024-07-24 03:07:18 +02:00
|
|
|
from pathlib import Path
|
|
|
|
from typing import cast
|
|
|
|
|
|
|
|
from UnityPy import Environment
|
|
|
|
from UnityPy.classes import TextAsset
|
2024-07-23 14:13:20 +02:00
|
|
|
|
|
|
|
# MU3.Sys.System.keyIvDigestFixed
|
|
|
|
KEY_IV_DIGEST_FIXED = bytes([
|
|
|
|
179, 10, 98, 130, 17, 166, 184, 233, 246, 211,
|
|
|
|
46, 229, 236, 79, 78, 83, 107, 151, 195, 172,
|
|
|
|
57, 72, 120, 103, 17, 124, 18, 64, 15, 225,
|
|
|
|
169, 39
|
|
|
|
])
|
2024-07-24 03:07:18 +02:00
|
|
|
FILE_MAP = {
|
|
|
|
"noise0": "Key",
|
|
|
|
"noise1": "IV",
|
|
|
|
"noise2": "Endpoint salt",
|
|
|
|
}
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
_ = parser.add_argument("mu3_data_path", type=Path)
|
|
|
|
_ = parser.add_argument("key_iv_digest_fixed", type=bytes.fromhex, nargs="?", default=KEY_IV_DIGEST_FIXED)
|
2024-07-23 14:13:20 +02:00
|
|
|
|
2024-07-24 03:07:18 +02:00
|
|
|
args = parser.parse_args()
|
2024-07-23 14:13:20 +02:00
|
|
|
|
2024-07-24 03:07:18 +02:00
|
|
|
env = Environment()
|
2024-07-23 14:13:20 +02:00
|
|
|
|
2024-07-24 03:07:18 +02:00
|
|
|
with (cast(Path, args.mu3_data_path) / "resources.assets").open("rb") as f:
|
|
|
|
env.load_file(f)
|
2024-07-23 14:13:20 +02:00
|
|
|
|
2024-07-24 03:07:18 +02:00
|
|
|
for object in env.objects:
|
|
|
|
if object.type.name != "TextAsset":
|
|
|
|
continue
|
2024-07-23 14:13:20 +02:00
|
|
|
|
2024-07-24 03:07:18 +02:00
|
|
|
data = cast(TextAsset, object.read())
|
2024-07-23 14:13:20 +02:00
|
|
|
|
2024-07-24 03:07:18 +02:00
|
|
|
if data.name in FILE_MAP:
|
|
|
|
key = blake2b(data.m_Script, digest_size=32, key=args.key_iv_digest_fixed).hexdigest()
|
2024-07-23 14:13:20 +02:00
|
|
|
|
2024-07-24 03:07:18 +02:00
|
|
|
print(f"{FILE_MAP[data.name]}: {key}")
|