Dragon Nest custom encrypted .pak

Extraction and unpacking of game archives and compression, encryption, obfuscation, decoding of unknown files
Omnitrix
Posts: 19
Joined: Fri Aug 31, 2018 11:24 pm

Dragon Nest custom encrypted .pak

Post by Omnitrix »

Hello, dunno if this allowed here. I am having custom encrypted Dragon Nest .pak file and regular .pak script is not working with that file. Or this is impossible without an encryption key? Thank you! https://www.mediafire.com/file/i4j0vjdz ... d.pak/file
LokiReborn
Posts: 190
Joined: Fri Aug 26, 2016 3:11 pm

Re: Dragon Nest custom encrypted .pak

Post by LokiReborn »

Omnitrix wrote:Hello, dunno if this allowed here. I am having custom encrypted Dragon Nest .pak file and regular .pak script is not working with that file. Or this is impossible without an encryption key? Thank you! https://www.mediafire.com/file/i4j0vjdz ... d.pak/file


It's allowed however probably not doable, I did try to guess at what it might be with the high repeat in some of the data "DN RU" and use that as an xor key to 0 it out however the data still didn't look correct. If you want to upload the bin folder can try taking a look but guessing encryption for files in 99% of cases is impossible.
Omnitrix
Posts: 19
Joined: Fri Aug 31, 2018 11:24 pm

Re: Dragon Nest custom encrypted .pak

Post by Omnitrix »

LokiReborn wrote:
Omnitrix wrote:Hello, dunno if this allowed here. I am having custom encrypted Dragon Nest .pak file and regular .pak script is not working with that file. Or this is impossible without an encryption key? Thank you! https://www.mediafire.com/file/i4j0vjdz ... d.pak/file


It's allowed however probably not doable, I did try to guess at what it might be with the high repeat in some of the data "DN RU" and use that as an xor key to 0 it out however the data still didn't look correct. If you want to upload the bin folder can try taking a look but guessing encryption for files in 99% of cases is impossible.

Thank you for the answer. What files I need to provide to you? The whole game folder is really huge size.
LokiReborn
Posts: 190
Joined: Fri Aug 26, 2016 3:11 pm

Re: Dragon Nest custom encrypted .pak

Post by LokiReborn »

Omnitrix wrote:
LokiReborn wrote:
Omnitrix wrote:Hello, dunno if this allowed here. I am having custom encrypted Dragon Nest .pak file and regular .pak script is not working with that file. Or this is impossible without an encryption key? Thank you! https://www.mediafire.com/file/i4j0vjdz ... d.pak/file


It's allowed however probably not doable, I did try to guess at what it might be with the high repeat in some of the data "DN RU" and use that as an xor key to 0 it out however the data still didn't look correct. If you want to upload the bin folder can try taking a look but guessing encryption for files in 99% of cases is impossible.

Thank you for the answer. What files I need to provide to you? The whole game folder is really huge size.


There is usually something like a bin folder that contains the executable & dll files, that's what would be needed to attempt to see how it's done.
Omnitrix
Posts: 19
Joined: Fri Aug 31, 2018 11:24 pm

Re: Dragon Nest custom encrypted .pak

Post by Omnitrix »

LokiReborn wrote:
Omnitrix wrote:
LokiReborn wrote:
It's allowed however probably not doable, I did try to guess at what it might be with the high repeat in some of the data "DN RU" and use that as an xor key to 0 it out however the data still didn't look correct. If you want to upload the bin folder can try taking a look but guessing encryption for files in 99% of cases is impossible.

Thank you for the answer. What files I need to provide to you? The whole game folder is really huge size.


There is usually something like a bin folder that contains the executable & dll files, that's what would be needed to attempt to see how it's done.

Here is everything from the folder except another .paks
http://www.mediafire.com/file/gt09or0cj ... N.zip/file
LokiReborn
Posts: 190
Joined: Fri Aug 26, 2016 3:11 pm

Re: Dragon Nest custom encrypted .pak

Post by LokiReborn »

