Giter Site home page Giter Site logo

arkassetstool's People

Contributors

chaomengcfx avatar tkkcc avatar yuanyan3060 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

arkassetstool's Issues

Not sure how to use it on downloaded file.

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.

[New feature idea] Repack AB files from extracted files

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.