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

Discussion in 'Wii U - Hacking & Backup Loaders' started by makikatze, May 9, 2016.

  1. makikatze
    OP

    makikatze Newbie

    Newcomer
    8
    16
    May 9, 2016
    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.
     

    Attached Files:

    Last edited by makikatze, May 9, 2016
    pelago, Masterwin, Dr Eggman and 10 others like this.
  2. Frustalupi

    Frustalupi Newbie

    Newcomer
    2
    0
    Oct 27, 2015
    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
     
  3. makikatze
    OP

    makikatze Newbie

    Newcomer
    8
    16
    May 9, 2016
    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.
     
  4. link270

    link270 GBAtemp Regular

    Member
    121
    73
    Jul 15, 2009
    United States
    Awesome! I'm a mac user as well, and it's nice to see some applications pop up that are cross-platform like this.
     
    makikatze likes this.
  5. makikatze
    OP

    makikatze Newbie

    Newcomer
    8
    16
    May 9, 2016
    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.
     
  6. jimmyleen

    jimmyleen GBAtemp Maniac

    Member
    1,160
    197
    Feb 28, 2016
    What is needed to run this on Linux? I ask because it will not run at all...not even as a program.
     
  7. makikatze
    OP

    makikatze Newbie

    Newcomer
    8
    16
    May 9, 2016
    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.
     
  8. OuahOuah

    OuahOuah GBAtemp Advanced Fan

    Member
    991
    200
    Oct 2, 2006
    France
    France
    What are eactly the 4 "partition identifier" ? What does letters mean ?
    Why GM only for game data ?
    Any info ?
    Just to be curious ;)
     
  9. makikatze
    OP

    makikatze Newbie

    Newcomer
    8
    16
    May 9, 2016
    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 ;)
     
    OuahOuah likes this.
  10. OuahOuah

    OuahOuah GBAtemp Advanced Fan

    Member
    991
    200
    Oct 2, 2006
    France
    France
    OMG, thanks, that fully detailed :)

    Wondering how scene release groups can have the disc key with the game :D
     
  11. makikatze
    OP

    makikatze Newbie

    Newcomer
    8
    16
    May 9, 2016
    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, May 11, 2016
    OuahOuah likes this.
  12. OuahOuah

    OuahOuah GBAtemp Advanced Fan

    Member
    991
    200
    Oct 2, 2006
    France
    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 ?
     
  13. makikatze
    OP

    makikatze Newbie

    Newcomer
    8
    16
    May 9, 2016
    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.
     
    OuahOuah likes this.
  14. Whovian NineThreeSixNine

    Whovian NineThreeSixNine Advanced Member

    Newcomer
    74
    41
    May 3, 2016
    United States
    Just found this.

    The one time that I don't get a .key file with a release... :P

    edit: What's your preferred Hex Editor?
     
  15. makikatze
    OP

    makikatze Newbie

    Newcomer
    8
    16
    May 9, 2016
    Gambia, The
    It's HxD on Windows and Hex Fiend on OSX and wxHexEditor on Linux :)
     
  16. Whovian NineThreeSixNine

    Whovian NineThreeSixNine Advanced Member

    Newcomer
    74
    41
    May 3, 2016
    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, May 13, 2016
  17. OuahOuah

    OuahOuah GBAtemp Advanced Fan

    Member
    991
    200
    Oct 2, 2006
    France
    France
    There's a GitHub Issue about key files ;)
    https://github.com/maki-chan/wudecrypt/issues/2
     
  18. Whovian NineThreeSixNine

    Whovian NineThreeSixNine Advanced Member

    Newcomer
    74
    41
    May 3, 2016
    United States
    OuahOuah likes this.
  19. Whovian NineThreeSixNine

    Whovian NineThreeSixNine Advanced Member

    Newcomer
    74
    41
    May 3, 2016
    United States
    Any updates on this, by chance? I'm seeing that the last commit was about a 1m20d ago, so I'm quite curious :)
     
  20. Shade4510

    Shade4510 Newbie

    Newcomer
    1
    0
    Mar 18, 2017
    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.