Omnitrix wrote:
LokiReborn wrote:
Omnitrix wrote:Thank you for the answer. What files I need to provide to you? The whole game folder is really huge size.


There is usually something like a bin folder that contains the executable & dll files, that's what would be needed to attempt to see how it's done.

Here is everything from the folder except another .paks
http://www.mediafire.com/file/gt09or0cj ... N.zip/file


So ... good news and bad news.
The good news is that it's doable with what you provided me, the bad news is that it's doing something I'm not familiar with.
Essentially in most games I've worked when the decryption happens it's happens as part of a routine in the game whether it be AES, TEA, Xor, etc. however with Dragon nest the decryption is done through a handle as part of the Read File call. So when the buffer arrives to the game the data is already decrypted.
So I can see the data you want at the moment but I'm not sure how it's done until I can trace the handle back and figure out what's actually happening. I'll let ya know if I figure it out. For anyone that may be more familiar with this sort of thing the first Read of a Pack File happens at 0x00DC7328 for 0x110 bytes where it determines what it's going to do next.

Edit: Small edit correcting myself, it's not the handle itself it's the fact the game uses Xigncode and it's hooking the call to ReadFile to do custom operations.
Omnitrix
Posts: 19
Joined: Fri Aug 31, 2018 11:24 pm

Re: Dragon Nest custom encrypted .pak

Post by Omnitrix »

LokiReborn wrote:
Omnitrix wrote:
LokiReborn wrote:
There is usually something like a bin folder that contains the executable & dll files, that's what would be needed to attempt to see how it's done.

Here is everything from the folder except another .paks
http://www.mediafire.com/file/gt09or0cj ... N.zip/file


So ... good news and bad news.
The good news is that it's doable with what you provided me, the bad news is that it's doing something I'm not familiar with.
Essentially in most games I've worked when the decryption happens it's happens as part of a routine in the game whether it be AES, TEA, Xor, etc. however with Dragon nest the decryption is done through a handle as part of the Read File call. So when the buffer arrives to the game the data is already decrypted.
So I can see the data you want at the moment but I'm not sure how it's done until I can trace the handle back and figure out what's actually happening. I'll let ya know if I figure it out. For anyone that may be more familiar with this sort of thing the first Read of a Pack File happens at 0x00DC7328 for 0x110 bytes where it determines what it's going to do next.

Edit: Small edit correcting myself, it's not the handle itself it's the fact the game uses Xigncode and it's hooking the call to ReadFile to do custom operations.

Thank you for information. Hope you will manage that :) Praying for you!
LokiReborn
Posts: 190
Joined: Fri Aug 26, 2016 3:11 pm

Re: Dragon Nest custom encrypted .pak

Post by LokiReborn »

Omnitrix wrote:
LokiReborn wrote:
Omnitrix wrote:Here is everything from the folder except another .paks
http://www.mediafire.com/file/gt09or0cj ... N.zip/file


So ... good news and bad news.
The good news is that it's doable with what you provided me, the bad news is that it's doing something I'm not familiar with.
Essentially in most games I've worked when the decryption happens it's happens as part of a routine in the game whether it be AES, TEA, Xor, etc. however with Dragon nest the decryption is done through a handle as part of the Read File call. So when the buffer arrives to the game the data is already decrypted.
So I can see the data you want at the moment but I'm not sure how it's done until I can trace the handle back and figure out what's actually happening. I'll let ya know if I figure it out. For anyone that may be more familiar with this sort of thing the first Read of a Pack File happens at 0x00DC7328 for 0x110 bytes where it determines what it's going to do next.

Edit: Small edit correcting myself, it's not the handle itself it's the fact the game uses Xigncode and it's hooking the call to ReadFile to do custom operations.

Thank you for information. Hope you will manage that :) Praying for you!


This was as far as I was able to get for the moment. I sadly got to work on a few other things not sure if anyone else can see what's missing.
Basically it fixes the header and file table however what I haven't been able to see is why the zlib won't decompress, it's possible they have some modification to that somewhere in the code too.
Omnitrix
Posts: 19
Joined: Fri Aug 31, 2018 11:24 pm

