XeNTaX Forum Index
Forum MultiEx Commander Tools Tools Home
It is currently Sun Sep 24, 2017 7:53 am

All times are UTC + 1 hour


Forum rules


Please click here to view the forum rules



Post new topic Reply to topic  [ 52 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: [Mobile] Kingdom Hearts Unchained file archives
PostPosted: Thu Apr 07, 2016 10:18 am 
Offline
advanced

Joined: Wed Jun 23, 2010 10:12 pm
Posts: 60
Has thanked: 18 times
Have thanks: 2 times














You can make the ads go away by registering

Kingdom Hearts Unchained seems to use two files to store almost all gameplay elements: misc.mp4 and misc.png. The files originally used in the install archive are enlarged whenever there is an update, the post-installation file download increases their size a hundred times.

The question is how they work, the smaller file is probably referencing stuff in the bigger one, but beyond that I'm clueless where to start.

Since the game is free2play it shouldn't be a problem linking these two files (ca. 20 MB) here:
http://www10.zippyshare.com/v/YhnYeNaS/file.html

The original apk file containing these files can be downloaded here:
https://apkpure.com/store/apps/details? ... lay.khuxww

If there is interest in the larger post-installation files (over 1 GB), I could upload them too.


Top
 Profile  
 
 Post subject: Re: [Mobile] Kingdom Hearts Unchained file archives
PostPosted: Sat Apr 09, 2016 8:11 pm 
Offline
ultra-n00b

Joined: Sat Apr 09, 2016 7:53 pm
Posts: 4
Has thanked: 0 time
Have thanks: 0 time
What more can I say than, PLEASE FOR THE LOVE OF GOD, POST THE FILES. I've spent the entire time since the NA version came out trying to figure out how to get it on my phone, and long story short, I need the post-install files. All of it. The entire "data/data/com" square enix whatever folder. Also, PLEASE don't make an account/avatar before exporting the files, because the account and save data carries over inside of the misc.mp4 file, and I could not find a way to delete said account by itself. I found an upload of all the files by someone on some jank, ad-filed website I don't care to remember the name of, only to get screwed over by that revelation. It needs to be clean, so people savvy enough to go through the process can go right in on their own accounts.


Top
 Profile  
 
 Post subject: Re: [Mobile] Kingdom Hearts Unchained file archives
PostPosted: Sun Apr 10, 2016 6:00 am 
Offline
advanced
User avatar

Joined: Mon Oct 06, 2014 7:22 am
Posts: 44
Has thanked: 1 time
Have thanks: 27 times
The misc.mp4 file contains multiple archives

Code:
struct BGADArchive {
    int magic;
    short unk0;
    short unk1;
    short headerSize;
    short extensionSize;
    short unk2;
    short unk3;
    int dataSize;
    int unknownSize;
};

To get the next archive in the misc.mp4 file, just keep adding an offset of headerSize + extensionSize + dataSize

Example C code: https://db.tt/dMIdazju
Hope this helps a bit


Top
 Profile  
 
 Post subject: Re: [Mobile] Kingdom Hearts Unchained file archives
PostPosted: Sun Apr 10, 2016 8:04 pm 
Offline
ultra-n00b

Joined: Sat Apr 09, 2016 7:53 pm
Posts: 4
Has thanked: 0 time
Have thanks: 0 time
MayBeePah wrote:
The misc.mp4 file contains multiple archives

Code:
struct BGADArchive {
    int magic;
    short unk0;
    short unk1;
    short headerSize;
    short extensionSize;
    short unk2;
    short unk3;
    int dataSize;
    int unknownSize;
};

To get the next archive in the misc.mp4 file, just keep adding an offset of headerSize + extensionSize + dataSize

Example C code: https://db.tt/dMIdazju
Hope this helps a bit

If that was directed towards me, sorry, but I don't know anything about scripting. More to the point, all I want is to copy-paste the full "data/com.squareenix" yada yada whatever folder in directly, because that jank file I mentioned proved to me that the game can recognize the files properly when you do that. Problem is, that file already had an account made, at level 15, no less.

I need a clean folder of files, because misc.mp4 is larger than my phone's entire cache folder, meaning it's impossible for me to download it myself. My phone can't store app data on the external SD Card for some stupid manufacturing cost-saving reason, and I've bricked my phone multiple times trying to do all this ever since the NA version came out. I've asked on KH13, KHInsider, Reddit, and more, but everyone just ignores me, so I'm very annoyed at this point. I just, need, the files, please.


Top
 Profile  
 
 Post subject: Re: [Mobile] Kingdom Hearts Unchained file archives
PostPosted: Mon Apr 11, 2016 12:21 am 
Offline
advanced

Joined: Wed Jun 23, 2010 10:12 pm
Posts: 60
Has thanked: 18 times
Have thanks: 2 times
Thank you MayBeePah, I'll try to make sense of it. Were you able to extract one of the archives in the misc.mp4?

@ggbhtg: I uploaded all files here:
http://www.share-online.biz/dl/GE20MF5OETM
http://www.share-online.biz/dl/2KGQOF5OS8O6
http://www.share-online.biz/dl/67HSUF5OQ8X
http://www.share-online.biz/dl/Q2ILXF5O8M

It's four parts because my internet connection is not that good and gets cut sometimes. It's packed with 7-zip, I didn't click on anything after the download started so hopefully this will help you. You could always get these files with an android emulator yourself though.


Top
 Profile  
 
 Post subject: Re: [Mobile] Kingdom Hearts Unchained file archives
PostPosted: Mon Apr 11, 2016 4:02 am 
Offline
ultra-n00b

Joined: Sat Apr 09, 2016 7:53 pm
Posts: 4
Has thanked: 0 time
Have thanks: 0 time
Azurfan wrote:
Thank you MayBeePah, I'll try to make sense of it. Were you able to extract one of the archives in the misc.mp4?

@ggbhtg: I uploaded all files here:
http://www.share-online.biz/dl/GE20MF5OETM
http://www.share-online.biz/dl/2KGQOF5OS8O6
http://www.share-online.biz/dl/67HSUF5OQ8X
http://www.share-online.biz/dl/Q2ILXF5O8M

It's four parts because my internet connection is not that good and gets cut sometimes. It's packed with 7-zip, I didn't click on anything after the download started so hopefully this will help you. You could always get these files with an android emulator yourself though.


THANK. YOU. I can't use an emulator because I don't have my own computer. It's gonna take a while to retrieve on my own crap internet connection, but I'll definitely post my results tomorrow.


Top
 Profile  
 
 Post subject: Re: [Mobile] Kingdom Hearts Unchained file archives
PostPosted: Tue Apr 12, 2016 5:28 am 
Offline
ultra-n00b

Joined: Sat Apr 09, 2016 7:53 pm
Posts: 4
Has thanked: 0 time
Have thanks: 0 time
Ok....unfortunately, I still can't get the game to actually run. Why? Because I get a "logged out due to inactivity" error. If I copy paste in certain files, this error message triggers and locks me into the title screen. Misc.mp4 isn't one of these files, but there's still a big issue here.

Initially, I seemed to circumvent this by installing the game without pasting in your files first, extracted cookieFile.txt, then pasted it over your cookies that seem to just become invalid to the game after a period of time. I've not done research yet to know if this is a known issue. HOWEVER, even though I got the game to run using this fix, and made it all the way to avatar creation and clan selection, the game spontaneously gave me the "inactivity" error anyway.

So right now, I'm trying to figure out which combination of files will actually let the game run, hoping that this isn't caused by that Permission I had to remove in order to get the apk to even install.

The worst part? This error also cause the game's data files to completely self-destruct on my end. That means I have to keep going back and forth on my phone to try different variations of using your files and fresh files from the game to trick itself into running properly...and every time I'm wrong, I have to uninstall and reinstall the app from scratch and twiddle my thumbs while that 1GB misc file transfers.

It also doesn't help that there's a specific file(s) that detects whether you have the misc files and whatever else is in the download. This file decides you don't actually have the download, gives a "storage space error" when you try and start the game, because it wants to download everything from scratch, then blows up all your app's files like the inactivity error.


Top
 Profile  
 
 Post subject: Re: [Mobile] Kingdom Hearts Unchained file archives
PostPosted: Wed Apr 13, 2016 6:36 am 
Offline
advanced
User avatar

Joined: Mon Oct 06, 2014 7:22 am
Posts: 44
Has thanked: 1 time
Have thanks: 27 times
I can decrypt and uncompress the archive with names now :)
But the images and some other files are custom formats (PNGs are compressed). I'll figure them out soon...


