March 28, 2024, 23:35
bigger smaller reset     1020px Wide width Full width Reset   * *

Gildor's Forums

  Homepage Facebook Read news on Twitter Youtube channel Github page
Welcome, Guest. Please login or register.
Did you miss your activation email?

« previous next »
Print
Author Topic: Blade & Soul package encryption  (Read 16830 times)
LokiReborn
Newbie
*
Posts: 3


View Profile
« on: January 04, 2014, 08:51 »

hey quick question for you, I'm trying to edit one of the upk by hand to change out the fonts to support more languages for localization since the default fonts are using fixed block sizes for languages such as Russian, over all I get the file structure and dropped in the replacement ttf file fixed the sizes etc. though no idea what the deal is with the encrypted section you manage with the -game=bns flag, any insight you can give me so I can modify the offsets ?
« Last Edit: January 05, 2014, 13:38 by Gildor » Logged
Gildor
Administrator
Hero Member
*****
Posts: 7978



View Profile WWW
« Reply #1 on: January 04, 2014, 18:10 »

Blade & Soul has:
1) encryption of package tables
2) encryption of compressed data
3) newer versions - full package encryption
Logged
LokiReborn
Newbie
*
Posts: 3


View Profile
« Reply #2 on: January 04, 2014, 21:53 »

Understood, however as I was able to extract all the TTF fonts by hand and test them I know they aren't encrypted and there is no compression of the data itself, it was more if you could explain the header encryption to me and save me the trouble of having to reverse umodel.
« Last Edit: January 06, 2014, 10:36 by LokiReborn » Logged
Gildor
Administrator
Hero Member
*****
Posts: 7978



View Profile WWW
« Reply #3 on: January 05, 2014, 13:42 »

Ok. I'll try to copy-paste code from Umodel, and if you can't understand any part - ask your questions.
Code:
if (Game == GAME_BladeNSoul && (Summary.PackageFlags & 0x08000000))
PatchBnSExports(ExportTable, Summary);

...

static void DecodeBnSPointer(int &Value, unsigned Code1, unsigned Code2, int Index)
{
unsigned tmp1 = ROR32(Value, (Index + Code2) & 0x1F);
unsigned tmp2 = ROR32(Code1, Index % 32);
Value = tmp2 ^ tmp1;
}

static void PatchBnSExports(FObjectExport *Exp, const FPackageFileSummary &Summary)
{
unsigned Code1 = ((Summary.HeadersSize & 0xFF) << 24) |
((Summary.NameCount   & 0xFF) << 16) |
((Summary.NameOffset  & 0xFF) << 8)  |
((Summary.ExportCount & 0xFF));
unsigned Code2 = (Summary.ExportOffset + Summary.ImportCount + Summary.ImportOffset) & 0x1F;

for (int i = 0; i < Summary.ExportCount; i++, Exp++)
{
DecodeBnSPointer(Exp->SerialSize,   Code1, Code2, i);
DecodeBnSPointer(Exp->SerialOffset, Code1, Code2, i);
}
}
Logged
LokiReborn
Newbie
*
Posts: 3


View Profile
« Reply #4 on: January 06, 2014, 09:24 »

I was able to do what I needed to with that, thank you so much =)

« Last Edit: January 15, 2014, 21:15 by Gildor » Logged
starlg
Newbie
*
Posts: 4


View Profile
« Reply #5 on: January 13, 2014, 18:46 »

hi everyone, I've been searching the "encryption of compressed data" for a long time, Can Gildor teach me? I think it is why my texture loaded form blade&soul is unrecognizable.
any help will be appreciate.
Logged
Gildor
Administrator
Hero Member
*****
Posts: 7978



View Profile WWW
« Reply #6 on: January 14, 2014, 12:24 »

B&S has non-encrypted compression methods, like original UE3. Encrypted LZO has separate flag. Check this thread:
http://www.gildor.org/smf/index.php/topic,297.msg2862.html#msg2862

Code:
#define COMPRESS_LZO_ENC 8   // encrypted LZO
Logged
starlg
Newbie
*
Posts: 4


View Profile
« Reply #7 on: January 14, 2014, 21:12 »

I've read the thread, and got a compressed buffer! but I encountered a LZO_E_LOOKBEHIND_OVERRUN error when I use lzo1x_decompress function to decompress this buffer!
I'm sure it is use Encrypted LZO, what's different between Encrypted LZO and LZO?
do I miss something? thank you for your reply!  Smiley
Logged
Gildor
Administrator
Hero Member
*****
Posts: 7978



View Profile WWW
« Reply #8 on: January 14, 2014, 21:15 »

Which compression flags do you have for that block?
Logged
starlg
Newbie
*
Posts: 4


View Profile
« Reply #9 on: January 15, 2014, 21:05 »

it is 8 .
Much like you described above

#define COMPRESS_LZO_ENC 8   // encrypted LZO
Logged
Gildor
Administrator
Hero Member
*****
Posts: 7978



View Profile WWW
« Reply #10 on: January 15, 2014, 21:14 »

Ok. Here's a code for decryption before passing data to LZO (again, copy-paste from umodel's source)

Code:
if (GForceGame == GAME_BladeNSoul && Flags == COMPRESS_LZO_ENC) // note: GForceGame is required (to not pass 'Game' here)
{
if (CompressedSize >= 32)
{
static const char *key = "qiffjdlerdoqymvketdcl0er2subioxq";
for (int i = 0; i < CompressedSize; i++)
CompressedBuffer[i] ^= key[i % 32];
}
// overide compression
Flags = COMPRESS_LZO;
}
Logged
starlg
Newbie
*
Posts: 4


View Profile
« Reply #11 on: January 16, 2014, 18:37 »

Wow, it worked!  I got the correct texture!
I appreciate it very much for your support, thank you!
Logged
kbnsh
Newbie
*
Posts: 1


View Profile
« Reply #12 on: July 27, 2014, 03:39 »


B & S's upk file to decompress the texture has
I want to modify the texture compression
However, this thread is that I do not know how to
I want you to tell me the way, if possible.
Logged
Print 
« previous next »
Jump to:  

Powered by SMF | SMF © 2006-2009, Simple Machines LLC
Leviathan design by Bloc | XHTML | CSS