Re: Dragon Nest custom encrypted .pak

Post by Omnitrix »

LokiReborn wrote:
Omnitrix wrote:
LokiReborn wrote:
So ... good news and bad news.
The good news is that it's doable with what you provided me, the bad news is that it's doing something I'm not familiar with.
Essentially in most games I've worked when the decryption happens it's happens as part of a routine in the game whether it be AES, TEA, Xor, etc. however with Dragon nest the decryption is done through a handle as part of the Read File call. So when the buffer arrives to the game the data is already decrypted.
So I can see the data you want at the moment but I'm not sure how it's done until I can trace the handle back and figure out what's actually happening. I'll let ya know if I figure it out. For anyone that may be more familiar with this sort of thing the first Read of a Pack File happens at 0x00DC7328 for 0x110 bytes where it determines what it's going to do next.

Edit: Small edit correcting myself, it's not the handle itself it's the fact the game uses Xigncode and it's hooking the call to ReadFile to do custom operations.

Thank you for information. Hope you will manage that :) Praying for you!


This was as far as I was able to get for the moment. I sadly got to work on a few other things not sure if anyone else can see what's missing.
Basically it fixes the header and file table however what I haven't been able to see is why the zlib won't decompress, it's possible they have some modification to that somewhere in the code too.

Thank you so much! But unpacking script is still not working even for decrypted file. But still I am very grateful to you, thank you! May be you will have a time in a future to finish this?
Ekey
Posts: 1383
Joined: Sat Aug 09, 2014 2:34 pm

Re: Dragon Nest custom encrypted .pak

Post by Ekey »

Code: Select all

# Dragon Nest (custom encryption) PAK format
# script for QuickBMS http://quickbms.aluigi.org

