generate xor pad

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

generate xor pad

Post by chrrox »

is there a way to generate a xor pad fast in qickbms.
it starts at 0 and keeps going higher till the size of the file every 16 bytes like this.
Image
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: generate xor pad

Post by aluigi »

Fast? uhmmm no.
It depends by how long it should be your xor pad, if it has a limited short size you can build it by hand but if that is supposed to be unlimited (as I think) then it's complicated.
chrrox
Posts: 388
Joined: Thu Aug 07, 2014 10:28 pm

Re: generate xor pad

Post by chrrox »

fastest way would be initialize as 0 the file size then use c program to modify values?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: generate xor pad

Post by aluigi »

A C function for performing the decryption would be good.
Do you mean something like the following?

Code: Select all

set MEMORY_FILE10 string "
void decrypt(unsigned char *data, int size) {
    int i, c;
    for(i = 0; i < size; i++) {
        c = i >> 4;
        switch(i & 15) {
            case 0:            break;
            case 1:  c >>= 8;  break;
            case 2:  c >>= 16; break;
            case 3:  c >>= 24; break;
            default: c = 0;
        }
        data[i] ^= c;
    }
}
"

get SIZE asize
log MEMORY_FILE 0 SIZE
calldll MEMORY_FILE10 decrypt tcc RET MEMORY_FILE SIZE
log "dump.dat" 0 SIZE MEMORY_FILE
chrrox
Posts: 388
Joined: Thu Aug 07, 2014 10:28 pm

Re: generate xor pad

Post by chrrox »

That worked great