Blur (xb360) .pak/PAK2, .levelstream/ARCH

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
Tosyk
Posts: 81
Joined: Mon Aug 11, 2014 6:37 am

Re: Blur (xb360) .pak/PAK2, .levelstream/ARCH

Post by Tosyk »

Ekey wrote:You should be copy this part

Code: Select all

set MEMORY_FILE10 string "
void blur_decrypt(unsigned char* lpBuffer, int dwSize)
{
  unsigned char lpKey[14] = {0x78, 0x56, 0x58, 0x6F, 0x34, 0x30, 0x6A, 0x33, 0x40, 0x24, 0x25, 0x5C, 0x25, 0x60};
  for (int i = 0; i < dwSize; i++)
  {
     lpBuffer[i] ^= lpKey[(i + 1) % 14];
  }
}
"


instead of

Code: Select all

set MEMORY_FILE10 string
in this case I have the same message from qbms:
Image
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Blur (xb360) .pak/PAK2, .levelstream/ARCH

Post by aluigi »

@Tosyk
No, you didn't change anything because that error happens only with the incomplete command you used.
It's just a copy&paste, how did you mess it up?
Tosyk
Posts: 81
Joined: Mon Aug 11, 2014 6:37 am

Re: Blur (xb360) .pak/PAK2, .levelstream/ARCH

Post by Tosyk »

aluigi wrote:@Tosyk
No, you didn't change anything because that error happens only with the incomplete command you used.
It's just a copy&paste, how did you mess it up?

I'm sorry, I didn't knew it can be that hard. I have this script rn and I'm using it only on root.pak because all other paks are extractable with previous versions.

Code: Select all

# Blur (script 0.3.3)
#   note that I have tried to support multiple versions of the Blur
#   archives with the result of being possibly not 100% compatible
#   with some of them.
#   would be required a full rewrite for each version but finding
#   all the old files is a pain at the moment
#   in case of problems set WORK_AROUND to 1
# script for QuickBMS http://quickbms.aluigi.org

set MEMORY_FILE10 string "
void blur_decrypt(unsigned char* lpBuffer, int dwSize)
{
  unsigned char lpKey[14] = {0x78, 0x56, 0x58, 0x6F, 0x34, 0x30, 0x6A, 0x33, 0x40, 0x24, 0x25, 0x5C, 0x25, 0x60};
  for (int i = 0; i < dwSize; i++)
  {
     lpBuffer[i] ^= lpKey[(i + 1) % 14];
  }
}
"

# set WORK_AROUND to 1 if you get an error
math WORK_AROUND = 0

getdstring SIGN 4
if SIGN == "2KAP"
elif SIGN == "PAK2"
    comtype xmemdecompress
    endian big
else
    cleanexit
endif
if WORK_AROUND != 0
    string SIGN r SIGN
endif

get PAK_SIZE asize

get VERSION long
get MYALIGN long
goto 0x38
get NAMES_SIZE long
if NAMES_SIZE == 0
    goto MYALIGN
    get NAMES_SIZE long
endif

savepos OFFSET
log MEMORY_FILE OFFSET NAMES_SIZE
calldll MEMORY_FILE10 "blur_decrypt" "tcc" RET MEMORY_FILE NAMES_SIZE
math OFFSET += NAMES_SIZE
math OFFSET x= MYALIGN
goto OFFSET

get FILES long
get DUMMY long
get DUMMY long
for i = 0 < FILES
    get NAME_OFF long
    get DUMMY long
    get SIZE long
    get TIMESTAMP longlong
    get OFFSET longlong
    if SIGN == "2KAP"
        if VERSION >= 2
            get CHUNK_SIZE long
            get CHUNK_ZSIZE long
        endif
    endif
    get ZERO long
    if ZERO == 0
        getdstring DUMMY 0x18
    endif

    if OFFSET != -1
        math OFFSET *= MYALIGN
        savepos TMP
        goto OFFSET

        math CHUNK_SIZE  = 0x10000
        math CHUNK_ZSIZE = 0

        if SIGN == "PAK2"
            get CHUNK_ZSIZE long
            #math CHUNK_ZSIZE -= 4    # ???
            savepos OFFSET
            get CHUNK_SIZE long
            if CHUNK_SIZE != SIZE
                get CHUNK_ZSIZE long
            else
                goto OFFSET
            endif
        else
            get CHUNK_SIZE long
            if CHUNK_SIZE != SIZE
                comtype unzip_dynamic   #deflate
                get CHUNK_ZSIZE long
            else
                comtype unzip_dynamic   #zlib
                goto OFFSET
                if VERSION <= 1
                    get CHUNK_ZSIZE long
                endif
            endif
        endif

        savepos OFFSET

        # lame work-around for another gamedata.pak file
        if CHUNK_SIZE u> PAK_SIZE
            math OFFSET -= 8
            math CHUNK_SIZE = SIZE
            math CHUNK_ZSIZE = SIZE
        elif CHUNK_ZSIZE u> CHUNK_SIZE
            math OFFSET -= 4
            math CHUNK_ZSIZE = CHUNK_SIZE
        endif

        goto TMP

        goto NAME_OFF MEMORY_FILE
        get NAME string MEMORY_FILE

        math TMP = CHUNK_ZSIZE
        math TMP x= MYALIGN

        math TMP2 = PAK_SIZE
        math TMP2 -= OFFSET

        savepos TMP_OFF
        if SIZE == TMP
            if SIZE > TMP2
                math SIZE = TMP2
            endif
            log NAME OFFSET SIZE
        elif SIZE == CHUNK_ZSIZE
            if SIZE > TMP2
                math SIZE = TMP2
            endif
            if SIGN == "PAK2"
                log NAME OFFSET SIZE
            else
                clog NAME OFFSET SIZE SIZE
            endif
        else
            if i == 0
                # just a compression check
                if SIGN == "PAK2"
                    comtype zlib_noerror
                    clog MEMORY_FILE3 OFFSET CHUNK_ZSIZE SIZE
                    get XSIZE asize MEMORY_FILE3
                    if XSIZE < SIZE
                        comtype xmemdecompress
                    else
                        comtype unzip_dynamic   #zlib
                    endif
                endif
            endif

            putvarchr MEMORY_FILE2 SIZE 0
            log MEMORY_FILE2 0 0
            append
            for
                clog MEMORY_FILE2 OFFSET CHUNK_ZSIZE CHUNK_SIZE
                get MYSIZE asize MEMORY_FILE2
                if MYSIZE >= SIZE
                    break
                endif
                math OFFSET += CHUNK_ZSIZE
                goto OFFSET
                get CHUNK_ZSIZE long
                savepos OFFSET
            next
            append
            log NAME 0 SIZE MEMORY_FILE2
        endif
        goto TMP_OFF
    endif
next i