set MEMORY_FILE10 string "
static unsigned char lpKey[499] = {
       0xBA, 0xAA, 0xAA, 0xDA, 0xBA, 0xEB, 0x24, 0x0A, 0xC5, 0x9B, 0x59, 0xAE, 0x8D,
       0xC0, 0xB8, 0x8D, 0x49, 0x6F, 0x66, 0x05, 0xA5, 0x25, 0x59, 0x4A, 0xA2, 0xFB,
       0xF2, 0x6B, 0x12, 0xF4, 0x7E, 0xBE, 0x12, 0xB5, 0xEA, 0x24, 0x19, 0x5B, 0x4D,
       0x60, 0x6D, 0x00, 0x96, 0xB9, 0xD5, 0x19, 0xB5, 0x96, 0x91, 0x07, 0x19, 0x22,
       0x48, 0x83, 0x7D, 0x49, 0xDE, 0xE9, 0x57, 0x82, 0xD5, 0x6D, 0xB8, 0x34, 0x3E,
       0x24, 0x1B, 0x74, 0x35, 0x67, 0xF1, 0x2C, 0xCC, 0x1E, 0x8B, 0x46, 0x0F, 0x68,
       0x0F, 0xC1, 0xEC, 0xAC, 0xAF, 0x4B, 0x36, 0x05, 0x14, 0x5E, 0xFD, 0xD9, 0x35,
       0x48, 0x10, 0x35, 0xC4, 0xA7, 0x46, 0x1B, 0x3D, 0x5D, 0x6B, 0xE1, 0xCA, 0x8A,
       0x81, 0x47, 0x6A, 0xE7, 0xC6, 0x31, 0xA1, 0xF4, 0x7D, 0x3F, 0x57, 0x51, 0x4B,
       0x3D, 0xDE, 0xB9, 0x84, 0x90, 0x85, 0x43, 0xD0, 0x20, 0x96, 0x55, 0xD4, 0x97,
       0x4C, 0xC6, 0x3F, 0xE2, 0x25, 0x5D, 0x7F, 0x74, 0x0E, 0x62, 0x37, 0xCA, 0x74,
       0x5A, 0x71, 0x73, 0xB0, 0x05, 0xB6, 0x77, 0x51, 0x16, 0xA9, 0x1E, 0xE7, 0x59,
       0xD6, 0x0B, 0x9D, 0x16, 0x0C, 0x72, 0x5C, 0x24, 0xCB, 0x28, 0x27, 0xEB, 0x1A,
       0xC1, 0xD9, 0x96, 0xA5, 0xE8, 0xCC, 0x62, 0xDF, 0xAF, 0xE4, 0x98, 0x67, 0x27,
       0x04, 0xBB, 0xDF, 0x3A, 0x13, 0x6B, 0x78, 0x13, 0x90, 0x5B, 0x20, 0xFA, 0xEC,
       0x00, 0x30, 0x38, 0xF9, 0x95, 0x11, 0x0C, 0x31, 0x83, 0x29, 0xCF, 0x3C, 0xD7,
       0x46, 0x05, 0x36, 0x27, 0xF7, 0xD2, 0xF9, 0xE8, 0x25, 0x9E, 0xBF, 0xED, 0x3D,
       0x81, 0x40, 0xA0, 0x57, 0x54, 0xEE, 0xA6, 0x9A, 0xC0, 0x76, 0x0B, 0xAA, 0x09,
       0xBF, 0xB7, 0xA7, 0x1C, 0xA8, 0x6D, 0x4B, 0xFF, 0xEE, 0xAA, 0x79, 0x12, 0xAF,
       0x29, 0x4A, 0xE6, 0x28, 0xC2, 0xB9, 0x7B, 0x91, 0x7A, 0x88, 0x8E, 0x80, 0x37,
       0xE5, 0x63, 0x90, 0x33, 0xD5, 0x5E, 0x7A, 0x13, 0x74, 0xC0, 0xE2, 0x07, 0x7A,
       0x7E, 0x09, 0x98, 0x78, 0xF0, 0xD7, 0x1D, 0xF9, 0xB1, 0x0D, 0x19, 0xEF, 0x62,
       0x11, 0x0D, 0x32, 0x7C, 0x3B, 0x32, 0x2E, 0x56, 0x3B, 0x03, 0x55, 0xA2, 0x04,
       0x28, 0x46, 0xDF, 0x2B, 0x65, 0x05, 0x6B, 0x22, 0x02, 0xBE, 0xF2, 0xB8, 0x89,
       0x0C, 0x28, 0x2D, 0x26, 0x3E, 0xE1, 0x6B, 0x63, 0x8A, 0x37, 0x76, 0x23, 0xF2,
       0xDD, 0xAC, 0x04, 0xC6, 0x20, 0x62, 0xDB, 0xAB, 0x02, 0xA0, 0x31, 0x8F, 0x7A,
       0xD6, 0x98, 0x42, 0x75, 0xC0, 0xBB, 0x84, 0x33, 0x10, 0x78, 0xF7, 0x43, 0x12,
       0xC6, 0x03, 0x8F, 0x63, 0x1F, 0x75, 0x94, 0x9E, 0x95, 0x5B, 0x71, 0x9E, 0x49,
       0xA5, 0x13, 0x5B, 0x29, 0xFC, 0xFF, 0x23, 0x80, 0xAF, 0xF1, 0xE4, 0x15, 0x1A,
       0xE9, 0x3C, 0xFB, 0x71, 0x4D, 0x7A, 0xAC, 0x7F, 0x26, 0x74, 0x14, 0x0F, 0x6B,
       0xF7, 0xBB, 0xB8, 0x05, 0x36, 0x4D, 0xC9, 0xA4, 0x35, 0x2C, 0x19, 0x0A, 0xFC,
       0x8C, 0xB3, 0x36, 0x0F, 0x36, 0x4C, 0x75, 0x14, 0x65, 0x50, 0xCD, 0x5E, 0x7F,
       0x9B, 0x01, 0x24, 0x22, 0xCB, 0x91, 0x9F, 0xF4, 0x3E, 0x31, 0xC6, 0x10, 0x30,
       0x42, 0x9D, 0xB2, 0xF9, 0x02, 0xA2, 0x80, 0x3B, 0xDB, 0x15, 0x04, 0x07, 0xED,
       0x1F, 0x9A, 0x2C, 0x5F, 0xF9, 0xAB, 0x44, 0xAB, 0x27, 0x42, 0x41, 0xC5, 0x30,
       0xA3, 0x2E, 0xB6, 0xFD, 0x67, 0xEF, 0xE8, 0xF4, 0xE2, 0x86, 0x44, 0x1E, 0x07,
       0x40, 0xB7, 0x03, 0x4A, 0x19, 0xDE, 0x92, 0x70, 0x3B, 0x2A, 0xB3, 0xAA, 0x6A,
       0xEB, 0xDB, 0x5C, 0x6C, 0x58, 0x5D, 0xE5, 0x59, 0x62, 0x46, 0xA1, 0xF0, 0xB4,
       0x56, 0x70, 0x4C, 0xBB, 0xBD};

