Indivisible .pkg

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
bonder
Posts: 16
Joined: Tue Oct 08, 2019 10:02 pm

Indivisible .pkg

Post by bonder »

Trying to decrypt and unpack Indivisible (PC)'s .pkg archives. Very new at this so not sure what to do.
Here are downloads for the executable and data_1.pkg.
Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Re: Indivisible .pkg

Post by Ekey »

Data is xored with very long key (1779080 bytes) - attached. Format: here. Files are compressed with LZ4
bonder
Posts: 16
Joined: Tue Oct 08, 2019 10:02 pm

Re: Indivisible .pkg

Post by bonder »

Ekey wrote:Data is xored with very long key (1779080 bytes) - attached. Format: here. Files are compressed with LZ4

Thank you! I've tried running the skullgirls bms script but nothing happens. How do I apply the key? Sorry, I'm very new at this.
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Indivisible .pkg

Post by aluigi »

@Ekey
Are you sure about the key?
The data from offset 0x19EF55 is wrong.

Anyway this is the script once the file is decrypted:

Code: Select all

# Indivisible PKG / Reverge Package File
#   thanks Ekey https://zenhax.com/viewtopic.php?p=51405#p51405
#   FILE MUST BE DECRYPTED!

endian big
get OFFSET long

get NAMESZ longlong
getdstring NAME NAMESZ
if NAME & "Reverge"
else
    print "Error: unknown package file: %s" NAME
    cleanexit
endif

get NAMESZ longlong
getdstring NAME NAMESZ

get FILES longlong
for i = 0 < FILES
    get NAMESZ longlong
    getdstring NAME NAMESZ
    get SIZE longlong
    get DUMMY long  # 1
    log NAME OFFSET SIZE
    math OFFSET + SIZE
next i
Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Re: Indivisible .pkg

Post by Ekey »

Seems compressed data also xored with this key. if interested, I attached pseudo-code for key generation and data decompression.
Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Re: Indivisible .pkg

Post by Ekey »

aluigi wrote:@Ekey
Are you sure about the key?
The data from offset 0x19EF55 is wrong.


Key are correct. Here a solution. Check this, works fine for me :)

Code: Select all

void lpDecrypt(BYTE* lpBuffer, DWORD dwSize)
{
  for (int i = 0; i < dwSize; i++)
  {
    lpBuffer[i] ^= lpKey[i % 1779072]; //v7 = v6 - 8;
  }
}
yuxin123
Posts: 13
Joined: Mon Oct 14, 2019 6:31 am

Re: Indivisible .pkg

Post by yuxin123 »

hi,@Ekey

I found your name in the dzs_qq.bms script. I got troblem with the filenames while extracting asura vfs fileshttps://www.zenhax.com/viewtopic.php?f=13&t=12656, as aluigi said something like codepage is wrong. I tried as much as I can then dont know waht to do.

Really wish you can help me.
vfs file:https://drive.google.com/open?id=1xchzvob3um5jP5gRajrYo8vZzD6BqGOG
bonder
Posts: 16
Joined: Tue Oct 08, 2019 10:02 pm

Re: Indivisible .pkg

Post by bonder »

The key worked fine for decrypting the main PKGs, but now I'm stuck again trying to get into these .lz4 files. Here is an upload from the data2.pkg, of Latigo's cutscene textures. What is my next step?
Szkaradek123
Posts: 124
Joined: Sat Aug 29, 2015 1:13 pm

Re: Indivisible .pkg

Post by Szkaradek123 »

Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Re: Indivisible .pkg

Post by Ekey »

Szkaradek123 wrote:Hi
Need help to decrypt lz4 files

sample:
http://www.mediafire.com/file/046i0vljx ... s.lz4/file

and here decrypted pkg
http://www.mediafire.com/file/7rhxy91q3 ... crypt/file

Your files are not fully decrypted. Here is my solution.

