Hacking WUDecrypt - A cross-platform tool to decrypt Wii U Disc images

makikatze

Member
OP
Newcomer
Joined
May 9, 2016
Messages
8
Trophies
0
Age
27
XP
63
Country
Gambia, The
Hi folks,

I am totally new here on GBATemp, but I thought, why not start with something for you.

I know there is DiscU.exe and VGMToolbox to decrypt Wii U Disc images (.wud) if you have the disc key and the common key, but I usually sit in front of my Macbook and both applications only work on Windows (VGMToolbox didn't compile or run with Mono and DiscU.exe isn't a C# application anyway, so both of them didn't work).

That's why I decided to just code my own WUD decryption tool. And because I am a friend of OSS and most probably a soon-to-come Free Software Foundation member, it was clear that I have to release the source code.

It's for sure not the best work and the code has to be optimized and cleaned, there's almost NO documentation about the code itself right now, but you can view it on Github here:

https://github.com/maki-chan/wudecrypt

The README file should tell you everything you need to know, but if there are any questions, I'll try to answer them in here.

Have fun decrypting WUD images on Windows, OSX and Linux ;)

EDIT: Added Linux and OSX binary. Windows will be uploaded by tomorrow, just too tired now and only wanted to push something out before I go to bed.

EDIT2: Added Windows build, though it's untested right now. Would be nice if somebody could give me feedback about the builds :)

EDIT3: Fixed some (non-critical) code defects including 3 minor memory leaks, pushing WUDecrypt to v0.1.1.
 

Attachments

  • wudecrypt-0.1.1-linux.zip
    18.7 KB · Views: 450
  • wudecrypt-0.1.1-osx.zip
    16.4 KB · Views: 374
  • wudecrypt-0.1.1-win.zip
    104 KB · Views: 2,190
Last edited by makikatze,

Frustalupi

New Member
Newbie
Joined
Oct 27, 2015
Messages
2
Trophies
0
Age
40
XP
37
Country
Swaziland
Hi,
thank you very much for the WUD decrypter :)
I have Linux but not Bakefile... how can I compile and run it ?

thank you
 

makikatze

Member
OP
Newcomer
Joined
May 9, 2016
Messages
8
Trophies
0
Age
27
XP
63
Country
Gambia, The
Hi Frustalupi,

your best bet would be to have Python 2 installed (bakefile needs it) and then just use their latest release. You can find the download here:
https://github.com/vslavik/bakefile/releases

You would need the bakefile-1.2.5.1_beta-bin.tar.bz2. Extract it go into the newly generated directory "bakefile-1.2.5.1_beta" and then use bakefile like this:
Code:
./bkl /path/to/wudecrypt.bkl

I hope that helps :)

Though I also uploaded the 0.1 binaries here and on Github. I didn't made any changes to the code after that. At least not yet.
 

makikatze

Member
OP
Newcomer
Joined
May 9, 2016
Messages
8
Trophies
0
Age
27
XP
63
Country
Gambia, The
@link270 Thanks, that was totally my intention. To push cross-platform coding forward, especially in the Wii U scene.

New version out, v0.1.1.
Releases for all three operating systems are attached to the first post and can be found on the Github releases page.
 

makikatze

Member
OP
Newcomer
Joined
May 9, 2016
Messages
8
Trophies
0
Age
27
XP
63
Country
Gambia, The
@jimmyleen It is a standard C application that only includes standard C headers that come with every linux. It does run on my Arch Linux VM, my Arch Linux server and my Debian server (though I did not test to decrypt an image yet).

Could you take a look at if the application has execution rights?
Furthermore, it is a command-line program. If you tried to execute it from your file explorer, it most probably just closed before you saw it, as the program terminates right after it prints a small usage header to the console if it wasn't called with the needed command-line arguments.
 

makikatze

Member
OP
Newcomer
Joined
May 9, 2016
Messages
8
Trophies
0
Age
27
XP
63
Country
Gambia, The
@OuahOuah

The "partition identifier" is a two character code for the type of the "partition" on the disc. Every Wii U Disc has different partitions, just like you can have partitions on your HDD. A complete example for a partition name would be "UP000500101004620000000004CF00" for the 5.3.2 update partition on Mario Party 10 (EUR image).

The following partition types are known to me:
  • SI: Contains information about the other partitions, for example partition keys for GM partitions (each GM partition has its own key for encryption/decryption)
  • UP: Contains a system firmware update
  • GI: Never seen it before, though it seems to be something similar to SI
  • GM: Contains game data (the "content", "code" and "meta" folder you maybe already know)