void iDecryptHeader(unsigned char* lpBuffer)
{
  for (int i = 272; i != 31; --i )
  {
     lpBuffer[i] ^= lpKey[i % 0x1F3] ^ lpBuffer[i - 1];
  }
}

void iDecryptEntry(unsigned char* lpBuffer, int dwSize)
{
  for (int i = dwSize - 1; i != 50; --i)
  {
     lpBuffer[i] ^= lpKey[i % 0x1F3] ^ lpBuffer[i - 1];
  }
 
  for (int i = 0; i < 50; ++i)
  {
     lpBuffer[i] ^= lpKey[(i + 105) % 0x1F3];
  }
}

void iDecryptFileData(unsigned char* lpBuffer, int dwSize)
{
  for (int i = 1; i < dwSize; ++i)
  {
     lpBuffer[i] ^= lpKey[i % 0x1F3];
  }
}
"

savepos HEADER_OFFSET
math HEADER_SIZE = 272

log MEMORY_FILE HEADER_OFFSET HEADER_SIZE
calldll MEMORY_FILE10 "iDecryptHeader" "tcc" RET MEMORY_FILE

idstring MEMORY_FILE "!!BEWARE THIS FILE IS ENCRYPTED"
goto 260 MEMORY_FILE
get FILES long MEMORY_FILE
get TABLE_OFFSET long MEMORY_FILE

get ARCHIVE_SIZE asize
math TABLE_SIZE = ARCHIVE_SIZE
math TABLE_SIZE -= TABLE_OFFSET

log MEMORY_FILE2 TABLE_OFFSET TABLE_SIZE
calldll MEMORY_FILE10 "iDecryptEntry" "tcc" RET MEMORY_FILE2 TABLE_SIZE

for i = 0 < FILES
  getdstring NAME 256 MEMORY_FILE2
  get ZSIZE long MEMORY_FILE2
  get SIZE long MEMORY_FILE2
  get XSIZE long MEMORY_FILE2
  get OFFSET long MEMORY_FILE2
  getdstring DUMMY 44 MEMORY_FILE2
  callfunction EXTRACT_FILE 1
next i

startfunction EXTRACT_FILE
 if ZSIZE == SIZE
    log MEMORY_FILE OFFSET SIZE
    calldll MEMORY_FILE10 "iDecryptFileData" "tcc" RET MEMORY_FILE SIZE
    log NAME 0 SIZE MEMORY_FILE
 else
    log MEMORY_FILE OFFSET ZSIZE
    calldll MEMORY_FILE10 "iDecryptFileData" "tcc" RET MEMORY_FILE ZSIZE
    clog NAME 0 ZSIZE SIZE MEMORY_FILE
 endif
endfunction


btw: x3.xem it's a fake dll, used for hook ReadFile function :)
Omnitrix
Posts: 19
Joined: Fri Aug 31, 2018 11:24 pm

Re: Dragon Nest custom encrypted .pak

Post by Omnitrix »

Ekey wrote:

Code: Select all

# Dragon Nest (custom encryption) PAK format
# script for QuickBMS http://quickbms.aluigi.org