Attachments:


You do not have the required permissions to view the files attached to this post. Register to gain access.



Top
 Profile  
 
 Post subject: Re: [Mobile] Kingdom Hearts Unchained file archives
PostPosted: Wed Apr 13, 2016 10:48 am 
Offline
advanced

Joined: Wed Jun 23, 2010 10:12 pm
Posts: 60
Has thanked: 18 times
Have thanks: 2 times
Omg, you are my hero MayBeePah.


Top
 Profile  
 
 Post subject: Re: [Mobile] Kingdom Hearts Unchained file archives
PostPosted: Wed Apr 13, 2016 11:54 am 
Offline
ultra-n00b
User avatar

Joined: Tue Apr 12, 2016 10:05 am
Posts: 1
Has thanked: 1 time
Have thanks: 1 time
Dumb question, but would it be possible to get the player character body parts(hair, faces, limbs, outfits, etc) extracted? I realized they could probably be used in animations and neat stuff like that.


Top
 Profile  
 
 Post subject: Re: [Mobile] Kingdom Hearts Unchained file archives
PostPosted: Fri Apr 15, 2016 8:43 am 
Offline
n00b

Joined: Thu Jul 01, 2010 8:46 pm
Posts: 14
Has thanked: 1 time
Have thanks: 0 time
MayBeePah wrote:
I can decrypt and uncompress the archive with names now :)
But the images and some other files are custom formats (PNGs are compressed). I'll figure them out soon...


