ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Sun Nov 28, 2021 6:17 pm

All times are UTC




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sun Oct 17, 2021 1:23 pm 

Joined: Sun Feb 09, 2020 11:35 am
Posts: 10
Sorry this is kinda a noob question but the only code I could somewhat understand is QuickBMS so i'm trying make this one work on QuickBMS...

Code:
let mRandom;

function getNextRandom() {
    mRandom ^= mRandom << 21;
    mRandom ^= mRandom >>> 35;
    mRandom ^= mRandom << 4;
   
    if (mRandom < 0)
        mRandom &= 2147483647;
   
    return mRandom / 2147483647;
}

function decryptPackage(bytes) {
    let view = new DataView(bytes);
   
    mRandom = 56895 & 25147 >> 1;
   
    for (let i = Math.min(view.byteLength, 65536) - 1; i >= 0; i -= 2)
        view.setInt8(i, view.getInt8(i) - Math.floor(getNextRandom() * 255));
   
    for (let i = view.byteLength - 1; i >= 0; i -= Math.floor(getNextRandom() * 255))
        view.setInt8(i, view.getInt8(i) - Math.floor(getNextRandom() * 255));
   
    for (let i = view.byteLength - 1; i >= Math.max(view.byteLength, 65536) - 65536; i -= 2)
        view.setInt8(i, view.getInt8(i) - Math.floor(getNextRandom() * 255));
   
    mRandom = 0;
    return bytes;
}


This code from Angry Birds Flash, I don't know how to convert


Top
   
PostPosted: Tue Nov 02, 2021 8:24 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 12569
The only way would be to implement it as a C function to call with calldll or with Encryption calldll.

The only doubt I have is about mRandom which is not clear if it's a 64bit or not, indeed I guess the script will not work correctly:
Code:
set MEMORY_FILE10 string "

long long mRandom = 0;

int Math_min(int a, int b) {
    if(a < b) return a;
    return b;
}
int Math_max(int a, int b) {
    if(a > b) return a;
    return b;
}

int getNextRandom() {
    mRandom ^= mRandom << (long long)21;
    mRandom ^= (unsigned long long)mRandom >> (unsigned long long)35;
    mRandom ^= mRandom << (long long)4;
   
    if (mRandom < 0)
        mRandom &= 2147483647;
   
    return mRandom / 2147483647;
}

void decryptPackage(unsigned char *view, int view_byteLength) {
    //int view = new DataView(bytes);
    int i;
   
    mRandom = 56895 & 25147 >> 1;
   
    for (i = Math_min(view_byteLength, 65536) - 1; i >= 0; i -= 2)
        view[i] -= (getNextRandom() * 255);
   
    for (i = view_byteLength - 1; i >= 0; i -= (getNextRandom() * 255))
        view[i] -= (getNextRandom() * 255);
   
    for (i = view_byteLength - 1; i >= Math_max(view_byteLength, 65536) - 65536; i -= 2)
        view[i] -= (getNextRandom() * 255);
   
    mRandom = 0;
}
"

get SIZE asize
log MEMORY_FILE 0 SIZE
calldll MEMORY_FILE10 decryptPackage tcc RET MEMORY_FILE SIZE
log "dump.dat" 0 SIZE MEMORY_FILE


Top
   
PostPosted: Thu Nov 04, 2021 1:33 am 

Joined: Sun Feb 09, 2020 11:35 am
Posts: 10
I tried to decrypt .pak but I got error, can you fix also don't forget to add both deflate and zlib compression after decrypting .pak


Attachments:
File comment: Here's .pak from Angry Birds in Ultrabook™ Adventure game
core.pak [427.88 KiB]
Downloaded 22 times
Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC


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:
Powered by phpBB® Forum Software © phpBB Limited