set MEMORY_FILE10 string "
static unsigned char lpKey[499] = {
       0xBA, 0xAA, 0xAA, 0xDA, 0xBA, 0xEB, 0x24, 0x0A, 0xC5, 0x9B, 0x59, 0xAE, 0x8D,
       0xC0, 0xB8, 0x8D, 0x49, 0x6F, 0x66, 0x05, 0xA5, 0x25, 0x59, 0x4A, 0xA2, 0xFB,
       0xF2, 0x6B, 0x12, 0xF4, 0x7E, 0xBE, 0x12, 0xB5, 0xEA, 0x24, 0x19, 0x5B, 0x4D,
       0x60, 0x6D, 0x00, 0x96, 0xB9, 0xD5, 0x19, 0xB5, 0x96, 0x91, 0x07, 0x19, 0x22,
       0x48, 0x83, 0x7D, 0x49, 0xDE, 0xE9, 0x57, 0x82, 0xD5, 0x6D, 0xB8, 0x34, 0x3E,
       0x24, 0x1B, 0x74, 0x35, 0x67, 0xF1, 0x2C, 0xCC, 0x1E, 0x8B, 0x46, 0x0F, 0x68,
       0x0F, 0xC1, 0xEC, 0xAC, 0xAF, 0x4B, 0x36, 0x05, 0x14, 0x5E, 0xFD, 0xD9, 0x35,
       0x48, 0x10, 0x35, 0xC4, 0xA7, 0x46, 0x1B, 0x3D, 0x5D, 0x6B, 0xE1, 0xCA, 0x8A,
       0x81, 0x47, 0x6A, 0xE7, 0xC6, 0x31, 0xA1, 0xF4, 0x7D, 0x3F, 0x57, 0x51, 0x4B,
       0x3D, 0xDE, 0xB9, 0x84, 0x90, 0x85, 0x43, 0xD0, 0x20, 0x96, 0x55, 0xD4, 0x97,
       0x4C, 0xC6, 0x3F, 0xE2, 0x25, 0x5D, 0x7F, 0x74, 0x0E, 0x62, 0x37, 0xCA, 0x74,
       0x5A, 0x71, 0x73, 0xB0, 0x05, 0xB6, 0x77, 0x51, 0x16, 0xA9, 0x1E, 0xE7, 0x59,
       0xD6, 0x0B, 0x9D, 0x16, 0x0C, 0x72, 0x5C, 0x24, 0xCB, 0x28, 0x27, 0xEB, 0x1A,
       0xC1, 0xD9, 0x96, 0xA5, 0xE8, 0xCC, 0x62, 0xDF, 0xAF, 0xE4, 0x98, 0x67, 0x27,
       0x04, 0xBB, 0xDF, 0x3A, 0x13, 0x6B, 0x78, 0x13, 0x90, 0x5B, 0x20, 0xFA, 0xEC,
       0x00, 0x30, 0x38, 0xF9, 0x95, 0x11, 0x0C, 0x31, 0x83, 0x29, 0xCF, 0x3C, 0xD7,
       0x46, 0x05, 0x36, 0x27, 0xF7, 0xD2, 0xF9, 0xE8, 0x25, 0x9E, 0xBF, 0xED, 0x3D,
       0x81, 0x40, 0xA0, 0x57, 0x54, 0xEE, 0xA6, 0x9A, 0xC0, 0x76, 0x0B, 0xAA, 0x09,
       0xBF, 0xB7, 0xA7, 0x1C, 0xA8, 0x6D, 0x4B, 0xFF, 0xEE, 0xAA, 0x79, 0x12, 0xAF,
       0x29, 0x4A, 0xE6, 0x28, 0xC2, 0xB9, 0x7B, 0x91, 0x7A, 0x88, 0x8E, 0x80, 0x37,
       0xE5, 0x63, 0x90, 0x33, 0xD5, 0x5E, 0x7A, 0x13, 0x74, 0xC0, 0xE2, 0x07, 0x7A,
       0x7E, 0x09, 0x98, 0x78, 0xF0, 0xD7, 0x1D, 0xF9, 0xB1, 0x0D, 0x19, 0xEF, 0x62,
       0x11, 0x0D, 0x32, 0x7C, 0x3B, 0x32, 0x2E, 0x56, 0x3B, 0x03, 0x55, 0xA2, 0x04,
       0x28, 0x46, 0xDF, 0x2B, 0x65, 0x05, 0x6B, 0x22, 0x02, 0xBE, 0xF2, 0xB8, 0x89,
       0x0C, 0x28, 0x2D, 0x26, 0x3E, 0xE1, 0x6B, 0x63, 0x8A, 0x37, 0x76, 0x23, 0xF2,
       0xDD, 0xAC, 0x04, 0xC6, 0x20, 0x62, 0xDB, 0xAB, 0x02, 0xA0, 0x31, 0x8F, 0x7A,
       0xD6, 0x98, 0x42, 0x75, 0xC0, 0xBB, 0x84, 0x33, 0x10, 0x78, 0xF7, 0x43, 0x12,
       0xC6, 0x03, 0x8F, 0x63, 0x1F, 0x75, 0x94, 0x9E, 0x95, 0x5B, 0x71, 0x9E, 0x49,
       0xA5, 0x13, 0x5B, 0x29, 0xFC, 0xFF, 0x23, 0x80, 0xAF, 0xF1, 0xE4, 0x15, 0x1A,
       0xE9, 0x3C, 0xFB, 0x71, 0x4D, 0x7A, 0xAC, 0x7F, 0x26, 0x74, 0x14, 0x0F, 0x6B,
       0xF7, 0xBB, 0xB8, 0x05, 0x36, 0x4D, 0xC9, 0xA4, 0x35, 0x2C, 0x19, 0x0A, 0xFC,
       0x8C, 0xB3, 0x36, 0x0F, 0x36, 0x4C, 0x75, 0x14, 0x65, 0x50, 0xCD, 0x5E, 0x7F,
       0x9B, 0x01, 0x24, 0x22, 0xCB, 0x91, 0x9F, 0xF4, 0x3E, 0x31, 0xC6, 0x10, 0x30,
       0x42, 0x9D, 0xB2, 0xF9, 0x02, 0xA2, 0x80, 0x3B, 0xDB, 0x15, 0x04, 0x07, 0xED,
       0x1F, 0x9A, 0x2C, 0x5F, 0xF9, 0xAB, 0x44, 0xAB, 0x27, 0x42, 0x41, 0xC5, 0x30,
       0xA3, 0x2E, 0xB6, 0xFD, 0x67, 0xEF, 0xE8, 0xF4, 0xE2, 0x86, 0x44, 0x1E, 0x07,
       0x40, 0xB7, 0x03, 0x4A, 0x19, 0xDE, 0x92, 0x70, 0x3B, 0x2A, 0xB3, 0xAA, 0x6A,
       0xEB, 0xDB, 0x5C, 0x6C, 0x58, 0x5D, 0xE5, 0x59, 0x62, 0x46, 0xA1, 0xF0, 0xB4,
       0x56, 0x70, 0x4C, 0xBB, 0xBD};