Could you share more on how you were able to get the file names? The game appears to be using the cocos2d-x sdk. It may use "VP8L" as an image format. I'm not sure if they would use Google's WebP though since it's unconventional.


Top
 Profile  
 
 Post subject: Re: [Mobile] Kingdom Hearts Unchained file archives
PostPosted: Sun Apr 24, 2016 11:05 am 
Offline
advanced
User avatar

Joined: Mon Oct 06, 2014 7:22 am
Posts: 44
Has thanked: 1 time
Have thanks: 27 times
Sorry, I've been busy and I forgot to work on Unchained.
I haven't got time at the moment to continue but here's the decryption algorithm if anyone wants to try:

Code:
#define BGADMagic 0x44414742

int khux_random(int seed) {
    return 0x19660D * seed + 0x3C6EF35F;
}

void khux_decrypt(int* data, int length, int key) {
    int i = 0;
    int count = (length + 3) >> 2;
   
    while (i < count) {
        key = khux_random(key);
        data[i] ^= key;
        i++;
    }
}

struct BGAD {
    int magic;
    short key_type;
    short unk;
    short header_size;
    short name_length;
    short data_type;
    short is_compressed;
    int data_size;
    int decompressed_size;
   
    //char name[nameLength];
    //char data[dataSize];
   
    /* how to:
        decrypt name: khux_decrypt(&name, name_length, data_size)
        decrypt data: khux_decrypt(&data, data_size, name_length)
     
        calculate offset to next BGAD file: header_size + name_length + data_size
     
        validate: magic == BGADMagic
     
        after decryption use zlib to decompress:
            if (is_compressed) {
                void* decompressed_buffer = malloc(decompressed_size);
                uncompress(decompressed_buffer, &decompressed_size, &data, data_size)
            }
     */
};


Top
 Profile  
 
 Post subject: Re: [Mobile] Kingdom Hearts Unchained file archives
PostPosted: Wed May 18, 2016 6:14 pm 
Offline
advanced

Joined: Wed Jun 23, 2010 10:12 pm
Posts: 60
Has thanked: 18 times
Have thanks: 2 times
Okay I tried but failed, getting the decryption to work seems to be way out of my league. Did anyone here had more luck with it?


Top
 Profile  
 
 Post subject: Re: [Mobile] Kingdom Hearts Unchained file archives
PostPosted: Fri May 20, 2016 12:19 am 
Offline
advanced
User avatar

Joined: Mon Oct 06, 2014 7:22 am
Posts: 44
Has thanked: 1 time
Have thanks: 27 times
This should extract every file in the misc.mp4 file
I just made this quickly so tell me if anything went wrong :)

requires zlib
usage: khux_decrypt .../misc.mp4 .../'directory name'

Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <zlib.h>
#include <sys/stat.h>

