Could Someone Make This Script..?

Discussion in 'NDS - Emulation and Homebrew' started by Sha8q, Sep 3, 2018.

  1. Sha8q
    OP

    Sha8q pls help

    Member
    3
    Mar 31, 2018
    Jamaica
    This might not be the best place to ask, but if I asked this on a random coding forum they would have no idea what I am talking about. I would like to know if someone could make a script for me that will get the CID and Consoleid of a console by using the NO$ block. I need this feature for Relaunch, and this will make everything so much easier for me and the people who are using it. (Relaunch's biggest update is going to have an amazing feature ;)... if I get this script I can make it!)

    (Don't forget that the consoleid is inverted)

    (I prefer the script to be made in batch, but that is probably impossible. I am fine with Python or any common coding language.)

    Thanks -Sha8q
     
    Last edited by Sha8q, Sep 3, 2018
  2. mondul

    mondul Advanced Member

    Newcomer
    3
    Aug 8, 2018
    Colombia
    Barranquilla
    I will try to have some time for that and also to re-code the whole relaunch script in Python so it could be multi platform.
     
    Sha8q likes this.
  3. Sha8q
    OP

    Sha8q pls help

    Member
    3
    Mar 31, 2018
    Jamaica
    Thanks! There is an update that will install Hiya instantly, and it depends on that script!
     
  4. mondul

    mondul Advanced Member

    Newcomer
    3
    Aug 8, 2018
    Colombia
    Barranquilla
    Here you have a short python3 (3.5 onwards) script for finding the eMMC CID and the console ID:
    Code:
    #!/usr/local/bin/python3
    
    import sys
    from os import path
    
    # Initialize NAND filename, path and the default exit code
    nand_file = 'nand.bin'
    nand_path = ''
    exit_code = 0
    
    # Try to get the NAND file from the command line
    if len(sys.argv) > 1:
        nand_path, nand_file = path.split(sys.argv[1])
    
    # Read the NAND file
    try:
        with open(path.join(nand_path, nand_file), 'rb') as f:
            # Go to the No$GBA footer offset
            f.seek(0xF000000)
            # Read the footer's header :-)
            bstr = f.read(0x10)
    
            if bstr == b'DSi eMMC CID/CPU':
                # Read the CID
                bstr = f.read(0x10)
                cid =  bytearray(bstr).hex().upper()
                print('eMMC CID  : ' + cid)
                # Save it to a text file at the same NAND location
                with open(path.join(nand_path, 'CID.txt'), 'w') as ftxt:
                    ftxt.write(cid)
    
                # Read the console ID
                bstr = f.read(8)
                console_id = bytearray(reversed(bstr)).hex().upper()
                print('Console ID: ' + console_id)
                # Save it to a text file at the same NAND location
                with open(path.join(nand_path, 'ConsoleID.txt'), 'w') as ftxt:
                    ftxt.write(console_id)
    
            else:
                print('ERROR: No$GBA footer not found')
                exit_code = 1
    
    except FileNotFoundError:
        print('ERROR: Could not open the file ' + nand_file)
        exit_code = 1
    
    sys.exit(exit_code)
    
    EDiT: Updated code
     
    Last edited by mondul, Sep 5, 2018
    Sha8q likes this.
  5. Sha8q
    OP

    Sha8q pls help

    Member
    3
    Mar 31, 2018
    Jamaica
    Thank you! I am about to finish the update, and it depends on that script!
     
  6. Sha8q
    OP

    Sha8q pls help

    Member
    3
    Mar 31, 2018
    Jamaica
    Hey, could you somehow make it save the consoleid and CID directly to a file? I have tried to do it myself but I have no coding experience in Python. I can also confirm that the script does work!
     
  7. mondul

    mondul Advanced Member

    Newcomer
    3
    Aug 8, 2018
    Colombia
    Barranquilla
    Updated the script with the following features:
    • The NAND file can now be specified from the command line. If not, nand.bin will be used.
    • It will save CID.txt and ConsoleID.txt at the same location as the NAND file.
    • Added an exit code in case of errors.
    • Added comments.
     
    Sha8q likes this.
  8. Sha8q
    OP

    Sha8q pls help

    Member
    3
    Mar 31, 2018
    Jamaica
    Anyone able to make a script that can remove the NO$ fooster from a NAND image? Also is there one that can download the 00000002.app launcher from the CDN and decrypt it?
     
  9. mondul

    mondul Advanced Member

    Newcomer
    3
    Aug 8, 2018
    Colombia
    Barranquilla
    First one already coded and working, tested withNo$GBA, but on Mac it is not removing the read-only flag, that's why I haven't included it yet in my helper script.

    I'm working on the second one on my free time, will let you know when it's done EDiT: @Sha8q Here it is: https://gist.github.com/mondul/a4705c32de1687a7756173596372345c
     
    Last edited by mondul, Oct 3, 2018
    Sha8q likes this.
Loading...