void iDecryptHeader(unsigned char* lpBuffer)
{
  for (int i = 272; i != 31; --i )
  {
     lpBuffer[i] ^= lpKey[i % 0x1F3] ^ lpBuffer[i - 1];
  }
}

void iDecryptEntry(unsigned char* lpBuffer, int dwSize)
{
  for (int i = dwSize - 1; i != 50; --i)
  {
     lpBuffer[i] ^= lpKey[i % 0x1F3] ^ lpBuffer[i - 1];
  }
 
  for (int i = 0; i < 50; ++i)
  {
     lpBuffer[i] ^= lpKey[(i + 105) % 0x1F3];
  }
}

void iDecryptFileData(unsigned char* lpBuffer, int dwSize)
{
  for (int i = 1; i < dwSize; ++i)
  {
     lpBuffer[i] ^= lpKey[i % 0x1F3];
  }
}
"

savepos HEADER_OFFSET
math HEADER_SIZE = 272

log MEMORY_FILE HEADER_OFFSET HEADER_SIZE
calldll MEMORY_FILE10 "iDecryptHeader" "tcc" RET MEMORY_FILE

idstring MEMORY_FILE "!!BEWARE THIS FILE IS ENCRYPTED"
goto 260 MEMORY_FILE
get FILES long MEMORY_FILE
get TABLE_OFFSET long MEMORY_FILE

