Homebrew [GM9][Script]All-in-One Megascript

  • Thread starter Thread starter annson24
  • Start date Start date
  • Views Views 82,767
  • Replies Replies 118
  • Likes Likes 21
Status
Not open for further replies.
Code:
####################Dump Home Menu to .cia####################

@Dump_Options_Dump_HomeMenu_to_.cia
set PREVIEW_MODE "GODMODE9 ALL-IN-ONE MEGASCRIPT\nby annson24\n \nDump Options\n>HomeMenu to .cia Dump"

if    not ask "Dump HomeMenu to .cia?\n \nPlease make sure you have\nenough storage space."
    goto MainMenu_Dump_Options
end

set OUTPATH "0:/gm9/out"        <-----------ADD THIS INITIALIZATION (But not this text obviously)
set CIA2 "$[OUTPATH]/homemenu.cia"


echo "$[REGION] region detected."

if chk $[REGION] "JPN"
    find $[OUTPATH]/0004003000008202* CIA1
elif chk $[REGION] "USA"
    find $[OUTPATH]/0004003000008F02* CIA1
elif chk $[REGION] "EUR"
    find $[OUTPATH]/0004003000009802* CIA1
elif chk $[REGION] "CHN"
    find $[OUTPATH]/000400300000A102* CIA1
elif chk $[REGION] "KOR"
    find $[OUTPATH]/000400300000A902* CIA1
elif chk $[REGION] "TWN"
    find $[OUTPATH]/000400300000B102* CIA1
elif chk $[REGION] "UNK"
    echo "Unknown Region.\nPlease contact the script author.\Aborting."
    goto MainMenu_Dump_Options
else
    echo "Operation failed."
    goto MainMenu_Dump_Options
end

mv -w -n $[CIA1] $[CIA2]
echo "HomeMenu Dumped in:\n$[OUTPATH]"

if    ask "Decrypt $[CIA2]?"
    decrypt $[CIA2]
    echo "$[CIA2] decrypted"
 
else
    echo "Decrypt declined."
 
end
goto MainMenu_Dump_Options

@annson24, see if this reduces clutter without breaking function. :P


Edit - Hey, in case you adjust the code like that posted above, I need to share with you this info about using elif with if and end. It doesn't appear that to be correct when using else with elif in the big if/end. Else in a sub if / end is fine if it's only binary (true/false).

Allowed
Code:
if [argument statement]
[your action(s) if true]
else
[your action(s) if false]
end

Allowed
Code:
if [argument statement]
[your action(s) if true]
elif [Skip to this argument statement if previous argument is false.]
[your action(s) if true]
elif [Skip to this argument statement if previous argument is false.]
[your action(s) if true]
.
.
.
elif [Final argument statement]
[your action(s) if true]
end

Not Allowed (Maybe allowed??)
Code:
if [argument statement]
[your action(s) if true]
elif [Skip to this argument statement if previous argument is false.]
[your action(s) if true]
elif [Skip to this argument statement if previous argument is false.]
[your action(s) if true]
.
.
.
else
[your action(s) if all previous arguments are false]
end

Edit #?? - Nvm. I think with else, you don't provide an argument. You're telling that if / end to default to doing that last action(s) when all other arguments fail.
 
Last edited by TurdPooCharger,
  • Like
Reactions: annson24
@annson24
I figured out what was wrong with your Dump Home Menu Script.
You set up CIA2 and all the CIA1 paths to include OUTPATH, but forgot to initialize OUTPATH.

Well, this lets me enjoy my coffee break. lol.
Thanks guys. Last night I was assuming that OUTPATH was a default var. kek. Will check the new one @8BitWonder but will also check the one from @TurdPooCharger.
Edit #?? - Nvm. I think with else, you don't provide an argument. You're telling that if / end to default to doing that last action(s) when all other arguments fail.
Exactly. :) EDIT: You forgot to include the building of cia from the tmd in your script.
 
Last edited by annson24,
Exactly. :) EDIT: You forgot to include the building of cia from the tmd in your script.
Heh. Touché. I fixed and tested this revision. It doesn't reduces lines that much but does decouples the find TMD and CIA1.

Code:
####################Dump Home Menu to .cia####################

@Dump_Options_Dump_HomeMenu_to_.cia
set PREVIEW_MODE "GODMODE9 ALL-IN-ONE MEGASCRIPT\nby annson24\n \nDump Options\n>HomeMenu to .cia Dump"

if    not ask "Dump HomeMenu to .cia?\n \nPlease make sure you have\nenough storage space."
    goto MainMenu_Dump_Options
end

set OUTPATH "0:/gm9/out"
set CIA2 "$[OUTPATH]/homemenu.cia"

