string convert

Doubts, help and support about QuickBMS and other game research tools
chrrox
Posts: 388
Joined: Thu Aug 07, 2014 10:28 pm

string convert

Post by chrrox »

I am trying to convert the string "e8fc9029" to an int
when I do
set KEY0 string "e8fc9029"
set TMP string "$"
string TMP += KEY0
set KEY0 long TMP
I get 0xFFFFFFFFE8FC9029
how do I make it get the unsigned version of the number so its
0xE8FC9029
chrrox
Posts: 388
Joined: Thu Aug 07, 2014 10:28 pm

Re: string convert

Post by chrrox »

I am getting an different results when I don't hard code the key.

Code: Select all

quickbmsver "0.8.0"
set MEMORY_FILE10 string "
typedef unsigned char uchar;
typedef unsigned int uint;

int ll_decrypt(unsigned char *data, int size, int keys_0, int keys_1, int keys_2) {
    int     i;
    for(i = 0; i < size; i++) {
        uchar c = data[i];
        data[i] = data[i] ^ (((keys_1 ^ keys_0 ^ keys_2) >> 24) & 0xff);
        keys_0 = (0x343fd * keys_0 + 0x269ec3) & 0xFFFFFFFF;
        keys_1 = (0x343fd * keys_1 + 0x269ec3) & 0xFFFFFFFF;
        keys_2 = (0x343fd * keys_2 + 0x269ec3) & 0xFFFFFFFF;
    }
}
"

set URLBASE string "https://jp-real-prod-v4tadlicuqeeumke.api.game25.klabgames.net/ep1002/static/f141c313a139e1e6/"
open "." "https://jp-real-prod-v4tadlicuqeeumke.api.game25.klabgames.net/ep1002/static/f141c313a139e1e6/masterdata_a_ja"
get SIZE asize
log MEMORY_FILE 0 SIZE
goto 0x14 MEMORY_FILE
get NSIZE byte MEMORY_FILE
getdstring VERSION NSIZE MEMORY_FILE
get NSIZE byte MEMORY_FILE
getdstring LANG NSIZE MEMORY_FILE
get FILES byte MEMORY_FILE
print "%VERSION% %LANG% %FILES%"
for i = 0 < files
math constKeys_0 =   0x3039  // 12345
math constKeys_1 =   0x10932 // 67890
math constKeys_2 =   0x7AB7  // 31415
set MEMORY_FILE2 ""
get NSIZE byte MEMORY_FILE
getdstring FNAME NSIZE MEMORY_FILE
get NSIZE byte MEMORY_FILE
getdstring KEY0 8 MEMORY_FILE
getdstring KEY1 8 MEMORY_FILE
getdstring KEY2 8 MEMORY_FILE
getdstring CRC 16 MEMORY_FILE
print "%FNAME% %KEY0% %KEY1% %KEY2% %CRC%"
set TMP string "$"
string TMP += KEY0
set KEY0 long TMP

set TMP string "$"
string TMP += KEY1
set KEY1 long TMP

set TMP string "$"
string TMP += KEY2
set KEY2 long TMP

set URL URLBASE
string URL + FNAME
print "Downloading %URL%"
xmath keys_0 "constKeys_0 ^ KEY0"
xmath keys_1 "constKeys_1 ^ KEY1"
xmath keys_2 "constKeys_2 ^ KEY2"
open "." URL
get SIZE asize
log MEMORY_FILE2 0 SIZE
calldll MEMORY_FILE10 "ll_decrypt" "tcc" RET MEMORY_FILE2 SIZE keys_0 keys_1 keys_2
string FNAME + ".decrypt"
log FNAME 0 SIZE MEMORY_FILE2
next i


chrrox
Posts: 388
Joined: Thu Aug 07, 2014 10:28 pm

Re: string convert

Post by chrrox »

The strings that convert the keys to all positive integers decrypt fine.


seems to work fine with 64 bit quickbms any way to make it work in 32 also?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: string convert

Post by aluigi »

The output is the same for both quickbms and quickbms_4gb_files.

I tried your script in the first post and I correctly get 0x00000000e8fc9029 with quickbms_4gb_files.
chrrox
Posts: 388
Joined: Thu Aug 07, 2014 10:28 pm

Re: string convert

Post by chrrox »

The xor output is wrong unless I use the 4gb file version
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: string convert

Post by aluigi »

I used the second script with both quickbms.exe and quickbms_4gb_files.exe and the output was identical.
chrrox
Posts: 388
Joined: Thu Aug 07, 2014 10:28 pm

Re: string convert

Post by chrrox »

I can't get this script to work with original quickbms.exe
viewtopic.php?f=9&t=12657
Might be due to the multiplication done in the xor function?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: string convert

Post by aluigi »

It's the same script posted above, the same I already tried and gave the same output with quickbms and quickbms_4gb_files.

Anyway that URL is now returning 404