#define BGADMagic 0x44414742
#define BGADSize sizeof(struct BGAD)
#define BGADMaxNameLength 0x100
#define BGADMaxDataSize 0x1000000

#define false 0
#define true 1

#define CatchError(condition) if (condition) { return false; }
#define Read(ptr, size) CatchError(fread(ptr, size, 1, file) != 1)

int khux_random(int seed) {
    return 0x19660D * seed + 0x3C6EF35F;
}

void khux_decrypt(int* data, int length, int key) {
    int count = (length + 3) >> 2;
   
    for (int i=0; i<count; i++) {
        key = khux_random(key);
        data[i] ^= key;
    }
}

struct BGAD {
    int magic;
    short key_type;
    short unk;
    short header_size;
    short name_length;
    short data_type;
    short is_compressed;
    int data_size;
    int decompressed_size;
};

struct BGADInfo {
    struct BGAD header;
    void* name;
    void* data;
    void* decompressed;
};

typedef struct BGADInfo BGADInfo;

void BGADInfoInit(BGADInfo* info) {
    info->name = malloc(BGADMaxNameLength);
    info->data = malloc(BGADMaxDataSize);
    info->decompressed = malloc(BGADMaxDataSize);
}

void BGADDecryptName(BGADInfo* info) {
    khux_decrypt(info->name, info->header.name_length, info->header.data_size);
   
    ((char*)info->name)[info->header.name_length] = 0;
}

void BGADDecryptData(BGADInfo* info) {
    khux_decrypt(info->data, info->header.data_size, info->header.name_length);
   
    if (info->header.is_compressed) {
        unsigned long int size = info->header.decompressed_size;
        uncompress(info->decompressed, &size, info->data, info->header.data_size);
    }
}

int ReadBGAD(FILE* file, BGADInfo* info) {
    Read(&info->header, BGADSize)
   
    CatchError(info->header.magic != BGADMagic)
    CatchError(info->header.name_length > BGADMaxNameLength)
   
    Read(info->name, info->header.name_length)
    BGADDecryptName(info);

    CatchError(info->header.data_size > BGADMaxDataSize)
    CatchError(info->header.decompressed_size > BGADMaxDataSize)
   
    Read(info->data, info->header.data_size)
    BGADDecryptData(info);

    return true;
}

void WriteBGAD(FILE* file, BGADInfo* info) {
    void* ptr = info->header.is_compressed
        ? info->decompressed
        : info->data;
   
    int size  = info->header.is_compressed
        ? info->header.decompressed_size
        : info->header.data_size;
   
    fwrite(ptr, size, 1, file);
}

void CreateDirectories(char** base, char* directories) {
    char* directory = strtok(directories, "/");
    char* next_directory;
   
    mkdir(*base, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
   
    while (directory != NULL) {
        next_directory = strtok(NULL, "/");
   
        strncat(*base, "/", 1);
        strncat(*base, directory, strlen(directory));
       
        if (next_directory != NULL) {
            mkdir(*base, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
        }
       
        directory = next_directory;
    }
}

int main(int argc, const char * argv[]) {
    setbuf(stdout, NULL);
   
    char* in_path = (char*)argv[1];
    char* out_path = (char*)argv[2];
    unsigned long out_path_len = strlen(out_path);
   
    FILE* file = fopen(in_path, "r");
    BGADInfo* info = malloc(sizeof(BGADInfo));
    BGADInfoInit(info);
   
    char* write_path = malloc(0x100);
   
    while (ReadBGAD(file, info)) {
        memset(write_path, 0, 0x100);
        strncat(write_path, out_path, out_path_len);
       
        CreateDirectories(&write_path, info->name);
   
        FILE* out_file = fopen(write_path, "w");
        CatchError(out_file == NULL)
       
        WriteBGAD(out_file, info);
        fclose(out_file);
    }
   
    fclose(file);
   
    return 0;
}


Top
 Profile  
 
 Post subject: Re: [Mobile] Kingdom Hearts Unchained file archives
PostPosted: Sat May 21, 2016 8:48 am 
Offline
ultra-n00b

Joined: Fri May 20, 2016 4:11 pm
Posts: 3
Has thanked: 1 time
Have thanks: 0 time
Would a compiled version be too much to ask for? I made some quick attempts that didn't work out, so I would be really thankful for one.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 52 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group