echo "$[REGION] region detected."

if chk $[REGION] "JPN"
    find 1:/title/00040030/00008202/content/*.tmd TMD
elif chk $[REGION] "USA"
    find 1:/title/00040030/00008F02/content/*.tmd TMD
elif chk $[REGION] "EUR"
    find 1:/title/00040030/00009802/content/*.tmd TMD
elif chk $[REGION] "CHN"
    find 1:/title/00040030/0000A102/content/*.tmd TMD
elif chk $[REGION] "KOR"
    find 1:/title/00040030/0000A902/content/*.tmd TMD
elif chk $[REGION] "TWN"
    find 1:/title/00040030/0000B102/content/*.tmd TMD
elif chk $[REGION] "UNK"
    echo "Unknown Region.\nPlease contact the script author.\Aborting."
    goto MainMenu_Dump_Options
end

if buildcia $[TMD]
    if chk $[REGION] "JPN"
        find $[OUTPATH]/0004003000008202* CIA1
    elif chk $[REGION] "USA"
        find $[OUTPATH]/0004003000008F02* CIA1
    elif chk $[REGION] "EUR"
        find $[OUTPATH]/0004003000009802* CIA1
    elif chk $[REGION] "CHN"
        find $[OUTPATH]/000400300000A102* CIA1
    elif chk $[REGION] "KOR"
        find $[OUTPATH]/000400300000A902* CIA1
    elif chk $[REGION] "TWN"
        find $[OUTPATH]/000400300000B102* CIA1
    end
else
    echo "Operation failed."
    goto MainMenu_Dump_Options
end

mv -w -n $[CIA1] $[CIA2]
echo "HomeMenu Dumped in:\n$[OUTPATH]"

if    ask "Decrypt $[CIA2]?"
    decrypt $[CIA2]
    echo "$[CIA2] decrypted"
 
else
    echo "Decrypt declined."
 
end
goto MainMenu_Dump_Options
 
  • Like
Reactions: annson24
That is pretty nice, it turns GodMode9 into a proper replacement for Decrypt9.
Could I request nnidsave.bin and SecureInfo_A/SecureInfo_C/movable.sed (SecureInfo_C is simply an alternate file supported by Luma so as to not touch the original, not 100% sure if it's still supported though) backup/restore?
nnidsave.bin is useful for removing the NNID from a console by injecting a blank one, or possibly for having multiple NNIDs and switching between them (might allow using eShop for different countries in the same region?)
SecureInfo is mostly for region changing and unbanning.
movable.sed is useful for de/encrypting SD card data on a PC, or for using things such as the 0-key movable.sed.

Also, the ability to dump ticket.db (and encTitleKeys/decTitleKeys if possible) would be useful, the former is for tools like FunkyCIA2 and the latter has a similar purpose but also makes it easy to submit keys to the title key site.
I'm implementing this at the moment, but I couldn't find the nnidsave.bin, encTitleKeys, and decTitleKeys anywhere. I haven't looked hard enough tho.
 
Last edited by annson24,
I'm implementing this at the moment, but I couldn't find the nnidsave.bin, encTitleKeys, and decTitleKeys anywhere. I haven't looked hard enough tho.
encTitleKeys/decTitleKeys are created from ticket.db so that might be hard to do with a script. Maybe GM9 has built in support for creating encTitleKeys/decTitleKeys but I'm not sure.
nnidsave.bin is in CTRNAND -> data -> (32 Character ID) -> sysdata -> 00010038 in the file named 00000000.
 
encTitleKeys/decTitleKeys are created from ticket.db so that might be hard to do with a script. Maybe GM9 has built in support for creating encTitleKeys/decTitleKeys but I'm not sure.
nnidsave.bin is in CTRNAND -> data -> (32 Character ID) -> sysdata -> 00010038 in the file named 00000000.

GM9 definitely has built in support for creating encTitleKeys, decTitlekeys, and seeddb.bin
 
encTitleKeys/decTitleKeys are created from ticket.db so that might be hard to do with a script. Maybe GM9 has built in support for creating encTitleKeys/decTitleKeys but I'm not sure.
nnidsave.bin is in CTRNAND -> data -> (32 Character ID) -> sysdata -> 00010038 in the file named 00000000.

https://github.com/d0k3/GodMode9

Support files
For certain functionality, GodMode9 may need 'support files'. Support files should be placed into 0:/gm9/support. Support files contain additional information that is required in decryption operations. A list of support files, and what they do, is found below. Please don't ask for support files - find them yourself.

...
  • seeddb.bin: This file is required to decrypt and mount seed encrypted NCCHs and CIAs if the seed in question is not installed to your NAND. Note that your seeddb.bin must also contain the seed for the specific game you need to decrypt.
  • encTitleKeys.bin / decTitleKeys.bin: These files are optional and provide titlekeys, which are required to create updatable CIAs from NCCH / NCSD files. CIAs created without these files will still work, but won't be updatable from eShop.

Support file handling
  • Build decTitleKeys.bin / encTitleKeys.bin / seeddb.bin: Press the HOME button, select More... -> Build support files. decTitleKeys.bin / encTitleKeys.bin can also be created / merged from tickets, ticket.db and other decTitleKeys.bin / encTitleKeys.bin files via the A button menu.

I'm not finding info about nnidsave.bin in the GodMode9 page.

Decrypt9WIP does mention these .bin files. Either there's some secret button combo you press on one of the drives in the menu, or they're not there in GM9.
https://github.com/d0k3/Decrypt9WIP/blob/master/README.md

  • System File Dump...: This allows you to directly dump & decrypt various files of interest from your SysNAND and EmuNAND. These files are included in this feature:
    • ticket.db: Contains titlekeys for installed titles - use this with Cearps FunkyCIA to download installed (legit, purchased) titles directly to your PCs ard drive.
    • title.db: A database of installed titles - apart from informative purposes this doesn't serve a direct purpose for most users at the moment.
    • import.db: A database of titles to be installed - this can be used to get rid of the FW update nag at a later time. Read more on it in this GBAtemp thread.
    • certs.db: A database of certificates - any practical use for this is unknown at the moment.
    • SecureInfo_A: This contains your region and an ASCII serial number - this can be used to temporarily change your 3DS region. The dump / inject options in Decrypt9 simplify the tutorial found here.
    • LocalFriendCodeSeed_B: This contains your FriendCodeSeed - in theory this can be used to import your friend list to another 3DS.
    • movable.sed: This contains the keyY for decryption of data on the SD card - Decrypt9 itself uses this in the SD Decryptor / Encryptor and in SD padgen.

  • System Save Dump...: This allows you to directly dump & decrypt various system saves from your SysNAND and EmuNAND. These files are included in this feature:
    • seedsave.bin: Contains the seeds for decryption of 9.6x seed encrypted titles - only the seeds for installed (legit, purchased) titles are included in this. Use SEEDconv (recommended) or the included Python script seeddb_gen.py to extract the seeds from this into the Decrypt9 readable seeddb.bin.
    • nagsave.bin: Contains some data relating to system updates - it is possible to block automatic system updates (ie. the 'update nag') with this file. Research is still in progress. Read this and the posts after it for more information.
    • nnidsave.bin: Contains your NNID data - this can be used to reset / remove the NNID from your system, without removing any other data. See here for instructions.
    • friendsave.bin: Contains your actual friendlist - this can be used to backup and restore your friendlist in conjunction with LocalFriendCodeSeed_B. Also see here.
    • configsave.bin: The config savegame - this contains various things that are set via the config menu. It also contains a flag telling the system that initial setup was already executed.
 
  • Like
Reactions: The Real Jdbye
https://github.com/d0k3/GodMode9





I'm not finding info about nnidsave.bin in the GodMode9 page.

Decrypt9WIP does mention these .bin files. Either there's some secret button combo you press on one of the drives in the menu, or they're not there in GM9.
https://github.com/d0k3/Decrypt9WIP/blob/master/README.md
I don't think any of those .bin files are easily findable in GM9 (without knowing the path and filename on NAND), hence why it's nice to have a script that makes them more easily accessible.
GM9 definitely has built in support for creating encTitleKeys, decTitlekeys, and seeddb.bin
Ah, I didn't even think of seeddb.bin, that would be another useful thing to have in the script.
 
Last edited by The Real Jdbye,
The top two thinga in my to-do list is 1. To figure out how to inject FBI to H&S directly, and 2. To figure out how to do a ctrtransfer. But since I'm at a dead end with those two, these requests will be on the next few updates. BTW, I updated the script again a few hours ago. It should now look somewhat like decrypt9 options. I also added an "inject" section.

encTitleKeys/decTitleKeys are created from ticket.db so that might be hard to do with a script. Maybe GM9 has built in support for creating encTitleKeys/decTitleKeys but I'm not sure.
nnidsave.bin is in CTRNAND -> data -> (32 Character ID) -> sysdata -> 00010038 in the file named 00000000.

I think I'll be able to do something about it. Noylt entirely sure yet. Thanks.

Edit: enctittlekey and dectitlekey, I'm also at a dead end just like the other two in my to-do list unless d0k3 implements logging with gm9. I made a feature request for it but he said It's going to be too much work to implement. He's not yet scrapping the request. I hope he'll consider.

Sent from my SM-G950F using Tapatalk
 
Last edited by annson24,
I don't think any of those .bin files are easily findable in GM9 (without knowing the path and filename on NAND), hence why it's nice to have a script that makes them more easily accessible.

Ah, I didn't even think of seeddb.bin, that would be another useful thing to have in the script.

The top two thinga in my to-do list is 1. To figure out how to inject FBI to H&S directly, and 2. To figure out how to do a ctrtransfer. But since I'm at a dead end with those two, these requests will be on the next few updates. BTW, I updated the script again a few hours ago. It should now look somewhat like decrypt9 options. I also added an "inject" section.



I think I'll be able to do something about it. Noylt entirely sure yet. Thanks.

Sent from my SM-G950F using Tapatalk

I'm currently looking into porting the ability of Decrypt9WIP to dumping and injecting SysNAND System Files and System Saves into a gm9 script. EmuNAND will be follow after SysNAND is worked out.

System File: ticket, title, import, certs, SecureInfo_A, LocalFriendCodeSeed_B, and movable.sed
System Save: seedsave, nagsave, nnidsave, friendsave, configsave

Would you like me to hold off in case you're also looking into this, annson24? Right now, I'm doing a reverse search of where each of those files are located using a duplicate program cleaner that checks for hash.
 
Last edited by TurdPooCharger,
I'm currently looking into porting the ability of Decrypt9WIP to dumping and injecting SysNAND System Files and System Saves into a gm9 script. EmuNAND will be follow after SysNAND is worked out.

System File: ticket, title, import, certs, SecureInfo_A, LocalFriendCodeSeed_B, and movable.sed
System Save: seedsave, nagsave, nnidsave, friendsave, configsave

Would you like me to hold off in case you're also looking into this, annson24? Right now, I'm doing a reverse search of where each of those files are located using a duplicate program cleaner that checks for hash.
There is already friendsave dump/inject in the script so it should be as easy as simply copy pasting and modifying the path.
LFCS_B is also already there, and the GodMode9 essentials backup you're prompted to make automatically dumps SecureInfo_A, movable.sed and some other files. Although having all of these in the script wouldn't be a bad idea anyway.
 
There is already friendsave dump/inject in the script so it should be as easy as simply copy pasting and modifying the path.
LFCS_B is also already there, and the GodMode9 essentials backup you're prompted to make automatically dumps SecureInfo_A, movable.sed and some other files. Although having all of these in the script wouldn't be a bad idea anyway.
I have to be honest. I haven't checked the entirety of the AIO megascript as I only took up interest reporting obscure scripts for addition and the latter Dump HomeMenu to cia started several posts back. Now that you mentioned some of these features are already there, I'll just focus on those that are missing.

I listed those in the D9WIP as-is as those were the ones listed in the app. I didn't know those saves and system files are still useful and would have thought GM9 would have those dump/inject options already in place.
 
I'm currently looking into porting the ability of Decrypt9WIP to dumping and injecting SysNAND System Files and System Saves into a gm9 script. EmuNAND will be follow after SysNAND is worked out.

System File: ticket, title, import, certs, SecureInfo_A, LocalFriendCodeSeed_B, and movable.sed
System Save: seedsave, nagsave, nnidsave, friendsave, configsave

Would you like me to hold off in case you're also looking into this, annson24? Right now, I'm doing a reverse search of where each of those files are located using a duplicate program cleaner that checks for hash.

Latest commit of megasceipt already includes ticket, title, secureinfo, localfriendcode, movablesed, and friendsave. Although all of them are only for sysnand. You should continue, I'm in no position to tell you to hold off. And more choices for the end-user would be better.

Sent from my SM-G950F using Tapatalk
 
  • Like
Reactions: TurdPooCharger
Latest commit of megasceipt already includes ticket, title, secureinfo, localfriendcode, movablesed, and friendsave. Although all of them are only for sysnand. You should continue, I'm in no position to tell you to hold off. And more choices for the end-user would be better.

Sent from my SM-G950F using Tapatalk
I don't want two people ending up making the same script. Avoid unnecessarily wasting time and effort. Making sure someone got this. So focus on these only?

ticket.db
title.db
import.db
certs.db
all the saves .bin except for friendsave ??

** Clarifications, one of us codes for the missing files and then two or more of us check the code is good for adding those into the megascript.

Edit - I can provide you the pathways and what the files are called if you want to handle the coding, annson24. I'm not feeling it. Too much keyboarding lol.
 
Last edited by TurdPooCharger,
  • Like
Reactions: annson24
Status
Not open for further replies.

Site & Scene News

Popular threads in this forum