[RELEASE] - DiscDump.py Python Disc Dumper

Discussion in 'Wii U - Hacking & Backup Loaders' started by TheCyberQuake, Nov 20, 2016.

  1. TheCyberQuake
    OP

    TheCyberQuake Certified Geek

    Member
    2,719
    1,609
    Dec 2, 2014
    United States
    Las Vegas, Nevada
    I got bored and decided to write a basic python script that will create a 1:1 decrypted ("loadiine-ready") game dump to the SD card. It will automatically find the titleID of the game, create a the folder /gamedumps/*titleID*, and then dump the disc's code, content and meta folders there.

    The main use I can see wit this it to dump disc-only games that can't be downloaded from NUS, repack them with NUSPacker and then install them to redNAND/sigpatched sysNAND. I've seen many people have issues trying to do this with current "loadiine-ready" dumps because they were made with DDD which will not give a 1:1 dump of the game.

    I believe this is currently the fastest way to dump a game as it dumps straight to SD, unlike DDD which would dump over the network to a computer.

    All you need is wupclient.py in the same folder and have it modified it to have your Wii U's IP address. Then just run any fw.img to load wupserver on the Wii U and then run DiscDump.py

    Also I won't say I'm a perfect programmer, so if you see anything in my script I can improve or change feel free to let me know!

    https://mega.nz/#!4QVxRTBK!Dk8aGwF2n5yUielabiuSvpBU6hrqnw8z-Rwu0udhVAI

    Code:
    import wupclient
    
    def isdir(path):
        if path[0] != "/" and w.cwd[0] == "/":
            return isdir(w.cwd + "/" + path)
        fsa_handle = w.get_fsa_handle()
        ret, dir_handle = w.FSA_OpenDir(fsa_handle, path if path != None else w.cwd)
        if ret == 0:
            w.FSA_CloseDir(fsa_handle, dir_handle)
            return True
        else:
            return False
    
    """Connect to wupserver"""
    print("Connecting to wupserver")
    w = wupclient.wupclient()
    if(w.s == None):
        input("Failed to connect to wupserver!")
        sys.exit(1)
    print("Connected!")
    wupclient.w = w
    
    """Mount SD card for dumping"""
    print("Mounting SD")
    ret = wupclient.mount_sd()
    if(ret == 0):
        input("Failed to mount SD! Press enter to quit.")
        sys.exit(1)
    
    """Mount optical disc content for dumping"""   
    print("Mounted! Mounting optical disc content")
    ret = wupclient.mount_odd_content()
    if(ret == 0):
        input("Failed to mount optical disc! Press enter to quit.")
        sys.exit(1)
    
    """Download meta.xml from disc to pull title ID"""
    print("Downloading meta.xml to obtain title ID")
    ret = w.dl("/vol/storage_odd_content/meta/meta.xml")
    if(ret == 0):
        input("Failed to download meta.xml! Press enter to quit.")
        sys.exit(1)
    
    """Grab title ID from downloaded meta.xml"""
    print("Grabbing title ID from meta.xml")
    import xml.etree.ElementTree as ET
    tree = ET.parse("meta.xml")
    root = tree.getroot()
    for child in root:
        if(child.tag.startswith("title_id")):
            titleID = child.text
    
    """Make directories on SD to dump to"""
    print("Creating directories on SD to dump to")
    if isdir("/vol/storage_sdcard/gamedumps"):
        if not(isdir("/vol/storage_sdcard/gamedumps/" + titleID)):
            ret = w.mkdir("/vol/storage_sdcard/gamedumps/" + titleID, 0x600)
            if(ret != 0):
                print("Failed to make directory on SD to dump to.")
                input("Press enter to quit.")
                sys.exit(1)
    else:
        ret = w.mkdir("/vol/storage_sdcard/gamedumps", 0x600)
        if(ret != 0):
            print("Failed to make directory on SD to dump to.")
            input("Press enter to quit.")
            sys.exit(1)
        else:
            ret = w.mkdir("/vol/storage_sdcard/gamedumps/" + titleID, 0x600)
            if(ret != 0):
                print("Failed to make directory on SD to dump to.")
                input("Press enter to quit.")
                sys.exit(1)
    
    """Use cpdir() to dump disc contents to SD"""
    print("Dumping decrypted disc contents")
    ret = w.cpdir("/vol/storage_odd_content", "/vol/storage_sdcard/gamedumps/" + titleID)
    if(ret == 0):
        input("Game dump failed! Press enter to quit")
        sys.exit(1)
    else:
        print("Game dump compete!")
        input("Press enter to exit.")
    
     
    Last edited by TheCyberQuake, Nov 20, 2016


  2. Wolfy

    Wolfy Person That Never Was

    Member
    536
    202
    Aug 18, 2015
    United States
    Somewhere In The Aether...
    Holy crap, thanks :3

    Amazed that this wasn't already a thing, but to do it "since you were bored"..........sweeeeeeeeeeeet.
     
  3. zeldaism

    zeldaism GBAtemp Advanced Fan

    Member
    605
    173
    Apr 19, 2016
    United States
    Thank you for this amazing script. Will try it out when I get home.
     
  4. pietempgba

    pietempgba GBAtemp Advanced Fan

    Member
    812
    132
    Jun 9, 2016
    United States
    im going to make it download a game from the wiiu to the sd card
     
  5. TheCyberQuake
    OP

    TheCyberQuake Certified Geek

    Member
    2,719
    1,609
    Dec 2, 2014
    United States
    Las Vegas, Nevada
    A couple simple modifications could probably make it dump any title, though I haven't looked into how game files are stored on Wii U when installed.

    — Posts automatically merged - Please don't double post! —

    When I get bored I poke around and test wupserver commands to see if I can do anything cool with it. I found several days ago you could copy files directly to/from the SD/Wii U. I've also looked at python scripts by other users to learn how to do useful things with python (like pulling titleID from meta.xml)
     
  6. pietempgba

    pietempgba GBAtemp Advanced Fan

    Member
    812
    132
    Jun 9, 2016
    United States
    I have a file directory structure here you go

    the x's are the last 8 letters and numbers of the title id
    Code:
    \storage_mlc\sys\title\00050010\XXXXXXXX
    \storage_mlc\sys\title\0005001b\XXXXXXXX
    \storage_mlc\sys\title\00050030\XXXXXXXX
    
    
    \storage_mlc\usr\title\00050000\XXXXXXXX
    \storage_mlc\usr\title\0005000c\XXXXXXXX
    \storage_mlc\usr\title\0005000e\XXXXXXXX
    
    
    \storage_usb\usr\title\00050000\XXXXXXXX
    \storage_usb\usr\title\0005000c\XXXXXXXX
    \storage_usb\usr\title\0005000e\XXXXXXXX
    
     
    Last edited by pietempgba, Nov 20, 2016
  7. TheCyberQuake
    OP

    TheCyberQuake Certified Geek

    Member
    2,719
    1,609
    Dec 2, 2014
    United States
    Las Vegas, Nevada
    I can probably write all the code to do it right now, but I can't test it right now as I'm currently dumping Star Fox Zero as a test of the script in OP.
    Do you know what the differences are with the first part of the title ID (0005xxxx)?
     
  8. pietempgba

    pietempgba GBAtemp Advanced Fan

    Member
    812
    132
    Jun 9, 2016
    United States
    yeah
    00050000 are for the games themselves
    0005000c is eShop title dlc
    0005000e are updates for games

    totally random question below

    how do i become at least a certified geek do i just post alot?
     
    Last edited by pietempgba, Nov 20, 2016
  9. TheCyberQuake
    OP

    TheCyberQuake Certified Geek

    Member
    2,719
    1,609
    Dec 2, 2014
    United States
    Las Vegas, Nevada
    Nah, that's just a custom title I gave myself. You can make your title say anything you want by editing your custom title from the personal details page:
    http://gbatemp.net/account/personal-details
     
  10. pietempgba

    pietempgba GBAtemp Advanced Fan

    Member
    812
    132
    Jun 9, 2016
    United States
    then how do i become a gbatemp maniac i mean

    — Posts automatically merged - Please don't double post! —

    i changed my title
     
  11. yahoo

    yahoo G͝B͢A͜t͞em҉p̡ R̨e͢g̷ul̨aŗ

    Member
    339
    236
    Aug 4, 2014
    United States
    Have any idea how to dump the encrypted contents of the disc so it's directly installable with wupinstaller with the the signed ticket from the disc?
     
  12. TheCyberQuake
    OP

    TheCyberQuake Certified Geek

    Member
    2,719
    1,609
    Dec 2, 2014
    United States
    Las Vegas, Nevada
    Post count of 1,000 I believe, but don't just post a bunch of nonsense to get that status. Just give it time of being an active member of the forums and you'll get there.

    Anyway, going back on topic I'm still duming star fox zero, which had a ton of small files. I may have to let it go overnight if it doesn't finish in the next two hours. But I must make sure I can get a full dump.

    Also to note, you can also use the command mount_odd_update(), which seems to have update files. Unsure if this is updates for the game, or system updates baked into the disc, or maybe both. I'll have to look into it later to see what it comes up with. It seems to dump encrypted files (.app), but I didn't let it finish to see what I would get. Maybe tomorrow.

    — Posts automatically merged - Please don't double post! —

    At this point there is no way to dump encrypted content from a disc. To dump WUD you need a hardmod afaik.
    But we do have signature patches at this point, so you could use NUSpacker to encrypted the unencrypted files and then install to redNAND or sysNAND with signature patches.
     
  13. pietempgba

    pietempgba GBAtemp Advanced Fan

    Member
    812
    132
    Jun 9, 2016
    United States
    im pretty sure the signed ticket is in storage_odd_tickets
     
  14. TheCyberQuake
    OP

    TheCyberQuake Certified Geek

    Member
    2,719
    1,609
    Dec 2, 2014
    United States
    Las Vegas, Nevada
    yes, but that is only the ticket. To install a game you need encrypted files (the files used with wupinstaller), while this dumps decrypted files (loadiine-ready).
     
  15. pietempgba

    pietempgba GBAtemp Advanced Fan

    Member
    812
    132
    Jun 9, 2016
    United States
    the brazillian method is using tickets from discs to install stuff
    exactly so you use utikdownloader with the title.tik or with that title site
    the ticket can download encrypted files
     
  16. TheCyberQuake
    OP

    TheCyberQuake Certified Geek

    Member
    2,719
    1,609
    Dec 2, 2014
    United States
    Las Vegas, Nevada
    Yes, but that method also involves downloading the install files from NUS, which are encrypted files. You can't use just the ticket, you also need the actual install files, which are encrypted. This dumps decrypted files, and thus need to be re-enrypted with NUSpacker

    — Posts automatically merged - Please don't double post! —

    That only works for games that are both disc and eShop. For disc only you can't get them from NUS
     
  17. pietempgba

    pietempgba GBAtemp Advanced Fan

    Member
    812
    132
    Jun 9, 2016
    United States
    im pretty sure i know what im talking about you can use title.tik to download encrypted files
    edit: oh ok sorry for the argument

    — Posts automatically merged - Please don't double post! —

    ohh so you can get the long lost luigi u that is only a few gb instead of 15 like nsmbu + nslu
     
  18. wicksand420

    wicksand420 GBAtemp Fan

    Member
    439
    135
    Nov 13, 2016
    United States
    Hi TheCyberQuake, Nice py. I was wondering if you looked up ft2sd? It's a homebrew application that dumps tik, disc content, and odds and also a lot of other interesting things to SD. You don't need to be connected to a server either so no worry of connection issues. Happy Hacking!
     
    Last edited by wicksand420, Nov 20, 2016
    Conn0r likes this.
  19. TheCyberQuake
    OP

    TheCyberQuake Certified Geek

    Member
    2,719
    1,609
    Dec 2, 2014
    United States
    Las Vegas, Nevada
    I saw it, but make is giving me issues for some reason so I need to look into it later.

    Sent from my SM-G386T using Tapatalk
     
  20. wicksand420

    wicksand420 GBAtemp Fan

    Member
    439
    135
    Nov 13, 2016
    United States
    I wanted to try out your app but Skylanders is taking forever to dump, I've been at it for 16 hours and its not done with the nfc figure data yet. It hasn't even gotten to the game data yet. Hopefully starfox isn't taking you this long.