Dogbyte Games "XPAK" Magic

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
squidiskool
Posts: 25
Joined: Wed Nov 04, 2020 2:05 pm

Dogbyte Games "XPAK" Magic

Post by squidiskool »

Is there a way to extract these? I'm looking to extract the files from Dogbyte Games' games. On iOS, it comes in "XPK" file format. On android, it's an obb file. They have the magic of "XPAK". Hmm... I can't find anything about this file. I was able to extract using offzip but I don't know what to do with the extracted files afterwards.
Sample: (Offroad Legends, iOS) https://www.mediafire.com/file/4xi26ah3 ... a.xpk/file
Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Re: Dogbyte Games "XPAK" Magic

Post by Ekey »

Data is encrypted
squidiskool
Posts: 25
Joined: Wed Nov 04, 2020 2:05 pm

Re: Dogbyte Games "XPAK" Magic

Post by squidiskool »

Oh. How do I decrypt it?
Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Re: Dogbyte Games "XPAK" Magic

Post by Ekey »

data xored by 0xAC54DF34 and compressed by Brotli

Image
Last edited by Ekey on Sun Mar 14, 2021 12:28 pm, edited 3 times in total.
squidiskool
Posts: 25
Joined: Wed Nov 04, 2020 2:05 pm

Re: Dogbyte Games "XPAK" Magic

Post by squidiskool »

nice, what coding is that?
wtf me I posted that on "zenhax", home of quickbms.
are you still working on it?
Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Re: Dogbyte Games "XPAK" Magic

Post by Ekey »

Currently no. I'm busy with my main job .. I can look it in next weekends. Maybe someone else can take a look in more detail about this format
Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Re: Dogbyte Games "XPAK" Magic

Post by Ekey »

DEV INFO
So. There are 2 types of archives:

xor key > 0xAC54DF34 (2891243316u)

[HEADER V0 + V1]

Code: Select all

struct XPAKHeader
{
   uint32_t   dwMagic;
   uint32_t   dwVersion; // 0 / 1 (LZMA)
   uint32_t   dwArchiveSize;
   byte   lpMD5[16]; // only present in versions above 0
   byte   lpLZMAProps[5]; // 4 bytes xored
   uint32_t dwTableZSize; // compressed size of table (xored)
};


[TABLE V0 + V1] (first dword is files count)

Code: Select all

struct XPAKTable
{
   uint32_t   dwFileNameLength;
   byte   lpFileName[dwFileNameLength];
   uint32_t   dwFileZSize;
   byte   bFlag; // if value > 3 = data is compressed
};


[HEADER V2]

Code: Select all

struct XPAKHeader
{
   uint32_t   dwMagic;
   uint32_t   dwVersion; // 2 (Brotli)
   uint32_t   dwArchiveSize;
   byte   lpMD5[16];
   uint32_t dwZero;
   uint32_t dwTableZSize; // compressed size of table (xored)
};


[TABLE V2] (first dword is files count)

Code: Select all

struct XPAKTable
{
   uint32_t   dwFileNameLength;
   byte   lpFileName[dwFileNameLength];
   uint32_t   dwFileZSize;
   byte   bFlag; // flag & 0x40 != 0
};


[DECRYPTION]

Code: Select all

void obfuscate(void *lpBuffer, int dwSize)
{
  signed int i; // r3@1
  int count; // r2@1 MAPDST

  i = 0;
  count = dwSize / 4;
  if ( count >= 4 )
    count = 4;
  while ( i < count )
  {
    ++i;
    *(DWORD *)lpBuffer ^= 0xAC54DF34;
    lpBuffer = (char *)lpBuffer + 4;
  }
}


Edited: Done
Last edited by Ekey on Wed Mar 17, 2021 2:38 pm, edited 5 times in total.
Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Re: Dogbyte Games "XPAK" Magic

Post by Ekey »

Done. I must admit, I could not implement a script for QuickBMS so I made batch tool for unpack on C# :mrgreen:

Code: Select all

[Usage]
    DB.XPAK.Unpacker <m_File> <m_OutDirectory>


Code: Select all

[Examples]
    DB.XPAK.Unpacker D:\main.33.com.dogbytegames.zombiesafari.obb D:\Unpacked


Supported V0, V1 and V2 archives. Unpack Only!

