Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not sure how to use it on downloaded file. #4

Open
Michaelwhite34 opened this issue Jun 25, 2023 · 0 comments
Open

Not sure how to use it on downloaded file. #4

Michaelwhite34 opened this issue Jun 25, 2023 · 0 comments

Comments

@Michaelwhite34
Copy link

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)

Get the current folder path

folder_path = os.getcwd()

Get all files in the current folder

file_list = os.listdir(folder_path)

Decrypt each byte file in the folder

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant