hactool is a tool to view information about, decrypt, and extract common file formats for the Nintendo Switch, especially Nintendo Content Archives.
Go to file
SciresM 84715a89f8
Merge pull request #35 from jakibaki/master
getopt_long returns an int, not a char.
2018-07-24 00:36:48 -07:00
mbedtls Add support for key derivation. 2018-04-26 00:10:14 -06:00
.gitignore Implement support for external keys (closes #6) 2018-02-06 00:04:27 -08:00
aes.c Add support for key derivation. 2018-04-26 00:10:14 -06:00
aes.h Add support for key derivation. 2018-04-26 00:10:14 -06:00
bktr.c Fix leftover buckets dereference not using getter. 2018-03-31 23:11:13 -07:00
bktr.h Fix Intersection bucket retrievals 2018-03-31 17:46:28 -06:00
cJSON.c Implement npdm -> JSON autogeneration. 2018-05-02 18:35:19 -06:00
cJSON.h Implement npdm -> JSON autogeneration. 2018-05-02 18:35:19 -06:00
config.mk.template Port to mbedtls 2018-01-29 18:39:30 +00:00
ConvertUTF.c Use Unicode's ConvertUTF for utf8->utf16 (Closes #11). 2018-02-04 19:08:53 -08:00
ConvertUTF.h Use Unicode's ConvertUTF for utf8->utf16 (Closes #11). 2018-02-04 19:08:53 -08:00
extkeys.c Add support for loading external titlekeys file (title.keys) 2018-07-23 22:16:26 -07:00
extkeys.h Add support for loading external titlekeys file (title.keys) 2018-07-23 22:16:26 -07:00
filepath.c Implement real BKTR support 2018-03-31 16:43:59 -06:00
filepath.h Add more options for Update RomFS 2018-02-12 03:35:48 -08:00
hfs0.c Initial XCI Support. (WIP, #4). 2018-02-04 00:23:10 -08:00
hfs0.h Initial XCI Support. (WIP, #4). 2018-02-04 00:23:10 -08:00
ivfc.h Fix XTS/NCA2 support. Add NCA0 support. 2018-07-20 03:03:35 -07:00
KEYS.md Minor layout change 2018-02-14 15:58:54 -08:00
kip.c Add support for KIP1 decompression. 2018-07-23 23:18:48 -07:00
kip.h Add JSON output for KIP1/INI, fix encrypted package2 input 2018-05-02 22:09:11 -06:00
LICENSE First Public commit. 2018-01-24 09:52:25 -08:00
lz4.c Add support for NSO parsing + decompression. 2018-07-24 00:14:48 -07:00
lz4.h Add support for NSO parsing + decompression. 2018-07-24 00:14:48 -07:00
main.c Merge pull request #35 from jakibaki/master 2018-07-24 00:36:48 -07:00
Makefile Add support for NSO parsing + decompression. 2018-07-24 00:14:48 -07:00
nax0.c Fix NAX0 decryption 2018-06-14 11:54:19 -05:00
nax0.h Add support for NAX0 input files. 2018-04-03 16:26:56 -06:00
nca0_romfs.c Fix XTS/NCA2 support. Add NCA0 support. 2018-07-20 03:03:35 -07:00
nca0_romfs.h Fix XTS/NCA2 support. Add NCA0 support. 2018-07-20 03:03:35 -07:00
nca.c Add additional warning, bump version to 1.2.0 2018-07-24 00:25:48 -07:00
nca.h Add support for loading external titlekeys file (title.keys) 2018-07-23 22:16:26 -07:00
npdm.c JSON: Output mapped pages/sizes as u32. 2018-05-02 22:10:57 -06:00
npdm.h Add JSON output for KIP1/INI, fix encrypted package2 input 2018-05-02 22:09:11 -06:00
nso.c Add support for NSO parsing + decompression. 2018-07-24 00:14:48 -07:00
nso.h Add support for NSO parsing + decompression. 2018-07-24 00:14:48 -07:00
packages.c Add JSON output for KIP1/INI, fix encrypted package2 input 2018-05-02 22:09:11 -06:00
packages.h Finish Package2 support, add support for INI1, KIP1 (Closes #4) 2018-02-07 00:10:53 -08:00
pfs0.c Implement npdm -> JSON autogeneration. 2018-05-02 18:35:19 -06:00
pfs0.h Re-brand ourselves, bump version number to 0.9 2018-02-02 21:35:43 -08:00
pki.c s/encrypted_header_key/header_key_source 2018-07-20 03:06:19 -07:00
pki.h Fix XTS/NCA2 support. Add NCA0 support. 2018-07-20 03:03:35 -07:00
README.md Add additional warning, bump version to 1.2.0 2018-07-24 00:25:48 -07:00
romfs.c Fix XTS/NCA2 support. Add NCA0 support. 2018-07-20 03:03:35 -07:00
rsa.c Fix XTS/NCA2 support. Add NCA0 support. 2018-07-20 03:03:35 -07:00
rsa.h Fix XTS/NCA2 support. Add NCA0 support. 2018-07-20 03:03:35 -07:00
settings.h Add support for KIP1 decompression. 2018-07-23 23:18:48 -07:00
sha.c Add support for NAX0 input files. 2018-04-03 16:26:56 -06:00
sha.h Add support for NAX0 input files. 2018-04-03 16:26:56 -06:00
types.h Re-brand ourselves, bump version number to 0.9 2018-02-02 21:35:43 -08:00
utils.c Add support for loading external titlekeys file (title.keys) 2018-07-23 22:16:26 -07:00
utils.h Add support for loading external titlekeys file (title.keys) 2018-07-23 22:16:26 -07:00
version.h Add additional warning, bump version to 1.2.0 2018-07-24 00:25:48 -07:00
xci.c Implement XCI logo partition extraction. 2018-05-31 20:54:17 +01:00
xci.h Implement XCI logo partition extraction. 2018-05-31 20:54:17 +01:00

hactool

License

hactool is a tool to view information about, decrypt, and extract common file formats for the Nintendo Switch, especially Nintendo Content Archives.

It is heavily inspired by ctrtool.

Usage

Usage: hactool [options...] <file>
Options:
-i, --info        Show file info.
                      This is the default action.
-x, --extract     Extract data from file.
                      This is also the default action.
  -r, --raw          Keep raw data, don't unpack.
  -y, --verify       Verify hashes and signatures.
  -d, --dev          Decrypt with development keys instead of retail.
  -k, --keyset       Load keys from an external file.
  -t, --intype=type  Specify input file type [nca, xci, pfs0, romfs, hfs0, npdm, pk11, pk21, ini1, kip1, nax0, keygen]
  --titlekey=key     Set title key for Rights ID crypto titles.
  --contentkey=key   Set raw key for NCA body decryption.
NCA options:
  --plaintext=file   Specify file path for saving a decrypted copy of the NCA.
  --header=file      Specify Header file path.
  --section0=file    Specify Section 0 file path.
  --section1=file    Specify Section 1 file path.
  --section2=file    Specify Section 2 file path.
  --section3=file    Specify Section 3 file path.
  --section0dir=dir  Specify Section 0 directory path.
  --section1dir=dir  Specify Section 1 directory path.
  --section2dir=dir  Specify Section 2 directory path.
  --section3dir=dir  Specify Section 3 directory path.
  --exefs=file       Specify ExeFS file path. Overrides appropriate section file path.
  --exefsdir=dir     Specify ExeFS directory path. Overrides appropriate section directory path.
  --romfs=file       Specify RomFS file path. Overrides appropriate section file path.
  --romfsdir=dir     Specify RomFS directory path. Overrides appropriate section directory path.
  --listromfs        List files in RomFS.
  --baseromfs        Set Base RomFS to use with update partitions.
  --basenca          Set Base NCA to use with update partitions.
  --basefake         Use a fake Base RomFS with update partitions (all reads will return 0xCC).
  --onlyupdated      Ignore non-updated files in update partitions.
NPDM options:
  --json=file        Specify file path for saving JSON representation of program permissions to.
KIP1 options:
  --json=file        Specify file path for saving JSON representation of program permissions to.
  --uncompressed=f   Specify file path for saving uncompressed KIP1.
NSO0 options:
  --uncompressed=f   Specify file path for saving uncompressed NSO0.
PFS0 options:
  --pfs0dir=dir      Specify PFS0 directory path.
  --outdir=dir       Specify PFS0 directory path. Overrides previous path, if present.
  --exefsdir=dir     Specify PFS0 directory path. Overrides previous paths, if present for ExeFS PFS0.
RomFS options:
  --romfsdir=dir     Specify RomFS directory path.
  --outdir=dir       Specify RomFS directory path. Overrides previous path, if present.
  --listromfs        List files in RomFS.
HFS0 options:
  --hfs0dir=dir      Specify HFS0 directory path.
  --outdir=dir       Specify HFS0 directory path. Overrides previous path, if present.
  --exefsdir=dir     Specify HFS0 directory path. Overrides previous paths, if present.
XCI options:
  --rootdir=dir      Specify XCI root HFS0 directory path.
  --updatedir=dir    Specify XCI update HFS0 directory path.
  --normaldir=dir    Specify XCI normal HFS0 directory path.
  --securedir=dir    Specify XCI secure HFS0 directory path.
  --logodir=dir      Specify XCI logo HFS0 directory path.
  --outdir=dir       Specify XCI directory path. Overrides previous paths, if present.
Package1 options:
  --package1dir=dir  Specify Package1 directory path.
  --outdir=dir       Specify Package1 directory path. Overrides previous path, if present.
Package2 options:
  --package2dir=dir  Specify Package2 directory path.
  --outdir=dir       Specify Package2 directory path. Overrides previous path, if present.
  --extractini1      Enable INI1 extraction to default directory (redundant with --ini1dir set).
  --ini1dir=dir      Specify INI1 directory path. Overrides default path, if present.
INI1 options:
  --ini1dir=dir      Specify INI1 directory path.
  --outdir=dir       Specify INI1 directory path. Overrides previous path, if present.
  --saveini1json     Enable generation of JSON descriptors for all INI1 members.
NAX0 options:
  --sdseed=seed      Set console unique seed for SD card NAX0 encryption.
  --sdpath=path      Set relative path for NAX0 key derivation (ex: /registered/000000FF/cafebabecafebabecafebabecafebabe.nca).
Key Derivation options:
  --sbk=key          Set console unique Secure Boot Key for key derivation.
  --tseckey=key      Set console unique TSEC Key for key derivation.```

## Building

Copy `config.mk.template` to `config.mk`, make changes as required, and then run `make`.
If your `make` is not GNU make (e.g. on BSD variants), you need to call `gmake` instead.

If on Windows, I recommend using MinGW.

## External Keys

External keys can be provided by the -k/--keyset argument to the a keyset filename.
Keyset files are text files containing one key per line, in the form "key_name = HEXADECIMALKEY".
Case shouldn't matter, nor should whitespace.

In addition, if -k/--keyset is not set, hactool will check for the presence of a keyset file
in $HOME/.switch/prod.keys (or $HOME/.switch/dev.keys if -d/--dev is set). If present, this file
will automatically be loaded.

## Licensing

This software is licensed under the terms of the ISC License.  
You can find a copy of the license in the LICENSE file.