Tutorial  Updated

How to get Switch Keys for Hactool/XCI Decrypting

This thread is deprecated
For a faster, easier and more up-to-date way of getting keys use Lockpick_RCM by shchmue
If you still want to follow this tutorial and end up with less keys, continue reading the Thread.


WARNING
  • DO NOT GIVE OUT ANY OF YOUR KEYS TO ANYONE! I CANNOT STRESS THAT ENOUGH!
  • DO NOT SHARE YOUR KEYS BETWEEN MULTIPLE SWITCHES THAT YOU DO/DON'T OWN! SOME ARE CONSOLE-UNIQUE
  • DO NOT ASK ME FOR KEYS


LEGEND
  • SBK
    SecureBootKey
  • TSEC
    Tegra Security Co-processor Key
  • eMMC
    Embedded MultiMediaCard (Switch's Onboard Storage)


GOAL
End up with 83+ keys including SBK and TSEC keys. Get Master Key's 0-5. (Master Keys 6 onwards is not done in this tutorial)
Reminder, if you want more up-to-date and much more convenient way to get your Switch's Keys, use Lockpick by shchmue (available in nx-appstore/homebrew store)


Tutorial — (Outdated for Switch's on firmware 6.x or newer)


#1 - Dumping System Keys (Biskeydump)#2 - Dumping Required Files#3 - Hactool Preparation#4 - Dumping KeysFinal WordsTroubleshooting


  1. We need to get your Secure Boot Key (SBK) and Tegra Security Co-processor Key (TSEC) before we can get the main keys.
    These are 100% console unique.

    1. Download and extract biskeydump.bin from biskeydumpvx.zip
      - Follow this tutorial but instead of using CTCaer's Hekate Mod .bin file, use the biskeydump.bin file
      - If the QR Code is Blue, Scan the QR Code with your Phone, Laptop e.t.c
      - If you cant find a device you can scan with, type them out into your PC/Laptop (Its highly recommended to scan the QR Code, as a lot of characters can look like another, O0, Il, rn can look like m, e.t.c)
    2. Once you have the biskeydump of your System, store all the keys you received somewhere safe, I recommend a secure cloud storage aswell as a USB Stick, perhaps even print it.
      - Don't give this to ANYONE, Seriously.

    If you get any errors please go to the Troubleshooting Tab.


    1. Follow this tutorial AGAIN but this time use CTCaer's Hekate Mod.
      - "Tools" -> "Backup..." -> "Backup eMMC BOOT0/1"
      - "Tools" -> "Backup..." -> "Backup eMMC SYS"
      - Back all the way to the first menu, and choose "Power off"
    2. Take the microSD Card out of your Switch and into your PC.
    3. Copy both "BOOT0" and "BCPKG2-1-Normal-Main" from "sd:/backup/xxxxxx/" (xxxxxx is different for everyone) to "hactool" on your Desktop (create the "hactool" folder)
      - Rename them with .bin at the end, "BOOT0.bin", "BCPKG2-1-Normal-Main.bin"

    1. Download and install Python 2.7.x - NOT Python 3.x.x
      When installing, it will ask you what features you want installed, scroll to the bottom and make sure "Add Python to Path" has "Entire Feature Installed to HDD" option chose (No Red X Icon), otherwise the scripts wont find Python and WILL fail
    2. Download and extract hactool TO THE DESKTOP AND NAME THE FOLDER "hactool"
      On Linux/MacOS: clone and build hactool manually
    3. Right-click this (script originally by tesnos6921, patched by shadowninja108, jakibaki and shchmue)
      - Click "Save link as" / "save as"
      - Set "Save as type" to "All Files"
      - Name it "keys.py"
      And finally save it to the hactool folder you placed in the Desktop.
      NOTICE TO GBATEMP STAFF: The "keys" inside this file, are NOT keys, they are SHA digest hashes used to search through files to find text that matches, which would be the keys.

    1. Press WIN(Btn)+R to open "Run", type "cmd" and press Ctrl+Shift then Enter to open Command Prompt as an Administrator
    2. Type (in order) or Copy the following and paste into Command Prompt (Some Windows Versions use Right Click to Paste, some use CTRL+C)
      python -m pip install --upgrade pip
      pip install lz4
      cd Desktop/hactool

      python keys.py SBK_Here_From_Biskeydump TSEC_Here_From_Biskeydump
    3. It should say: "Now you can do hactool --keyset=keys.txt to use them!", if it does, and there's no warning messages, you're good to go! :O
    If you get any errors please go to the Troubleshooting Tab.

  2. You now have a keys.txt file with your console-specific keys inside.
    Rename as needed by any software that requires a different name or file extension, it doesn't matter.
    Though I highly recommend renaming it to prod.keys as this filename for Key file's is becoming a popular choice with other software
    There may be more keys, as the Switch's lifecycle goes on, more and more keys will be needed as the firmwares grow and grow.
    • The Hactool warning:
      Code:
      [WARN] prod.keys does not exist.
      can be safely ignored.
      - if you want to place your "keys.txt" file their, put "keys.txt" on your Desktop and run the following with Administrator Command Prompt (Step #4.1 for instructions):
      Code:
      mkdir -p %USERPROFILE%\.switch
      move "%USERPROFILE%\Desktop\keys.txt" "%USERPROFILE%\.switch\prod.keys"

  3. #1 ISSUES:
    • Code:
      Red QR Code Outline
      - The reasons this can occur is quite a rarity, all I can say is to keep rebooting and trying again.
      - If there's a new version of biskeydump out, try using the newer biskeydump.bin
    • Code:
      QR Code not being scanned by your Reader
      - Align your QR Code Readers alignment overlay with the Blue Square's Corners/Edges, NOT the QR Code's Corners/Edges.
      - Clean your camera lens
      - Be in a bright room

    #4 ISSUES:
    • Code:
      File "keys.py", line ...
      print message
      ^
      SyntaxError: Missing parentheses in call to 'print'. Did you mean print(message)?
      - You didn't place SBK and TSEC in the 4th line of the Command in Step #4.2
      - You installed Python 3.x.x when you must use 2.7.x, uninstall python, logout of windows (important it removes python from PATH) and follow Step #3.2 then move back to #4.1
    • Code:
      import lz4.block
      File "C:\Python27\lib\site-packages\lz4\__init__.py", line 17, in <module>
      from ._version import ( # noqa: F401
      ImportError: DLL load failed: The specified module could not be found.
      - The 2nd line of the Command in Step #4.2 failed without you noticing. Try running the 1st line to upgrade pip and if that goes successfully run the 2nd line to install lz4 and see if it successfully installs.
 
Last edited by shchmue,

DaveSwitch

Well-Known Member
Newcomer
Joined
Jul 15, 2018
Messages
47
Trophies
0
Age
24
Location
Hyrule Castle
XP
293
Country
Canada
hacgui now supports all firmwares check it out if you're on Windows: https://github.com/shadowninja108/HACGUI/releases
Error:


System.AggregateException: Une ou plusieurs erreurs se sont produites. ---> System.IO.InvalidDataException: Failed to decrypt package2! Is the correct key present?
à LibHac.Package2.FindKeyGeneration(Keyset keyset, IStorage storage)
à LibHac.Package2..ctor(Keyset keyset, IStorage storage)
à HACGUI.FirstStart.PickNANDPage.OnNandFound() dans B:\Documents\Switch_Projects\hactoolgui\hactoolgui\FirstStart\PickNANDPage.xaml.cs:ligne 119
à HACGUI.FirstStart.PickNANDPage.<StartDeriving>b__2_1(DerivingPage page) dans B:\Documents\Switch_Projects\hactoolgui\hactoolgui\FirstStart\PickNANDPage.xaml.cs:ligne 91
à HACGUI.FirstStart.DerivingPage.<>c__DisplayClass0_0.<.ctor>b__1() dans B:\Documents\Switch_Projects\hactoolgui\hactoolgui\FirstStart\DerivingPage.xaml.cs:ligne 24
à System.Threading.Tasks.Task.Execute()
--- Fin de la trace de la pile d'exception interne ---
---> (Exception interne #0) System.IO.InvalidDataException: Failed to decrypt package2! Is the correct key present?
à LibHac.Package2.FindKeyGeneration(Keyset keyset, IStorage storage)
à LibHac.Package2..ctor(Keyset keyset, IStorage storage)
à HACGUI.FirstStart.PickNANDPage.OnNandFound() dans B:\Documents\Switch_Projects\hactoolgui\hactoolgui\FirstStart\PickNANDPage.xaml.cs:ligne 119
à HACGUI.FirstStart.PickNANDPage.<StartDeriving>b__2_1(DerivingPage page) dans B:\Documents\Switch_Projects\hactoolgui\hactoolgui\FirstStart\PickNANDPage.xaml.cs:ligne 91
à HACGUI.FirstStart.DerivingPage.<>c__DisplayClass0_0.<.ctor>b__1() dans B:\Documents\Switch_Projects\hactoolgui\hactoolgui\FirstStart\DerivingPage.xaml.cs:ligne 24
à System.Threading.Tasks.Task.Execute()<---


I followed this guide: "https://gamebanana.com/tuts/12766" so it's maybe different?
 

shchmue

Developer
Developer
Joined
Dec 23, 2013
Messages
791
Trophies
1
XP
2,367
Country
United States
Error:


System.AggregateException: Une ou plusieurs erreurs se sont produites. ---> System.IO.InvalidDataException: Failed to decrypt package2! Is the correct key present?
à LibHac.Package2.FindKeyGeneration(Keyset keyset, IStorage storage)
à LibHac.Package2..ctor(Keyset keyset, IStorage storage)
à HACGUI.FirstStart.PickNANDPage.OnNandFound() dans B:\Documents\Switch_Projects\hactoolgui\hactoolgui\FirstStart\PickNANDPage.xaml.cs:ligne 119
à HACGUI.FirstStart.PickNANDPage.<StartDeriving>b__2_1(DerivingPage page) dans B:\Documents\Switch_Projects\hactoolgui\hactoolgui\FirstStart\PickNANDPage.xaml.cs:ligne 91
à HACGUI.FirstStart.DerivingPage.<>c__DisplayClass0_0.<.ctor>b__1() dans B:\Documents\Switch_Projects\hactoolgui\hactoolgui\FirstStart\DerivingPage.xaml.cs:ligne 24
à System.Threading.Tasks.Task.Execute()
--- Fin de la trace de la pile d'exception interne ---
---> (Exception interne #0) System.IO.InvalidDataException: Failed to decrypt package2! Is the correct key present?
à LibHac.Package2.FindKeyGeneration(Keyset keyset, IStorage storage)
à LibHac.Package2..ctor(Keyset keyset, IStorage storage)
à HACGUI.FirstStart.PickNANDPage.OnNandFound() dans B:\Documents\Switch_Projects\hactoolgui\hactoolgui\FirstStart\PickNANDPage.xaml.cs:ligne 119
à HACGUI.FirstStart.PickNANDPage.<StartDeriving>b__2_1(DerivingPage page) dans B:\Documents\Switch_Projects\hactoolgui\hactoolgui\FirstStart\PickNANDPage.xaml.cs:ligne 91
à HACGUI.FirstStart.DerivingPage.<>c__DisplayClass0_0.<.ctor>b__1() dans B:\Documents\Switch_Projects\hactoolgui\hactoolgui\FirstStart\DerivingPage.xaml.cs:ligne 24
à System.Threading.Tasks.Task.Execute()<---


I followed this guide: "https://gamebanana.com/tuts/12766" so it's maybe different?
try deleting your /backup/<numbers>/dumps folder and redoing the hekate dumps then try again
 

DaveSwitch

Well-Known Member
Newcomer
Joined
Jul 15, 2018
Messages
47
Trophies
0
Age
24
Location
Hyrule Castle
XP
293
Country
Canada
try deleting your /backup/<numbers>/dumps folder and redoing the hekate dumps then try again
Still get an error


System.AggregateException: Une ou plusieurs erreurs se sont produites. ---> System.IO.InvalidDataException: Failed to decrypt package2! Is the correct key present?
à LibHac.Package2.FindKeyGeneration(Keyset keyset, IStorage storage)
à LibHac.Package2..ctor(Keyset keyset, IStorage storage)
à HACGUI.FirstStart.PickNANDPage.OnNandFound() dans B:\Documents\Switch_Projects\hactoolgui\hactoolgui\FirstStart\PickNANDPage.xaml.cs:ligne 119
à HACGUI.FirstStart.PickNANDPage.<StartDeriving>b__2_1(DerivingPage page) dans B:\Documents\Switch_Projects\hactoolgui\hactoolgui\FirstStart\PickNANDPage.xaml.cs:ligne 91
à HACGUI.FirstStart.DerivingPage.<>c__DisplayClass0_0.<.ctor>b__1() dans B:\Documents\Switch_Projects\hactoolgui\hactoolgui\FirstStart\DerivingPage.xaml.cs:ligne 24
à System.Threading.Tasks.Task.Execute()
--- Fin de la trace de la pile d'exception interne ---
---> (Exception interne #0) System.IO.InvalidDataException: Failed to decrypt package2! Is the correct key present?
à LibHac.Package2.FindKeyGeneration(Keyset keyset, IStorage storage)
à LibHac.Package2..ctor(Keyset keyset, IStorage storage)
à HACGUI.FirstStart.PickNANDPage.OnNandFound() dans B:\Documents\Switch_Projects\hactoolgui\hactoolgui\FirstStart\PickNANDPage.xaml.cs:ligne 119
à HACGUI.FirstStart.PickNANDPage.<StartDeriving>b__2_1(DerivingPage page) dans B:\Documents\Switch_Projects\hactoolgui\hactoolgui\FirstStart\PickNANDPage.xaml.cs:ligne 91
à HACGUI.FirstStart.DerivingPage.<>c__DisplayClass0_0.<.ctor>b__1() dans B:\Documents\Switch_Projects\hactoolgui\hactoolgui\FirstStart\DerivingPage.xaml.cs:ligne 24
à System.Threading.Tasks.Task.Execute()<---
 
Last edited by DaveSwitch,

JHumBL3

Active Member
Newcomer
Joined
Nov 22, 2018
Messages
41
Trophies
0
Age
38
XP
417
Country
United States
I was able to get my keys while on 5.1 but now that I'm on 6.2 by ChoiDujour the kezplez.nro crashes after it starts dumping. Any possible solutions!?
 

SkullHex2

Well-Known Member
Member
Joined
Feb 27, 2017
Messages
246
Trophies
0
XP
1,300
Country
United States
Despite having successfully installed lz4, I keep getting this error (and yes, I went myself to the path specified and saw with my own eyes that the package is there):
import lz4.block
File "C:\Python27\lib\site-packages\lz4\__init__.py", line 17, in <module>
from ._version import ( # noqa: F401
ImportError: DLL load failed: The specified module could not be found.
 

Henbro11341

Member
Newcomer
Joined
Aug 7, 2018
Messages
23
Trophies
0
Age
38
XP
322
Country
United States
hactool>python keys.py SBK_Here_From_Biskeydump TSEC_Here_From_Biskeydump
Using BOOT0.bin to get keys from package1...
Requesting keyblob seeds...
Deriving keys...
Decrypting package1...
Using Secure_Monitor.bin to get keys to decrypt package2...
Traceback (most recent call last):
File "keys.py", line 417, in <module>
TZ_f = open(os.path.join("package1", "Secure_Monitor.bin"), "rb")
IOError: [Errno 2] No such file or directory: 'package1\\Secure_Monitor.bin'



Any ideas
 

Adran_Marit

Walküre's Hacker
Member
Joined
Oct 3, 2015
Messages
3,781
Trophies
1
Location
42*South
XP
4,559
Country
Australia
hactool>python keys.py SBK_Here_From_Biskeydump TSEC_Here_From_Biskeydump
Using BOOT0.bin to get keys from package1...
Requesting keyblob seeds...
Deriving keys...
Decrypting package1...
Using Secure_Monitor.bin to get keys to decrypt package2...
Traceback (most recent call last):
File "keys.py", line 417, in <module>
TZ_f = open(os.path.join("package1", "Secure_Monitor.bin"), "rb")
IOError: [Errno 2] No such file or directory: 'package1\\Secure_Monitor.bin'



Any ideas

7.0? If so this method won't work
 

Henbro11341

Member
Newcomer
Joined
Aug 7, 2018
Messages
23
Trophies
0
Age
38
XP
322
Country
United States
I tryed the downgrade and i have acess to nothing other then loading in rcm im trying to get my keys so i can potentially rebuild the nand.
 

510jungleboy

Member
Newcomer
Joined
Feb 23, 2019
Messages
9
Trophies
0
Age
48
XP
76
Country
United States
I'm on #4 tutorial and on command line 4.I kept getting a message " The system cannot find path specified ". Anyone getting this error?
 

oxcom76

New Member
Newbie
Joined
Mar 2, 2019
Messages
1
Trophies
0
Age
47
XP
59
Country
United States
Which of the lines in the keys.txt output from Lockpick are considered your 'BIS keys 0-3 crypt and tweek'? I tried using the Homebrew SD Setup page with my fuse and key bins. It told me the length of my tsec file was incorrect. I had previously run Lockpick successfully and have thkeys.txt file. Since your note on the OP say to use LP, I'm hoping the keys I need for choidujour are in the file.
 

Pikkappa

Member
Newcomer
Joined
Mar 11, 2019
Messages
21
Trophies
0
Age
36
XP
105
Country
Italy
Code:
Using BOOT0.bin to get keys from package1...
Requesting keyblob seeds...
Deriving keys...
Decrypting package1...
Using Secure_Monitor.bin to get keys to decrypt package2...
Traceback (most recent call last):
  File "keys.py", line 417, in <module>
    TZ_f = open(os.path.join("package1", "Secure_Monitor.bin"), "rb")
IOError: [Errno 2] No such file or directory: 'package1\\Secure_Monitor.bin'

I'm going mad guys... what i have to do??


done, I hadn't putted the hactool.exe in the folder :D
 
Last edited by Pikkappa,

kenshinchai

Member
Newcomer
Joined
Sep 17, 2018
Messages
16
Trophies
0
Age
41
XP
92
Country
Malaysia
54519225_298721574133687_4477256879252176896_n.jpg

I got this error, im on 5.1
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    SylverReZ @ SylverReZ: Lol Veho.