Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
GaryOderNichts committed Mar 28, 2020
2 parents 97169c8 + 74a04e2 commit 7d866a0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Wii (U) NAND Extractor written in C

## Usage
`extractor.exe nand.bin`
`extractor-win.exe nand.bin` or for linux `./extractor-linux nand.bin`
keys.bin or otp.bin needs to be in the same folder.

## Build
build with gcc
build with gcc
To build for linux you need to replace the io.h with the linux headers and add a mode to mkdir
12 changes: 11 additions & 1 deletion extractor.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ int main(int argc, char* argv[])

fclose(rom);
free(key);
free(nandName);

return 0;
}
Expand Down Expand Up @@ -199,7 +200,10 @@ byte_t* readKeyfile(char* path)

FILE* keyfile = fopen(path, "rb");
if (keyfile == NULL)
{
free(retval);
return NULL;
}

fseek(keyfile, 0x158, SEEK_SET);
fread(retval, sizeof(byte_t), 16, keyfile);
Expand All @@ -214,7 +218,10 @@ byte_t* readOTP(char* path)

FILE* otpfile = fopen(path, "rb");
if (otpfile == NULL)
{
free(retval);
return NULL;
}

if (nandType == Wii)
fseek(otpfile, 0x058, SEEK_SET);
Expand Down Expand Up @@ -487,7 +494,7 @@ void extractFile(fst_t fst, uint16_t entry, char* parent)
for (int i = 0; fat < 0xFFF0; i++)
{
//extracting...
printf("extracting %s cluster %i\n", fst.filename, i);
printf("extracting %s cluster %i\n", filename, i);
byte_t* cluster = getCluster(fat);
memcpy((byte_t*) (data + (i * 0x4000)), cluster, 0x4000);
fat = getFAT(fat);
Expand All @@ -510,6 +517,7 @@ byte_t* aesDecrypt(byte_t* key, byte_t* enc_data, size_t data_size)
{
byte_t* dec_data = calloc(data_size, sizeof(byte_t));
memcpy(dec_data, enc_data, data_size);
free(enc_data);

const byte_t* iv = calloc(16, sizeof(byte_t));

Expand All @@ -518,6 +526,8 @@ byte_t* aesDecrypt(byte_t* key, byte_t* enc_data, size_t data_size)

AES_CBC_decrypt_buffer(&ctx, dec_data, data_size);

free(iv);

return dec_data;
}

Expand Down

0 comments on commit 7d866a0

Please sign in to comment.