Skip to content

Commit

Permalink
Update to v1.2.9.
Browse files Browse the repository at this point in the history
Make keys.txt follow the format needed by wad2bin (https://github.com/DarkMatterCore/wad2bin).
  • Loading branch information
DarkMatterCore committed Jun 16, 2020
1 parent 74bfe2f commit 014e1b3
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 68 deletions.
Binary file modified HBC/boot.dol
Binary file not shown.
Binary file modified HBC/boot.elf
Binary file not shown.
6 changes: 3 additions & 3 deletions HBC/meta.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<app version="1.1">
<name>Xyzzy</name>
<version>1.2.8</version>
<release_date>20200521000000</release_date>
<version>1.2.9</version>
<release_date>20200615220000</release_date>
<coder>Bushing, DarkMatterCore</coder>
<short_description>Extract your Wii console keys!</short_description>
<long_description>Xyzzy is a homebrew application that allows the extraction of the OTP and SEEPROM Encryption Keys.
Expand All @@ -14,7 +14,7 @@ Other changes include:
* Compatibility with USB mass storage devices.
* Support for GCN controllers and newer WiiMotes.
* Retrieves SD IV, MD5 Blanker and MAC address.
* Besides generating a "keys.txt" file with a hexdump of every dumped key, these files are also created:
* Besides generating a "keys.txt" file with a hexdump of every dumped key, which follows the format required by wad2bin (https://github.com/DarkMatterCore/wad2bin), these files are also created:
* "bootmii_keys.bin" (follows the BootMii keys.bin format).
* "device.cert" (raw device certificate dump).
* "otp.bin" (raw OTP memory dump).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Other changes include:
* Compatibility with USB mass storage devices.
* Support for GCN controllers and newer WiiMotes.
* Retrieves SD IV, MD5 Blanker and MAC address.
* Besides generating a "keys.txt" file with a hexdump of every dumped key, these files are also created:
* Besides generating a "keys.txt" file with a hexdump of every dumped key, which follows the format required by [wad2bin](https://github.com/DarkMatterCore/wad2bin), these files are also created:
* "bootmii_keys.bin" (follows the BootMii keys.bin format).
* "device.cert" (raw device certificate dump).
* "otp.bin" (raw OTP memory dump).
Expand Down
40 changes: 2 additions & 38 deletions source/tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,43 +363,7 @@ char *StorageDeviceMountName(void)
return str;
}

static char ascii(char s)
{
if (s < 0x20 || s > 0x7E) return '.';
return s;
}

void HexDump(FILE *fp, void *d, size_t len)
{
if (!fp || !d || !len) return;

size_t i, off;
u8 *data = (u8*)d;

for(off = 0; off < len; off += 16)
{
fprintf(fp, "%08X ", off);

for(i = 0; i < 16; i++)
{
if ((i + off) >= len) break;
fprintf(fp, "%02X", data[off + i]);
if ((i + 1) < 16) fprintf(fp, " ");
}

fprintf(fp, " ");

for(i = 0; i < 16; i++)
{
if ((i + off) >= len) break;
fprintf(fp, "%c", ascii(data[off + i]));
}

fprintf(fp, "\r\n");
}
}

void HexKeyDump(FILE *fp, void *d, size_t len)
void HexKeyDump(FILE *fp, void *d, size_t len, bool add_spaces)
{
if (!fp || !d || !len) return;

Expand All @@ -410,7 +374,7 @@ void HexKeyDump(FILE *fp, void *d, size_t len)
{
fprintf(fp, "%02X", data[i]);

if ((i + 1) < len)
if (add_spaces && (i + 1) < len)
{
if (((i + 1) % 16) > 0)
{
Expand Down
5 changes: 2 additions & 3 deletions source/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <wiiuse/wpad.h>
#include <malloc.h>

#define VERSION "1.2.8"
#define VERSION "1.2.9"

//#define IsWiiU() (((*(vu32*)0xCD8005A0) >> 16) == 0xCAFE)
#define ResetScreen() printf("\x1b[2J")
Expand Down Expand Up @@ -33,8 +33,7 @@ int SelectStorageDevice(void);
char *StorageDeviceString(void);
char *StorageDeviceMountName(void);

void HexDump(FILE *fp, void *d, size_t len);
void HexKeyDump(FILE *fp, void *d, size_t len);
void HexKeyDump(FILE *fp, void *d, size_t len, bool add_spaces);

signed_blob *GetSignedTMDFromTitle(u64 title_id, u32 *out_size);

Expand Down
63 changes: 40 additions & 23 deletions source/xyzzy.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static const char *priiloader_files[] = {

static const u32 priiloader_files_count = (u32)MAX_ELEMENTS(priiloader_files);

static const char *key_names[] = {
static const char *key_names_stdout[] = {
"boot1 Hash ",
"Common Key ",
"Console ID ",
Expand All @@ -110,6 +110,24 @@ static const char *key_names[] = {
NULL
};

static const char *key_names_txt[] = {
"boot1_hash ",
"wii_common_key ",
"console_id ",
"ecc_private_key ",
"nand_hmac ",
"nand_aes_key ",
"prng_key ",
"ng_key_id ",
"ng_signature ",
"wii_korean_key ",
"sd_key ",
"sd_iv ",
"md5_blanker ",
"mac_address ",
NULL
};

static void OTP_ClearData(void)
{
memset(otp_ptr, 0, OTP_SIZE);
Expand Down Expand Up @@ -425,11 +443,12 @@ static void GetMACAddress(void)
}
}

static void PrintAllKeys(otp_t *otp_data, seeprom_t *seeprom_data, FILE *fp)
static void PrintAllKeys(otp_t *otp_data, seeprom_t *seeprom_data, FILE *fp, bool is_txt)
{
if (!otp_data || !fp) return;

u8 key_idx = 1;
const char **key_names = (is_txt ? key_names_txt : key_names_stdout);

/* We'll use this for the Korean common key check */
u8 null_key[16] = {0};
Expand All @@ -446,42 +465,47 @@ static void PrintAllKeys(otp_t *otp_data, seeprom_t *seeprom_data, FILE *fp)
/* Only display the current additional key if we retrieved it */
if (i >= 10 && !additional_keys[i - 10].retrieved) continue;

fprintf(fp, "[%u] %s: ", key_idx, key_names[i]);
if (is_txt)
{
fprintf(fp, "%s= ", key_names[i]);
} else {
fprintf(fp, "[%u] %s: ", key_idx, key_names[i]);
}

switch(i)
{
case 0: // boot1 Hash
HexKeyDump(fp, otp_data->boot1_hash, sizeof(otp_data->boot1_hash));
HexKeyDump(fp, otp_data->boot1_hash, sizeof(otp_data->boot1_hash), !is_txt);
break;
case 1: // Common Key
HexKeyDump(fp, otp_data->common_key, sizeof(otp_data->common_key));
HexKeyDump(fp, otp_data->common_key, sizeof(otp_data->common_key), !is_txt);
break;
case 2: // Console ID
HexKeyDump(fp, otp_data->ng_id, sizeof(otp_data->ng_id));
HexKeyDump(fp, otp_data->ng_id, sizeof(otp_data->ng_id), !is_txt);
break;
case 3: // ECC Priv Key
HexKeyDump(fp, otp_data->ng_priv, sizeof(otp_data->ng_priv));
HexKeyDump(fp, otp_data->ng_priv, sizeof(otp_data->ng_priv), !is_txt);
break;
case 4: // NAND HMAC
HexKeyDump(fp, otp_data->nand_hmac, sizeof(otp_data->nand_hmac));
HexKeyDump(fp, otp_data->nand_hmac, sizeof(otp_data->nand_hmac), !is_txt);
break;
case 5: // NAND AES Key
HexKeyDump(fp, otp_data->nand_key, sizeof(otp_data->nand_key));
HexKeyDump(fp, otp_data->nand_key, sizeof(otp_data->nand_key), !is_txt);
break;
case 6: // PRNG Key
HexKeyDump(fp, otp_data->rng_key, sizeof(otp_data->rng_key));
HexKeyDump(fp, otp_data->rng_key, sizeof(otp_data->rng_key), !is_txt);
break;
case 7: // NG Key ID
HexKeyDump(fp, &(seeprom_data->ng_key_id), sizeof(seeprom_data->ng_key_id));
HexKeyDump(fp, &(seeprom_data->ng_key_id), sizeof(seeprom_data->ng_key_id), !is_txt);
break;
case 8: // NG Signature
HexKeyDump(fp, seeprom_data->ng_sig, sizeof(seeprom_data->ng_sig));
HexKeyDump(fp, seeprom_data->ng_sig, sizeof(seeprom_data->ng_sig), !is_txt);
break;
case 9: // Korean Key
HexKeyDump(fp, seeprom_data->korean_key, sizeof(seeprom_data->korean_key));
HexKeyDump(fp, seeprom_data->korean_key, sizeof(seeprom_data->korean_key), !is_txt);
break;
default: // Additional keys
HexKeyDump(fp, additional_keys[i - 10].key, additional_keys[i - 10].key_size);
HexKeyDump(fp, additional_keys[i - 10].key, additional_keys[i - 10].key_size, !is_txt);
break;
}

Expand Down Expand Up @@ -588,19 +612,12 @@ int XyzzyGetKeys(bool vWii)
}

/* Print all keys to stdout */
PrintAllKeys(otp_data, seeprom_data, stdout);
PrintAllKeys(otp_data, seeprom_data, stdout, false);

if (fp)
{
/* Print all keys to output txt */
PrintAllKeys(otp_data, seeprom_data, fp);

/* This will create a hexdump of the device.cert in the selected device */
if (devcert)
{
fprintf(fp, "\r\nDevice cert:\r\n");
HexDump(fp, devcert, DEVCERT_SIZE);
}
PrintAllKeys(otp_data, seeprom_data, fp, true);

fclose(fp);
fp = NULL;
Expand Down

0 comments on commit 014e1b3

Please sign in to comment.