How to split more than one file type from a single file?

Doubts, help and support about QuickBMS and other game research tools
reh
Posts: 48
Joined: Sun Apr 21, 2019 2:09 am

How to split more than one file type from a single file?

Post by reh »

I have a file that is about 2G in size and there are several concatenated files.

Code: Select all

findloc OFFSET string "MDL4"
do
    goto OFFSET
    get DUMMY long
    findloc NEXT_OFFSET string "MDL4" 0 ""
    if NEXT_OFFSET == ""
        get SIZE asize
    else
        math SIZE = NEXT_OFFSET
    endif
    math SIZE -= OFFSET
    log "" OFFSET SIZE
    math OFFSET = NEXT_OFFSET
while NEXT_OFFSET != ""


With this script, the file is divided by the desired type, but it looks for only one type of file and the other types are concatenated together with the extracted files.

Is it possible to extract all types of files separately or to ensure that the script does not include the other types in the extracted files?

Each file type is separated by empty bytes. I will attach an example of a file extracted by the script, where it is possible to find the other file types (MDL4, MTX, MOT).
000000aa.zip

I thank you for your help!
Acewell
Posts: 706
Joined: Fri Aug 08, 2014 1:06 am

Re: How to split more than one file type from a single file?

Post by Acewell »

reh wrote:Is it possible to extract all types of files separately or to ensure that the script does not include the other types in the extracted files?

if you want just the mdl files without the other appended files use this:

Code: Select all

findloc OFFSET string "MDL4"
do
    goto OFFSET
    goto 8 0 seek_cur
    get SIZE long
    findloc NEXT_OFFSET string "MDL4" 0 ""
    log "" OFFSET SIZE
    math OFFSET = NEXT_OFFSET
while NEXT_OFFSET != ""

:D
reh
Posts: 48
Joined: Sun Apr 21, 2019 2:09 am

Re: How to split more than one file type from a single file?

Post by reh »

Acewell wrote:
reh wrote:Is it possible to extract all types of files separately or to ensure that the script does not include the other types in the extracted files?

if you want just the mdl files without the other appended files use this:

Code: Select all

findloc OFFSET string "MDL4"
do
    goto OFFSET
    goto 8 0 seek_cur
    get SIZE long
    findloc NEXT_OFFSET string "MDL4" 0 ""
    log "" OFFSET SIZE
    math OFFSET = NEXT_OFFSET
while NEXT_OFFSET != ""

:D


Thank you so much Acewell !!
Another question, how do I delete all the bytes that look like:\ x0F \ x00 \ x00 \ x00 \ xFF \ xFF \ xFF \ xFF \ x00 \ x00 \ x00 \ x00 \ x01 \ x00 \ x00 \ x00 end \ x0F \ x00 \ x00 \ x00 \ xFF \ xFF \ xFF \ xFF \ x01 \ x00 \ x00 \ x00 \ x01 \ x00 \ x00 \ x00 in the file?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: How to split more than one file type from a single file?

Post by aluigi »

You can try Encryption replace for that job, in theory it should work:

Code: Select all

get SIZE asize
encryption replace "\x0F\x00\x00\x00\xFF\xFF\xFF\xFF\x00\x00\x00\x00\x01\x00\x00\x00" ""
log "output.dat" 0 SIZE
And then doing the same with the other sequence of bytes.
reh
Posts: 48
Joined: Sun Apr 21, 2019 2:09 am

Re: How to split more than one file type from a single file?

Post by reh »

aluigi wrote:You can try Encryption replace for that job, in theory it should work:

Code: Select all

get SIZE asize
encryption replace "\x0F\x00\x00\x00\xFF\xFF\xFF\xFF\x00\x00\x00\x00\x01\x00\x00\x00" ""
log "output.dat" 0 SIZE
And then doing the same with the other sequence of bytes.


Thank you, it worked very well.