What's new

DX Library Archive tools


steveju

Demon Girl
Joined
Jun 24, 2016
Messages
81
Reputation score
39
I was looking into DX archives because DXExtractor didn't work with some of the newer games that are being released, making it impossible to extract the game files for translation or modification. The archives are made with and they are used by WOLF RPG Maker and other RPG games. I found that the encryption, while easy-ish to bypass, is hard because there are no tools available that worked.

was a pretty good tool for the job, but it hasn't been updated to support the newer archive formats and the tool that comes with DX Library, DxaDecode, can't handle non-ascii keys. DXExtract skips the key generation process and uses post-encryption keys in HEX to unpack the archives which was a cool idea.


Background
DX archive keys are not really encrypted that well. The resulting key looks complicated eg. 1223344556677889900AABBC, but actually the long key is "encrypted" for each character individually... and since DX Library source code is available, we also know how every single character is calculated (see code). What this means for us is that we can easily decode the encryption string back to it's original form since we're not trying to decode the whole key, we're decoding it a single character at a time.

Code:
key[0] = ~key[0] ;
key[1] = ( key[1] >> 4 ) | ( key[1] << 4 ) ;
key[2] = key[2] ^ 0x8a ;
key[3] = ~( ( key[3] >> 4 ) | ( key[3] << 4 ) ) ;
key[4] = ~key[4] ;
key[5] = key[5] ^ 0xac ;
key[6] = ~key[6] ;
key[7] = ~( ( key[7] >> 3 ) | ( key[7] << 5 ) ) ;
key[8] = ( key[8] >> 5 ) | ( key[8] << 3 ) ;
key[9] = key[9] ^ 0x7f ;
key[10] = ( ( key[10] >> 4 ) | ( key[10] << 4 ) ) ^ 0xd6;
key[11] = key[11] ^ 0xcc;
The number of different chars for each individual character in the keystring is 255 or 0xFF. The keys are always 12 characters long, if they're longer than that, the encryption function ignores extra characters and if it's shorter, it'll just append the encryption string to itself (before key[x] operations) to make it 12 characters long.

Eg. Viocide Vore Side Action RPG's password "boost" becomes "boostboostbo" and Uwasa no yado musume's "quingamepakcode" becomes "quingamepakc".

In the original DX Libs the string is basically split into chars, chars converted into binary, the binary for each char is placed into an array and then the operations listed above are done to each object in the array.
Eg. first character in Viocide is "b" which is 01100010 in binary, then we do "bitwise NOT" -operation to it, which results in 10011101, which is 9D in HEX (9DF6E5C88BCE90129B0BF0A3) and so on...

The encoding is ~"b" = 9D. To reverse this process, we just try a different x in ~x = 9D until we get one that results in 9D... Yes I know, in this case bitwise NOT is actually non-destructive and we can just do ~ on 10011101 and it'll come back as 01100010, which is the original character. This was just an example.

Implementation
Now we can make an app that checks for every input variation possible until we get a match using the functions pulled from the source code. Do that for all characters and we have the original key.

Example code from tool.jar (slightly edited):
Code:
//try each possible character or value
for (int x = 1; x < 255; x++) {
//calculate the encoded character for each character until we get a match
if (key[1].equals(((x >> 4) | (x << 4))) {
// this is the original character or rather the integer that represents that character
return x;
}
// something goes terribly wrong
return -1;
}

and so on...
The resulting numbers are then converted to characters and put together to form a string, which only works with the original DxaDecode if the characters in the keystring are printable. Some DX archives use keys that have non-printable characters which makes them impossible to use with DxaDecode, which is probably why DXExtract was made back in the day, as it solved this issue. Eg. the example usage below contains a character that has a value of 7 which isn't writable in (it's BEL/Bell).

