LibHac/README.md

120 lines
6.4 KiB
Markdown
Raw Permalink Normal View History

2018-08-31 17:47:11 +02:00
# LibHac
2018-07-08 18:40:55 +02:00
2019-02-26 05:55:25 +01:00
[![NuGet](https://img.shields.io/nuget/v/LibHac.svg?style=flat-square)](https://www.nuget.org/packages/LibHac)
[![MyGet](https://img.shields.io/myget/libhac/vpre/libhac.svg?label=myget&style=flat-square)](https://www.myget.org/feed/libhac/package/nuget/LibHac)
[![AppVeyor Build Status](https://img.shields.io/appveyor/ci/thealexbarney/LibHac/master.svg?style=flat-square)](https://ci.appveyor.com/project/Thealexbarney/libhac/history)
LibHac is a .NET and .NET Core library for opening, decrypting and extracting common content file formats used by the Nintendo Switch.
2018-07-08 18:40:55 +02:00
Most content is imported and exported using a standard `IStorage` interface. This means that reading nested file types and encryptions can easily be done by linking different file readers together.
2018-07-08 18:40:55 +02:00
For example, the files from a title stored on the external SD card can be read or extracted in this way.
`NAX0 Reader` -> `NCA Reader` -> `RomFS Reader` -> `Individual Files`
# hactoolnet
2018-08-31 17:47:11 +02:00
hactoolnet is an example program that uses LibHac. It is used in a similar manner to [hactool](https://github.com/SciresM/hactool).
2018-07-08 18:40:55 +02:00
## Usage
```
2018-09-10 03:48:17 +02:00
Usage: hactoolnet.exe [options...] <path>
2018-07-08 18:40:55 +02:00
Options:
-r, --raw Keep raw data, don't unpack.
2018-10-13 04:06:21 +02:00
-y, --verify Verify all hashes in the input file.
-h, --enablehash Enable hash checks when reading the input file.
2018-07-08 18:40:55 +02:00
-k, --keyset Load keys from an external file.
2019-02-04 02:27:09 +01:00
-t, --intype=type Specify input file type [nca, xci, romfs, pk11, pk21, ini1, kip1, switchfs, save, ndv0, keygen, romfsbuild]
2018-07-08 18:40:55 +02:00
--titlekeys <file> Load title keys from an external file.
NCA options:
2019-02-04 02:27:09 +01:00
--plaintext <file> Specify file path for saving a decrypted copy of the NCA.
2018-07-08 18:40:55 +02:00
--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.
2019-02-04 02:27:09 +01:00
--exefs <file> Specify ExeFS file path.
2018-09-10 03:48:17 +02:00
--exefsdir <dir> Specify ExeFS directory path.
2019-02-04 02:27:09 +01:00
--romfs <file> Specify RomFS file path.
2018-09-10 03:48:17 +02:00
--romfsdir <dir> Specify RomFS directory path.
2018-07-08 18:40:55 +02:00
--listromfs List files in RomFS.
--basenca Set Base NCA to use with update partitions.
2018-09-13 02:51:21 +02:00
RomFS options:
--romfsdir <dir> Specify RomFS directory path.
--listromfs List files in RomFS.
2019-02-04 02:27:09 +01:00
RomFS creation options:
Input path must be a directory
--outfile <file> Specify created RomFS file path.
2018-09-10 03:48:17 +02:00
XCI options:
--rootdir <dir> Specify root XCI directory path.
--updatedir <dir> Specify update XCI directory path.
--normaldir <dir> Specify normal XCI directory path.
--securedir <dir> Specify secure XCI directory path.
--logodir <dir> Specify logo XCI directory path.
--outdir <dir> Specify XCI directory path.
--exefs <file> Specify main ExeFS file path.
--exefsdir <dir> Specify main ExeFS directory path.
--romfs <file> Specify main RomFS file path.
--romfsdir <dir> Specify main RomFS directory path.
--nspout <file> Specify file for the created NSP.
2018-09-13 02:51:21 +02:00
Package1 options:
--outdir <dir> Specify Package1 directory path.
2018-09-17 03:26:16 +02:00
Package2 options:
--outdir <dir> Specify Package2 directory path.
2018-10-13 04:06:21 +02:00
INI1 options:
--outdir <dir> Specify INI1 directory path.
2018-07-08 18:40:55 +02:00
Switch FS options:
--sdseed <seed> Set console unique seed for SD card NAX0 encryption.
--listapps List application info.
--listtitles List title info for all titles.
2019-02-04 02:27:09 +01:00
--listncas List info for all NCAs.
2018-07-08 18:40:55 +02:00
--title <title id> Specify title ID to use.
2018-09-10 03:48:17 +02:00
--outdir <dir> Specify directory path to save title NCAs to. (--title must be specified)
--exefs <file> Specify ExeFS directory path. (--title must be specified)
--exefsdir <dir> Specify ExeFS directory path. (--title must be specified)
--romfs <file> Specify RomFS directory path. (--title must be specified)
--romfsdir <dir> Specify RomFS directory path. (--title must be specified)
2018-09-11 05:09:35 +02:00
--savedir <dir> Specify save file directory path.
2018-10-13 04:06:21 +02:00
-y, --verify Verify all titles, or verify a single title if --title is set.
2019-02-04 02:27:09 +01:00
Save data options:
2018-09-10 03:48:17 +02:00
--outdir <dir> Specify directory path to save contents to.
--debugoutdir <dir> Specify directory path to save intermediate data to for debugging.
2018-09-16 05:31:06 +02:00
--sign Sign the save file. (Requires device_key in key file)
2019-02-04 02:27:09 +01:00
--listfiles List files in save file.
--replacefile <filename in save> <file> Replaces a file in the save data
NDV0 (Delta) options:
Input delta patch can be a delta NCA file or a delta fragment file.
--basefile <file> Specify base file path.
--outfile Specify patched file path.
2018-10-13 04:06:21 +02:00
Keygen options:
--outdir <dir> Specify directory path to save key files to.
2018-07-08 18:40:55 +02:00
```
## Examples
#### List applications on a Switch SD card or NAND
`hactoolnet -t switchfs --sdseed <sd_seed> --listapps <sd_root_path>`
#### Extract a title from an SD card or NAND as NCA files
`hactoolnet -t switchfs --sdseed <sd_seed> --title <title_id> --outdir output <sd_root_path>`
#### Extract the RomFS from a title from an SD card or NAND
`hactoolnet -t switchfs --sdseed <sd_seed> --title <title_id> --romfsdir romfs <sd_root_path>`
Specifying the base title ID will extract the unpatched title.
Specifying the patch title ID will extract the patched title.
## External Keys
2018-09-10 03:48:17 +02:00
For more detailed information on keyset files, see [KEYS.md](KEYS.md).
2018-07-08 18:40:55 +02:00
Keys can be loaded from a text file by specifying a filename with the `-k` argument. The file should be in the same format read by [hactool](https://github.com/SciresM/hactool#external-keys):
"Keyset files are text files containing one key per line, in the form "key_name = HEXADECIMALKEY". Case shouldn't matter, nor should whitespace."
2018-07-09 18:47:32 +02:00
Console-unique keys can be loaded from a text file by specifying a filename with the `--consolekeys` argument. The file format is the same as the main keyset file.
2018-07-08 18:40:55 +02:00
Title keys can be loaded from a text file by specifying a filename with the `--titlekeys` argument. The file should contain one key per line in the form `rights_id,HEXADECIMALKEY`.
2019-02-26 05:55:25 +01:00
If a keyfile is not set at the command line, hactoolnet will search for and load keyfiles in `$HOME/.switch/prod.keys`, `$HOME/.switch/console.keys` and `$HOME/.switch/title.keys`.