SI, UP and GI partitions are encrypted with the disc specific key, while GM partitions are encrypted with a partition-specific key that is stored in TITLE.TIK files in the SI (or GI?) partitions. The TITLE.TIK file itself is encrypted with the Wii U common key (that's why you need the disc specific key and the common key to extract an image).

WUDecrypt allows you to extract only specific types of partitions, as to play a game, you would only need to extract the GM partition and could discard the data from the UP partitions, as you won't want to extract the unneeded system firmware update. Though some curious people may still want to extract everything and that's why WUDecrypt usually does that ;)
 
  • Like
Reactions: OuahOuah

OuahOuah

Well-Known Member
Member
Joined
Oct 2, 2006
Messages
1,063
Trophies
0
Age
44
Location
France
Website
www.ouahouah.eu
XP
709
Country
France
@OuahOuah

The "partition identifier" is a two character code for the type of the "partition" on the disc. Every Wii U Disc has different partitions, just like you can have partitions on your HDD. A complete example for a partition name would be "UP000500101004620000000004CF00" for the 5.3.2 update partition on Mario Party 10 (EUR image).

The following partition types are known to me:
  • SI: Contains information about the other partitions, for example partition keys for GM partitions (each GM partition has its own key for encryption/decryption)
  • UP: Contains a system firmware update
  • GI: Never seen it before, though it seems to be something similar to SI
  • GM: Contains game data (the "content", "code" and "meta" folder you maybe already know)
SI, UP and GI partitions are encrypted with the disc specific key, while GM partitions are encrypted with a partition-specific key that is stored in TITLE.TIK files in the SI (or GI?) partitions. The TITLE.TIK file itself is encrypted with the Wii U common key (that's why you need the disc specific key and the common key to extract an image).

WUDecrypt allows you to extract only specific types of partitions, as to play a game, you would only need to extract the GM partition and could discard the data from the UP partitions, as you won't want to extract the unneeded system firmware update. Though some curious people may still want to extract everything and that's why WUDecrypt usually does that ;)

OMG, thanks, that fully detailed :)

Wondering how scene release groups can have the disc key with the game :D
 

makikatze

Member
OP
Newcomer
Joined
May 9, 2016
Messages
8
Trophies
0
Age
27
XP
63
Country
Gambia, The
Most probably, but that's just a guess, they have something special attached to a legit Wii U or something and they can read its memory. The Wii U could store the key somewhere in memory and they know where.

But they could of course also have something very special they built themselves to read the disc itself and to get the title key.
 
Last edited by makikatze,
  • Like
Reactions: OuahOuah

OuahOuah

Well-Known Member
Member
Joined
Oct 2, 2006
Messages
1,063
Trophies
0
Age
44
Location
France
Website
www.ouahouah.eu
XP
709
Country
France
What is the format for common key and title key files ?
Just plain text with one line ?
Like a common.txt and inside one line with D7XXXXXXXX ?
Same for title key file ?
 

makikatze

Member
OP
Newcomer
Joined
May 9, 2016
Messages
8
Trophies
0
Age
27
XP
63
Country
Gambia, The
@OuahOuah
No, currently, WUDecrypt needs binary files of the keys (like the ones you already get with scene releases). So you cannot just post the key as plaintext into the files. You have to use a hex editor or something similar to get every byte of the key into it's binary form. It should be 16 bytes long afterwards and bytes are two hexadecimal characters long (e.g. D7 FF FF FF FF, and so on).

Though I could also add the possibility to read plaintext keys if the file extension ends with .txt
I will add this as a Feature Request on the Github sources.
 
  • Like
Reactions: OuahOuah

Whovian NineThreeSixNine

Well-Known Member
Newcomer
Joined
May 3, 2016
Messages
95
Trophies
0
XP
754
Country
United States
Cheers dude!

Time to screw with some .key files...

Edit: Okay, me again. Hi. What's your suggestion for creating the .bin files manually?

Edit 2: I've seen TitleKeys in NFO files more than its own dedicated .key file, sooo :P

Edit 3: I'm totally not spamming F5 every minute or two to see if you answered :P
 
Last edited by Whovian NineThreeSixNine,

OuahOuah

Well-Known Member
Member
Joined
Oct 2, 2006
Messages
1,063
Trophies
0
Age
44
Location
France
Website
www.ouahouah.eu
XP
709
Country
France

Shade4510

New Member
Newbie
Joined
Mar 18, 2017
Messages
1
Trophies
0
Age
33
XP
32
Country
Canada
I am having trouble extracting the GM partition with two separate WUD files. It keeps telling me the partition has no valid file table signature. Can anyone help me with this or point me in the right direction? Thanks.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
    KenniesNewName @ KenniesNewName: Lol they have detergent in wine style boxes new fad incoming