get ARCHIVE_SIZE asize
math TABLE_SIZE = ARCHIVE_SIZE
math TABLE_SIZE -= TABLE_OFFSET

log MEMORY_FILE2 TABLE_OFFSET TABLE_SIZE
calldll MEMORY_FILE10 "iDecryptEntry" "tcc" RET MEMORY_FILE2 TABLE_SIZE

for i = 0 < FILES
  getdstring NAME 256 MEMORY_FILE2
  get ZSIZE long MEMORY_FILE2
  get SIZE long MEMORY_FILE2
  get XSIZE long MEMORY_FILE2
  get OFFSET long MEMORY_FILE2
  getdstring DUMMY 44 MEMORY_FILE2
  callfunction EXTRACT_FILE 1
next i

startfunction EXTRACT_FILE
 if ZSIZE == SIZE
    log MEMORY_FILE OFFSET SIZE
    calldll MEMORY_FILE10 "iDecryptFileData" "tcc" RET MEMORY_FILE SIZE
    log NAME 0 SIZE MEMORY_FILE
 else
    log MEMORY_FILE OFFSET ZSIZE
    calldll MEMORY_FILE10 "iDecryptFileData" "tcc" RET MEMORY_FILE ZSIZE
    clog NAME 0 ZSIZE SIZE MEMORY_FILE
 endif
endfunction


btw: x3.xem it's a fake dll, used for hook ReadFile function :)

OH MY. IT'S WORKING! Thank you so much. I am so thankful to both of you. guys. I'll be praying for you both! Thank you so much!!!
rochey
Posts: 2
Joined: Thu Dec 30, 2021 12:58 pm

Re: Dragon Nest custom encrypted .pak

Post by rochey »

hello can you help me encryption the .pak files i not understand how to use this script thanks , and if it possible to do it on all paks ?
rochey
Posts: 2
Joined: Thu Dec 30, 2021 12:58 pm

Re: Dragon Nest custom encrypted .pak

Post by rochey »

it ask for dll ?
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Dragon Nest custom encrypted .pak

Post by aluigi »

That's a script for quickbms:
http://quickbms.com

Type Y when quickbms will ask you about the DLL code (there is no dll, it refers to the C-language code in the MEMORY_FILE10 string)
Omnitrix
Posts: 19
Joined: Fri Aug 31, 2018 11:24 pm

Re: Dragon Nest custom encrypted .pak

Post by Omnitrix »

Hello everyone and happy holidays! After two years I have a problem with another Dragon Nest .pak while unpacking. I got this error:
Image
I saw a topic with similar problem on this forum and tried provided fix but unfortunately it's not working. Script looks like that:

Code: Select all

IDString "EyedentityGames Packing File 0.1"
goto 0x104
get Files long
get noffset long
goto noffset
for i = 0 < Files
getdstring NAME 0x100
get ZSIZE long
get SIZE long
get ZSIZE1 long
get OFFSET long
get UNK3 long
getdstring NULL1 0x28
if SIZE <= ZSIZE
log NAME OFFSET SIZE
else
clog NAME OFFSET ZSIZE SIZE
endif
next i
Here is the file, it's 27mb. https://www.mediafire.com/file/colladrc ... 1.pak/file
Omnitrix
Posts: 19
Joined: Fri Aug 31, 2018 11:24 pm

Re: Dragon Nest custom encrypted .pak

Post by Omnitrix »

Sorry for bumping. Really need your help, guys!
Omnitrix
Posts: 19
Joined: Fri Aug 31, 2018 11:24 pm

Re: Dragon Nest custom encrypted .pak

Post by Omnitrix »

Bump
Omnitrix
Posts: 19
Joined: Fri Aug 31, 2018 11:24 pm

Re: Dragon Nest custom encrypted .pak

Post by Omnitrix »

bumping again