1) Decrypt PKG's with utility -> IPKGDecryptor (here). Usage as always simple:

Example

Code: Select all

IPKGDecryptor e:\Games\Indivisible\pkgs\data_1.pkg


2) Use a new script below on PKG with prefix _decrypted
3) Profit.

Code: Select all

# Indivisible PKG / Reverge Package File
#   thanks Ekey https://zenhax.com/viewtopic.php?p=51405#p51405
#   FILE MUST BE DECRYPTED! Use IPKGDecryptor https://zenhax.com/viewtopic.php?p=52847#p52847

endian big
get OFFSET long

get NAMESZ longlong
getdstring NAME NAMESZ
if NAME & "Reverge"
else
    print "Error: unknown package file: %s" NAME
    cleanexit
endif

get NAMESZ longlong
getdstring NAME NAMESZ

get FILES longlong
for i = 0 < FILES
    get NAMESZ longlong
    getdstring NAME NAMESZ
    get SIZE longlong
    get DUMMY long  # 1
   
    set EXT extension NAME
   
    if EXT == "LZ4"
       comtype lz4f
       math FSIZE = 0x400000 #I think this is enough :)
       math FSIZE * 10
       clog NAME OFFSET SIZE FSIZE
    else
       log NAME OFFSET SIZE
    endif
    math OFFSET + SIZE
next i
Last edited by Ekey on Sat Dec 28, 2019 8:02 pm, edited 2 times in total.
Szkaradek123
Posts: 124
Joined: Sat Aug 29, 2015 1:13 pm

Re: Indivisible .pkg

Post by Szkaradek123 »

Thank you Ekey for the tool.

I have a little problem to force a tool to work.

Bat file is not working and i wonder what is problem ?

My commands were something like that:

IPKGDecryptor d:\Indivisible\pkgs\data_3.pkg

IPKGDecryptor d:/Indivisible/pkgs/data_3.pkg

"d:\Indivisible\pkgs\IPKGDecryptor.exe" "d:\Indivisible\pkgs\data_3.pkg"

IPKGDecryptor "d:\Indivisible\pkgs\data_3.pkg"

I have very slowly Python decryptor maked by your algorithm.

Code: Select all

def pkgParser(filename):
   new=open(filename+".decrypt","wb")
   
   keyFile=open("key.dat","rb")
   keyBin=BinaryReader(keyFile)
   keydata=keyBin.b(keyBin.fileSize())
   
   pkgFile=open(filename,'rb')
   pkgFile.seek(0,2)
   size=pkgFile.tell()
   print size
   pkgFile.seek(0)
   #for i  in  range(size):
   i=0
   while(True):
      b=struct.unpack('b',pkgFile.read(1))[0]
      b^=keydata[i % 1779072]
      new.write(struct.pack('b',b))
      if i==size:break
      i+=1
   keyFile.close()
   new.close()
   pkgFile.close()


It works for me and using bms to extract data from decrypted pkg files i get needed images and other files.

Animated sprites are build in files with "art" extension. They are local swizzled.
http://www.mediafire.com/file/62unppy1w ... o.art/file
Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Re: Indivisible .pkg

Post by Ekey »

Szkaradek123 wrote:Thank you Ekey for the tool.

I have a little problem to force a tool to work.

Bat file is not working and i wonder what is problem ?

My commands were something like that:

IPKGDecryptor d:\Indivisible\pkgs\data_3.pkg

IPKGDecryptor d:/Indivisible/pkgs/data_3.pkg

"d:\Indivisible\pkgs\IPKGDecryptor.exe" "d:\Indivisible\pkgs\data_3.pkg"

IPKGDecryptor "d:\Indivisible\pkgs\data_3.pkg"

Oops, my bad. I fixed it :)
ili
Posts: 81
Joined: Wed Sep 17, 2014 2:28 pm

Re: Indivisible .pkg

Post by ili »

thanks
Wonderful
Posts: 1
Joined: Sat Apr 11, 2020 1:16 am

