如题,但是用as读取时发现部分assetbundel进行处理没看懂是什么,另一部分是fakehead可以直接处理
资源包上传了,有兴趣的大佬可以看看
如题,但是用as读取时发现部分assetbundel进行处理没看懂是什么,另一部分是fakehead可以直接处理
资源包上传了,有兴趣的大佬可以看看
搜一下加密的文件头站内实际上有几篇了
def decrypt_unity_asset(file_path, encrypted_data):
if len(encrypted_data) < 8:
return None
v6 = [
0x189E7AC52BF4063D,
0x3C97EA058BF264D1,
0xE86BA20491D5F7C3,
0x569C8B73D01E2FA4
]
v7 = len(encrypted_data)
v8 = bytearray(v7 - 8)
v9 = (v7 - 8) // 16
v10 = bytearray(16)
dst = bytearray(16)
for v12 in range(v9):
v13 = v12 * 16
v10[:] = encrypted_data[v13 + 8: v13 + 24]
v15 = v6[v12 % len(v6)]
shuffle16(dst, v10, v15)
v8[v13:v13 + 16] = dst[:]
v16 = 16 * v9
while v16 < len(v8):
v8[v16] = encrypted_data[v16 + 8]
v16 += 1
filename = Path(file_path).stem
v21 = sha1_hashed(filename)
hash_bytes = v21.encode('ascii')
for v11 in range(len(v8)):
k = v11 % len(hash_bytes)
v8[v11] ^= hash_bytes[k]
return v8
def shuffle16(dst, src, mask):
for i in range(0, 64, 4):
v7 = i // 4
v9 = i & 0x3F
v10 = (mask >> v9) & 0xF
dst[v7] = src[v10]
def sha1_hashed(input_str):
return hashlib.sha1(input_str.encode('ascii')).hexdigest()
def remove_waste_bytes(data):
unityfs_header = b"UnityFS"
header_index = data.find(unityfs_header)
if header_index != -1:
return data[header_index:]
else:
return data
def decrypt_files_in_folder(folder_path):
count = 0
for root, _, files in os.walk(folder_path):
for file in files:
if file.endswith('.unity3d'):
file_path = os.path.join(root, file)
with open(file_path, 'rb') as f:
signature = f.read(4).decode('ascii', errors='ignore')
if signature == "UnityFS":
continue
if signature == "eeab":
with open(file_path, 'rb') as f:
encrypted_data = f.read()
decrypted_data = decrypt_unity_asset(file_path, encrypted_data)
if decrypted_data:
decrypted_data = remove_waste_bytes(decrypted_data)
# 覆盖原始文件
with open(file_path, 'wb') as f:
f.write(decrypted_data)
count += 1
print(f"已解密: {file_path}")
elif signature == "euab":
with open(file_path, 'rb') as f:
encrypted_data = f.read()
decrypted_data = remove_waste_bytes(encrypted_data)
with open(file_path, 'wb') as f:
f.write(decrypted_data)
count += 1
print(f"已解密: {file_path}")
print(f"解密完成! 共处理 {count} 个文件")
感谢