If someone needs a packer, then I attach the source code (yeah, I'm a lazy ass ¯\_(ツ)_/¯ )
Last edited by Ekey on Wed Mar 17, 2021 2:36 pm, edited 4 times in total.
squidiskool
Posts: 25
Joined: Wed Nov 04, 2020 2:05 pm

Re: Dogbyte Games "XPAK" Magic

Post by squidiskool »

Ekey wrote:Done. I must admit, I could not implement a script for QuickBMS so I made batch tool for unpack on C# :mrgreen:

Code: Select all

[Usage]
    DB.XPAK.Unpacker <m_File> <m_OutDirectory>


Code: Select all

[Examples]
    DB.XPAK.Unpacker D:\main.33.com.dogbytegames.zombiesafari.obb D:\Unpacked


Supported V1 and V2 archives. Unpack Only!

If someone needs a packer, then I attach the source code (yeah, I'm a lazy ass ¯\_(ツ)_/¯ )

Thanks! Wow, a lot of info! Works great on Offroad Legends iOS. Found out the PNGs that are actually not PNGs, they're actually PVR textures. Here's an example of Rainbow.
Image
Edit: Would be amazing if I can convert the models. They come in two formats, H3D and GEO. The H3D file looks to be an XML of some sort. The GEO file is not ASCII, and it has the MAGIC of "H3DG".
Another edit: They appear to be Horde3D model files.
Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Re: Dogbyte Games "XPAK" Magic

Post by Ekey »

squidiskool wrote:Thanks! Wow, a lot of info! Works great on Offroad Legends iOS.

Yup. Tool works on all the games from this company of those that I could find.
squidiskool
Posts: 25
Joined: Wed Nov 04, 2020 2:05 pm

Re: Dogbyte Games "XPAK" Magic

Post by squidiskool »

Ekey wrote:
squidiskool wrote:Thanks! Wow, a lot of info! Works great on Offroad Legends iOS.

Yup. Tool works on all the games from this company of those that I could find.

ALERT! I'm trying to extract the XPK from version 1.0 of Offroad Legends but I get this:
[ERROR]: Unsupported version > 0 < of XPAK archive file!
Can you look into it ?
H e r e : https://www.mediafire.com/file/77rmb8xv ... 9.xpk/file
Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Re: Dogbyte Games "XPAK" Magic

Post by Ekey »

Added V0 type :)
squidiskool
Posts: 25
Joined: Wed Nov 04, 2020 2:05 pm

Re: Dogbyte Games "XPAK" Magic

Post by squidiskool »

Ekey wrote:Added V0 type :)

Thanks, I was trying to get the old Wheely before it turned into a UAZ, for some reason.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Dogbyte Games "XPAK" Magic

Post by aluigi »

Well done Ekey.

I tried to make a quickbms script based on the source code of the tool (good occasion to spot bugs in my quickbms beta):
http://aluigi.org/bms/dogbyte_xpk.bms
squidiskool
Posts: 25
Joined: Wed Nov 04, 2020 2:05 pm

Re: Dogbyte Games "XPAK" Magic

Post by squidiskool »

aluigi wrote:Well done Ekey.

I tried to make a quickbms script based on the source code of the tool (good occasion to spot bugs in my quickbms beta):
http://aluigi.org/bms/dogbyte_xpk.bms

That does the job well too.
Karpati
Posts: 107
Joined: Wed Nov 12, 2014 1:46 pm

Re: Dogbyte Games "XPAK" Magic

Post by Karpati »

squidiskool wrote:Would be amazing if I can convert the models. They come in two formats, H3D and GEO. The H3D file looks to be an XML of some sort. The GEO file is not ASCII, and it has the MAGIC of "H3DG".
Another edit: They appear to be Horde3D model files.


I have finished my Horde3D Engine (v5;v6; Offroad Legends; Offroad Legends 2) *.GEO/*.SCENE.XML/*.MATERIAL.XML or *.GEO/*.H3D loader module and I have released the following programs as web updates:

- 3D Object Converter v7.047 (Windows)
- i3DConverter v3.905 (macOS)
- i3DConverter v1.905 (Linux)

How to get the 3D Object Converter v7.047:
Download the 3D Object Converter from http://3doc.i3dconverter.com and install it or download and use the portable version.
After it just use the Help/Check for updates... function to get the v7.047.

How to get the i3DConverter v3.905 macOS:
Download the i3DConverter from http://www.i3dconverter.com and install it.
After it just use the Help/Check for updates... function to get the v3.905.

How to get the i3DConverter v1.905 Linux:
Download the i3DConverter from http://www.i3dconverter.com and install it.
After it just use the Help/Check for updates... function to get the v1.905.
LukeAndBobPro
Posts: 1
Joined: Sun Jun 06, 2021 3:43 pm

Re: Dogbyte Games "XPAK" Magic

Post by LukeAndBobPro »

Ekey wrote:Added V0 type :)

Hey, I just downloaded the bin version of your software and I'm having a bit of a problem trying to extract the "data.xpk" file from the game, ya see every time I try to extract file, it doesn't seem to do anything, I mean I'm typing in the same command it tells me to type, am I missing a file or is it because I'm pressing the wrong buttons?
how do I use it?
squidiskool
Posts: 25
Joined: Wed Nov 04, 2020 2:05 pm

Re: Dogbyte Games "XPAK" Magic

Post by squidiskool »

Ekey wrote:Added V0 type :)

Need update, some png files that are extracted are corrupted and don't load :ugeek:
squidiskool
Posts: 25
Joined: Wed Nov 04, 2020 2:05 pm

Re: Dogbyte Games "XPAK" Magic

Post by squidiskool »

??
squidiskool
Posts: 25
Joined: Wed Nov 04, 2020 2:05 pm

Re: Dogbyte Games "XPAK" Magic

Post by squidiskool »

Hmm... When I compare between a working one and a corrupted one, it appears it has been encrypted. The corrupted one has a series of alphabet (sorry don't really know how to explain it)

Here's a link to one of the "corrupted" files:
https://drive.google.com/file/d/1ryzeua ... sp=sharing