Re: Indivisible .pkg

Post by Wonderful »

This thread was super helpful for me -- I was able to use the IPKGDecryptor and the new BMS script to turn the data_*.pkg files into folders full of files -- however, I'm pretty stuck on how to properly extract the various .lz4 files. The BMS script doesn't seem to have extracted them, and a variety of things I've tried haven't worked yet.

Using data_2.pkg/lz4/foits/golem.art.lz4 as an example:
* I downloaded and ran the lz4.exe tool on the file, but I get "Error 44 : Unrecognized header : file cannot be decoded"
* I downloaded the python lz4 module and tried using lz4.block.decompress(<file's binary contents>), but get "_block.LZ4BlockError: Decompression failed: corrupt input or insufficient space in destination buffer. Error code: 4"
* I tried the same lz4.block.decompress() with an uncompressed_size=X, but I get the same error up until X is too large.
* I tried lz4.frame.decompress(<file's binary contents>), but get "RuntimeError: LZ4F_getFrameInfo failed with code: ERROR_frameType_unknown"
* I tried all of the above a second time, after running the file through IPKGDecryptor.exe just in case. The errors make me think that at that point the file's just corrupted, so I don't think it needs to be decrypted?

I'm not very familiar with QuickBMS or LZ4, so I haven't tried further experiments with the BMS scripts or with trying to understand the .lz4 file header info. Any chance someone could help me with the proper steps to take one of these .lz4 files and actually get it properly extracting?

Thank you!!!
swat
Posts: 15
Joined: Sat May 15, 2021 8:58 am

Re: Indivisible .pkg

Post by swat »

Ekey wrote:
Szkaradek123 wrote:Thank you Ekey for the tool.

I have a little problem to force a tool to work.

Bat file is not working and i wonder what is problem ?

My commands were something like that:

IPKGDecryptor d:\Indivisible\pkgs\data_3.pkg

IPKGDecryptor d:/Indivisible/pkgs/data_3.pkg

"d:\Indivisible\pkgs\IPKGDecryptor.exe" "d:\Indivisible\pkgs\data_3.pkg"

IPKGDecryptor "d:\Indivisible\pkgs\data_3.pkg"

Oops, my bad. I fixed it :)


I have decrypted data_1.pkg
extract files with quickbms
and import with quickbms
but
how to crypt data_1_decrypted.pkg
because game crashed
Vannbin
Posts: 1
Joined: Tue Mar 15, 2022 4:26 am

Re: Indivisible .pkg

Post by Vannbin »

I've pretty much gone through every .pkg file for the game but can't really go past the .lz4 files in there, the .art, .dds and other files under the .lz4 are ones I can't figure out and can't fine any real options around even through a few searches(I'll keep trying but the concluding I keep getting is that it's pretty much impossible) still, I took a moment to think, 'sure I'm stumped but there's no point in giving up. If I can't do it maybe someone else can, no point in me just trashing my work after all.' And so that leads to this moment.

https://drive.google.com/file/d/1rGdH-X ... sp=sharing

I am stumped on getting past .lz4 part of the files, I managed to semi get past one for a .art file but have no clue or resource to get past it. I pretty much just used all the tips and directions from here to even get this much done but as of that I can't do anything else.
Zeek_McGee
Posts: 1
Joined: Thu Jun 30, 2022 3:06 pm

Re: Indivisible .pkg

Post by Zeek_McGee »

Example dds.lz4
Rename to .dds

Open with Gimp or convert to .png

u win!
FreetoThinkFree
Posts: 1
Joined: Sat Aug 20, 2022 3:13 am

Re: Indivisible .pkg

Post by FreetoThinkFree »

Zeek_McGee wrote:Example dds.lz4
Rename to .dds

Open with Gimp or convert to .png

u win!


I tried doing that with .art files, .lz4 files and .art.lz4 files. It didn't work. Any other way?