Skip to content
View in the app

A better way to browse. Learn more.

ResHax

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Help us keep the site running.

Help making a BMS script from a javascript code

Featured Replies

  • Author
  • Localization

gamelandresearch, posted Sun Oct 17, 2021 1:23 pm (67068)


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
  • Author
  • Localization

aluigi, posted Tue Nov 02, 2021 8:24 pm (67337)


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
  • Author
  • Localization

gamelandresearch, posted Thu Nov 04, 2021 1:33 am (67359)


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
Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.