Why is this needed?
Right now there is not much use for this yet (as in there's probably no archive out there that forces someone to use this... yet), as DXExtract supports the older archives and newer archive types are slowly just rolling out. Newer WOLF RPG titles updated their archives, but also changed the common encoding key to one that had an ASCII counterpart that the existing DxaDecode was able to use (key: 8P@(rO!p;s58). Tool.jar was used to decode the password from the encoded HEX used by Game.exe (you can analyze it with eg. ).

You can still use this modified tool. Say you want to use DxaDecode to extract contents from older Wolf RPG games but for some reason can't use DXExtract, the code for them in DXExtract is B39DA084D737531FF1081880. If we decode that back to the original key that was used, we get "76 217 42 183 40 155 172 7 62 119 236 76". Each number represents an ASCII character, small numbers don't have any ASCII counterpart and some of them like 62 are escape characters (>), so DxaDecode will fail to work as it can't read the key. With the edited version it's possible to input those impossible characters and decode the files. The included DEC versions are made and compiled from the latest source code at the time of posting (v1.06)... Or you could use these to troll someone and hand them a custom made archive.

How to use DxaDecodeDEC (example):
Code:
DxaDecodeDEC 76 217 42 183 40 155 172 7 62 119 236 76 EV-PIC.wolf
It's also easy to encode loose files back to archives with the tools provided, so translators can make archives that are compatible with the game after editing the source files without having to use the UI of eg. WOLF RPG Editor.

How to use DxaEncodeDEC (example):
Code:
DxaEncodeDEC 76 217 42 183 40 155 172 7 62 119 236 76 BasicData
It will create BasicData.dxa that you can rename to BasicData.wolf and it'll work with the game.

Requirements
tools.jar needs JRE from:



Included in this post are...
tool.zip - a simple tool that can take the encoded HEX (base 16) string, bruteforce it and decode it to DEC (base 10) and regular printable text/ASCII. It can also convert a string into encoded HEX (Windows/Linux/MacOS)
DxaDecodeDEC.zip - Altered version of DxaDecode that uses integers instead of characters as input for keystring (Windows only)
DxaEncodeDEC.zip - Altered version of DxaEncode that uses integers instead of characters as input for keystring (Windows only)

There's not much error checking in the files. They work with the correct input, will probably crash and burn with incorrect.


Remember to hit that "Add to reputation" button
.
ToxicShock said:
no trust in files shared by someone with red rep and <20 posts.
 

Attachments

Last edited:

Hi10Foo

Newbie
Joined
Oct 16, 2014
Messages
7
Reputation score
12
Attached is my command-line tool for extracting DXA files (v1 to v6, though I only tested against v4 and v6 files since that's what I could find).

To extract:
DXArc e "BasicData.wolf" -p 38504028724F21703B733538
where 38504028724F21703B733538 is the hex-encoded password (in this case "8P@(rO!p;s58").

It can also try to guess the password:
DXArc b "BasicData.wolf"

Source code is included.
 

Attachments

JustLurksHere

Jungle Girl
Joined
Oct 28, 2016
Messages
558
Reputation score
45
As I noted (perhaps here, but possibly elsewhere), there might be a problem coming...
If the author of WolfRPG Editor or any other engine using DXLib decides to update, v7 format looks like a major problem for reversing.
Some of the solutions used are borderline Stormlib.
Also, the header won't be as good a source of info for reversing.

Edit: so, I see you've at least implemented those parts of v7 that are covered by upstream implementation...
Yet, that's not the tricky part...
 
Last edited:

Hi10Foo

Newbie
Joined
Oct 16, 2014
Messages
7
Reputation score
12
I implemented part of v7. I didn't have any files to test with, so I didn't bother trying to complete it. (If anyone knows of any v7 files that use a known password, I'd be happy to finish it, but you might as well use the DXLib tools.)

But yes, the v7 encryption scheme is not so easily broken and would probably require discovering the password in the executable to extract the files.

Then there is v8, which changed the encryption scheme yet again (though it may be more easily broken than v7 if the password is short enough).
 
Last edited:
OP
steveju

steveju

Demon Girl
Joined
Jun 24, 2016
Messages
81
Reputation score
39
v1.08 that accepts decimal input.

As for the password to decrypt new WolfRPG titles... Maximum key length has increased from 12 to 56 characters (integer between 0-255). This should work if you find out the key.

NOTE:
This can decode old WolfRPG titles that use the 76,217,42,183,40,155,172,7,62,119,236,76 key, but can't decode slightly newer titles that use the 56,80,64,40,114,79,33,112,59,115,53 (aka. 8P@(rO!p;s5) key. The unmodified DxaDecode v1.08 can't decode either of those, because the key input is limited to printable ASCII and the modifications to non V5 archive encryption/decryption in DXLib broke the older archive handling... or if you want to split hairs on it, they "removed" the older archive handling.

EDIT: Made the exes standalone, no need to install mingw32... Oh, and the new WolfRPG titles are definitely using v8 archives, since "DX" is in plaintext in the first bytes of the wolf archives. That's a feature only possible with v1.08
 

Attachments

Last edited:

JustLurksHere

Jungle Girl
Joined
Oct 28, 2016
Messages
558
Reputation score
45
@steveju: if you're using the code from upstream, you should have noticed that they've simply removed the code handling older archive versions.
 
OP
steveju

steveju

Demon Girl
Joined
Jun 24, 2016
Messages
81
Reputation score
39


Someone found or figured out the decryption key.

It's WLFRPrO!p(;s5((8P@((UFWlu$#5(=
Or 87,76,70,82,80,114,79,33,112,40,59,115,53,40,40,56,80,64,40,40,85,70,87,108,117,36,35,53,40,61 in decimal.
 

1130155732

New member
Joined
Nov 20, 2021
Messages
1
Reputation score
1
Hi steveju, do you know if there is anyone figured out the key of ASTLIBRA-Revision?
 

Anticor

Demon Girl
Joined
Oct 25, 2013
Messages
65
Reputation score
23
Hi steveju, do you know if there is anyone figured out the key of ASTLIBRA-Revision?
Wondering the same thing actually. Xentax is dead now, and reduced chat room on Discord, unfortunately. Very hard to get info on this kind of thing now.
 
Top