2018-06-21 18:16:51 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
2018-06-21 23:03:58 +02:00
|
|
|
|
using System.Linq;
|
2018-06-21 16:25:20 +02:00
|
|
|
|
using libhac;
|
2018-06-16 19:11:38 +02:00
|
|
|
|
|
2018-06-21 16:25:20 +02:00
|
|
|
|
namespace hactoolnet
|
2018-06-16 19:11:38 +02:00
|
|
|
|
{
|
2018-06-21 16:25:20 +02:00
|
|
|
|
public static class Program
|
2018-06-16 19:11:38 +02:00
|
|
|
|
{
|
|
|
|
|
static void Main(string[] args)
|
2018-06-21 18:16:51 +02:00
|
|
|
|
{
|
|
|
|
|
ListSdContents(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void DecryptNax0(string[] args)
|
2018-06-16 19:11:38 +02:00
|
|
|
|
{
|
2018-06-20 19:42:56 +02:00
|
|
|
|
var keyset = ExternalKeys.ReadKeyFile(args[0]);
|
|
|
|
|
keyset.SetSdSeed(args[1].ToBytes());
|
|
|
|
|
|
|
|
|
|
var nax0 = new Nax0(keyset, args[2], args[3]);
|
2018-06-21 16:25:20 +02:00
|
|
|
|
var nca = new Nca(keyset, nax0.Stream);
|
|
|
|
|
|
2018-06-20 19:42:56 +02:00
|
|
|
|
using (var output = new FileStream(args[4], FileMode.Create))
|
|
|
|
|
using (var progress = new ProgressBar())
|
|
|
|
|
{
|
2018-06-21 23:03:58 +02:00
|
|
|
|
progress.LogMessage($"Title ID: {nca.Header.TitleId:X16}");
|
2018-06-20 19:42:56 +02:00
|
|
|
|
progress.LogMessage($"Writing {args[4]}");
|
2018-06-21 16:25:20 +02:00
|
|
|
|
nax0.Stream.CopyStream(output, nax0.Stream.Length, progress);
|
2018-06-20 19:42:56 +02:00
|
|
|
|
}
|
2018-06-16 19:11:38 +02:00
|
|
|
|
}
|
2018-06-21 18:16:51 +02:00
|
|
|
|
|
|
|
|
|
static void ListSdContents(string[] args)
|
|
|
|
|
{
|
|
|
|
|
var keyset = ExternalKeys.ReadKeyFile(args[0]);
|
|
|
|
|
keyset.SetSdSeed(args[1].ToBytes());
|
|
|
|
|
var sdfs = new SdFs(keyset, args[2]);
|
2018-06-21 23:03:58 +02:00
|
|
|
|
var ncas = sdfs.ReadAllNca().ToArray();
|
2018-06-21 18:16:51 +02:00
|
|
|
|
|
|
|
|
|
foreach (var nca in ncas)
|
|
|
|
|
{
|
2018-06-21 23:03:58 +02:00
|
|
|
|
Console.WriteLine($"{nca.Header.TitleId:X16} {nca.Header.ContentType} {nca.Name}");
|
2018-06-21 18:16:51 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-06-16 19:11:38 +02:00
|
|
|
|
}
|
|
|
|
|
}
|