chaomengcfx / arkassetstool Goto Github PK
View Code? Open in Web Editor NEW方舟资源自动下载解包
方舟资源自动下载解包
I tried to use
import os
from Crypto.Cipher import AES
class ArkAssets:
CHAT_MASK = bytes.fromhex('554954704169383270484157776e7a7148524d4377506f6e4a4c49423357436c').decode()
@staticmethod
def text_asset_decrypt(stream, has_rsa: bool = True) -> bytes:
aes_key = ArkAssets.CHAT_MASK[:16].encode()
aes_iv = bytearray(16)
data = stream[128:] if has_rsa else stream
buf = data[:16]
mask = ArkAssets.CHAT_MASK[16:].encode()
for i in range(len(buf)):
aes_iv[i] = buf[i] ^ mask[i]
aes_obj = AES.new(aes_key, AES.MODE_CBC, aes_iv)
decrypt_buf = aes_obj.decrypt(data[16:])
unpad = lambda s: s[0:(len(s) - s[-1])]
return unpad(decrypt_buf)
folder_path = os.getcwd()
file_list = os.listdir(folder_path)
for file_name in file_list:
if os.path.isfile(file_name):
with open(file_name, 'rb') as file:
encrypted_data = file.read()
decrypted_data = ArkAssets.text_asset_decrypt(encrypted_data)
new_file_name = file_name + '.decrypted'
with open(new_file_name, 'wb') as decrypted_file:
decrypted_file.write(decrypted_data)
But it doesn't work, I am not familar with code - -. I am only trying to decrypt bytes files in assets/AB/Android/gamedata/excel folder and repack them.
Hello,
Thank you for your tool that allows me to get the AB files already extracted!
Do you think in the future also do the opposite? I mean be able to recreate the AB file from the extracted file?
I have also already tried on my side starting from the skill_table.json file for example to obtain the skill_table.ab again, however I am a beginner in python and I do not know much about AES keys or Unity...
I was able to do this myself:
def text_asset_encrypt(stream, has_rsa: bool = True):
aes_obj = AES.new(b'UITpAi82pHAWwnzq', AES.MODE_CBC, bytearray(b'{\r\n "skcom_char'))
data = stream[128:] if has_rsa else stream
encrypt_buf = aes_obj.encrypt(pad(data[16:], 16))
return encrypt_buf
With :
- b'UITpAi82pHAWwnzq' : aes_key (get in decryption function for skill file only)
- bytearray(b'{\r\n "skcom_char') : aes_iv (get in decryption function for skill file only)
However, the reconstructed AB file is not identical to the original AB file...
Here is the code allowing me to try to encrypt the files again:
def pack(file_path_ab: Path, file_path_json: Path):
# with open(file_path_json, 'rb') as file:
with open(file_path_json, 'r') as file:
# Read file data
data = file.read()
dataUnserialized = json.dumps(data).encode('utf-8')
de = text_asset_encrypt(bytes(dataUnserialized))
# de = text_asset_encrypt(data)
shutil.copyfile(file_path_ab, file_path_json + '.ab')
env = UnityPy.load(str(file_path_json + '.ab'))
for obj in env.objects:
data = obj.read()
name = obj.type.name
if name == 'TextAsset':
with open(file_path_json + '.abb', 'wb') as f:
data.script = de
data.save()
# print(data.save())
f.write(env.file.save())
As you can see I am also trying to use JSON functions however I clearly don't know if my problem comes from the misuse of JSON functions, AES key, pad for key, Unity or somewhere else ...
Thanks in advance for your help,
Best regards,
Nyantasan59
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.