How to get Switch Keys for Hactool/XCI Decrypting

Discussion in 'Switch - Tutorials' started by PRAGMA, Jun 10, 2018.

  1. Silent002

    Silent002 Newbie

    Newcomer
    1
    Jul 8, 2018
    United Kingdom
    Thanks very much for the reply man I appreciate it, but it doesn't look like it worked. I used "hactool keyset=" as well as "hactool --keyset=" but neither seemed to set correctly. I've got a directory in my %userprofile% now, and although prod.keys is in there (and contains all the same keys from keys.txt exactly as they were output from the keys.py script, 40 keys in total) but it's still erroring out with "Invalid NCA Header" when I try to load an NCA. Could it be something wrong with keys.txt itself? Looking at other replies, it seems I've got all the right keys in there.
     

    Attached Files:

  2. dark_samus3

    dark_samus3 GBAtemp Addict

    Member
    9
    May 30, 2015
    United States
    It could be you're missing newer keys needed for the NCA or something. What system version are you on?
     
  3. Silent002

    Silent002 Newbie

    Newcomer
    1
    Jul 8, 2018
    United Kingdom
    Ah that is a possibility, the system I took the keys from is running on version 5.1.0.
     
  4. dark_samus3

    dark_samus3 GBAtemp Addict

    Member
    9
    May 30, 2015
    United States
    Well, you're missing masterkeys 1-3 so it's possible.
     
  5. Silent002

    Silent002 Newbie

    Newcomer
    1
    Jul 8, 2018
    United Kingdom
    Okay, just added the three missing Master Keys, still the same error. Funny enough if I remove a character from any of the keys and save it, hactool tells me that key should be 32 characters - so it is at least reading the file. I can only assume I need some or all of the 40 (37?) keys that haven't been found so far. That's a shame. Thanks for your help anyway man, much appreciated!
     
  6. Tom288
    This message by Tom288 has been removed from public view by Joe88, Jul 10, 2018, Reason: This is not allowed on this site.
    Jul 9, 2018
  7. RazorX2014

    RazorX2014 GBAtemp Advanced Fan

    Member
    3
    Mar 18, 2014
    @dark_samus3 so how many keys does your newest keys.py get now?
     
  8. gameboy

    gameboy GBAtemp Advanced Maniac

    Member
    6
    Dec 9, 2015
    United States
    this worked for me.
    nsw2.3.0 windows8.1
    python2.7.15 86x

    but was it supposed to generate a keys.txt? because i didnt get that in my hactool folder
     
  9. dark_samus3

    dark_samus3 GBAtemp Addict

    Member
    9
    May 30, 2015
    United States
    actually, no, no need for keys.txt. It generates %userprofile%/.switch/prod.keys, which hactool will automatically check for, and load if present. So, no need to ever do "keyset=keys.txt" just use hactool without it
     
  10. medi01

    medi01 Member

    Newcomer
    1
    Jul 9, 2018
    Germany
    Guys I have a bit of a chicken and an egg problem.
    I'm trying to install higher firmware without burning fuses.
    Which, as far as I understand, means, that keys extracted from my console dumps won't be enough

    Googling for more keys... does bring results, but hactool complains about "failed to match key" followed by "Invalid NCA Header"... :S

    What am I doing wrong? :S

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

    PS
    Hmm, here is the log from obtaining keys:

    Code:
    Using BOOT0.bin to get keys from package1...
    Deriving keys...
    Decrypting package1...
    Using Secure_Monitor.bin to get keys to decrypt package2...
    Decrypting package2...
    Decompressing spl.kip1 and FS.kip1...
    Getting keys from spl...
    Getting keys from FS...
    Doing final key derivation...
    If there were no warnings, we found all the keys!
    Now you can do hactool --keyset=keys.txt to use them!
    

    But then, even with XCI of Just Dance 2017 (which should be on FW lower than 3.0.2, from which I'm extracting the keys):

    Code:
    hactool.exe --keys=keys.txt "pathtojustdance2017.xci"
    Invalid NCA header! Are keys correct?
    Done!
     
  11. Seelbreaker

    Seelbreaker GBAtemp Regular

    Member
    3
    Mar 22, 2010
    Gambia, The
    So hi,

    i've been trying now for straight 4 hours to get python running (while doing other stuff) but it just won't work, since i always get an invalid syntax error.

    here are some outputs from python -v, pip install lz4 and python keys.py (wihtout the keys because the error is the same)

    Warning: Spoilers inside!

    I've got Win10 Version 10.0.17134.165

    rcm with tegrasmash and everything is runnig as i have my own keydump created with briskeydump.

    and in my Path Variables there is the Path for python included:
    Path=C:\Python\;C:\Python\Scripts;

    ofcourse i rebooted after adding the variable...

    can any1 help me in getting the syntax working? like - environment variables should be fine right?.... ah yeah, i started cmd as an admin and not - uac is on default...


    hactool.exe and the dll files are as well as boot0.bin and BCPKG2-1-Normal-Main.bin are in the C:\Python Folder.

    Edit: i also copied hactool, the dll and the keys.py into Desktop\hactool - still invalid syntax :(


    Installing 64-bit Python 2.7.15 didn't helped either :(
     
    Last edited by Seelbreaker, Jul 12, 2018
  12. medi01

    medi01 Member

    Newcomer
    1
    Jul 9, 2018
    Germany
    If in doubt, Python offers you to add itself to the env variables (off by default).

    My problem with it was that pip tool, needed to install additional libs wasn't installed automatically, so I had to manually fetch it executing this python script with admin rights (attached).
     

    Attached Files:

  13. Seelbreaker

    Seelbreaker GBAtemp Regular

    Member
    3
    Mar 22, 2010
    Gambia, The
    unfortunately it didn't helped :( guess i need to somehow set up a linux and nfs mounts for this stuff :/
     
  14. medi01

    medi01 Member

    Newcomer
    1
    Jul 9, 2018
    Germany
    You need to be more specific about errors you get.
     
  15. aos10

    aos10 ❤ Zelda ❤\(^o^)/

    Member
    8
    Apr 10, 2012
    Saudi Arabia
    when i run hactool.exe it runs fast and close then nothing
    i downloaded the last version of hactool
     
  16. RazorX2014

    RazorX2014 GBAtemp Advanced Fan

    Member
    3
    Mar 18, 2014
    hactool on it's own has to be ran in cmd (command prompt)
     
  17. aos10

    aos10 ❤ Zelda ❤\(^o^)/

    Member
    8
    Apr 10, 2012
    Saudi Arabia
    like that?

    [​IMG]
     
    Last edited by aos10, Jul 12, 2018
  18. RazorX2014

    RazorX2014 GBAtemp Advanced Fan

    Member
    3
    Mar 18, 2014
    if you're trying to dump your keys you need to put your BOOT0 and BCPKG2-1-Normal-Main in the same folder and rename them so they have .bin on the end and then run python keys.py <YOUR SBK> <YOUR TSEK> in the command prompt window, you get those keys by dumping your biskeys using the biskeydump.bin payload
     
    Last edited by RazorX2014, Jul 12, 2018
  19. aos10

    aos10 ❤ Zelda ❤\(^o^)/

    Member
    8
    Apr 10, 2012
    Saudi Arabia
    oh, i have boot0 and boot1 only right now.

    what is BCPKG2?
     
  20. RazorX2014

    RazorX2014 GBAtemp Advanced Fan

    Member
    3
    Mar 18, 2014
    if i remember you dump the SYS and it should create a folder in Backups called Partitions and in that you will see:
    BCPKG2-1-Normal-Main
    BCPKG2-2-Normal-Sub
    BCPKG2-3-SafeMode-Main
    BCPKG2-4-SafeMode-Sub
    BCPKG2-5-Repair-Main
    BCPKG2-6-Repair-Sub
    PRODINFO
    PRODINFOF
    SAFE
    SYSTEM
     
    aos10 likes this.
  21. aos10

    aos10 ❤ Zelda ❤\(^o^)/

    Member
    8
    Apr 10, 2012
    Saudi Arabia
    thanks, now i remember i've only backed up boot0 and 1.
    doing all of them now including the NAND, this gonna take sometime, thanks again.

    well be back if there new question.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice