In memory of Ben “bushing” Byer, who passed away on Monday, February 8th, 2016.

Difference between revisions of "Talk:Wii Savegame Parser"

From WiiBrew
Jump to navigation Jump to search
m (Robot: Cosmetic changes)
 
(19 intermediate revisions by 5 users not shown)
Line 1: Line 1:
== Talk: Savegame Parser ==
 
 
 
Hi all,
 
Hi all,
Im getting interested in the hack of the savegames.
+
I'm getting interested in the hack of the savegames.
It looks a first step to hack all the ecryption protections of the Wii, because it could provide many information about algorithms used by the console.
+
It looks a first step to hack all the encryption protections of the Wii, because it could provide many information about algorithms used by the console.
 
In other hand, I'm interested in security and it seems to be a entertainment exercising the knowledgement.
 
In other hand, I'm interested in security and it seems to be a entertainment exercising the knowledgement.
  
I'm using a Wii and games bought in Germany. I've made several comparisions between savegames of Zelda and WiiSports.
+
I'm using a Wii and games bought in Germany. I've made several comparisons between savegames of Zelda and WiiSports.
  
 
I've converted the script to C# and written a small application which parses the savegames.
 
I've converted the script to C# and written a small application which parses the savegames.
  
 
Comparing the data with the parser, the first remark is with the magic value right after the Mac Address.
 
Comparing the data with the parser, the first remark is with the magic value right after the Mac Address.
Istead of a 0xF5550000 I've got a 0x90900000. Hmmmmm... Different zone?
+
Instead of a 0xF5550000 I've got a 0x90900000. Hmmmmm... Different zone?
  
 
It is interesting for me the size of the hashes.
 
It is interesting for me the size of the hashes.
 
The most used standard algorithms are:
 
The most used standard algorithms are:
 
MD4 16 bytes (algorithm broken)
 
MD4 16 bytes (algorithm broken)
MD5 16 bytes (algorithm broken, but still in use because its an internet standard)
+
MD5 16 bytes (algorithm broken, but still in use because it's an internet standard)
 
RIPEMD 16 bytes
 
RIPEMD 16 bytes
 
SHA-1 20 bytes
 
SHA-1 20 bytes
Line 39: Line 37:
 
I've saved two games (Zelda and Wiisport) in different days. When comparing the files, I'm trying to check which data is the same, so it depends only on the Wii.
 
I've saved two games (Zelda and Wiisport) in different days. When comparing the files, I'm trying to check which data is the same, so it depends only on the Wii.
 
Basically the header is different, the hash #1 too (which I think depends on the game) too, the block sizes are different and the encrypted data too.
 
Basically the header is different, the hash #1 too (which I think depends on the game) too, the block sizes are different and the encrypted data too.
But hash #3, all the RootCA information and hash #4 are identical, which means they are independendent of the game and the time.
+
But hash #3, all the RootCA information and hash #4 are identical, which means they are independent of the game and the time.
  
 
Hmmm I'll continue investigating.
 
Hmmm I'll continue investigating.
Line 49: Line 47:
 
I've been tinkering with the save files and the results are bizarre. For example, I took a Wii Sports file and changed the "number of files" to 2, and it copied back to the system just fine. I tried some other values and it wouldn't copy anymore, so I tried 2 again and it still wouldn't! But after changing back to 1, it would copy again, and I checked no other bytes were changed. WTF? This happens in other cases too, such as the file size. It accepts the first change, but after that only the original file. [[User:142.59.173.240|142.59.173.240]] 22:00, 22 March 2007 (PDT)
 
I've been tinkering with the save files and the results are bizarre. For example, I took a Wii Sports file and changed the "number of files" to 2, and it copied back to the system just fine. I tried some other values and it wouldn't copy anymore, so I tried 2 again and it still wouldn't! But after changing back to 1, it would copy again, and I checked no other bytes were changed. WTF? This happens in other cases too, such as the file size. It accepts the first change, but after that only the original file. [[User:142.59.173.240|142.59.173.240]] 22:00, 22 March 2007 (PDT)
  
== Format Testing ==
+
== Things that need to be looked into ==
* 0x0000 - 0xF0C0: Header - Guessing it's an Image since it's the same for all saves from same game.
 
* 0xF0C0 - 0xF0C4: Magic = 0x00000070 (112L)
 
* 0xF0C4 - 0xF0C8: Magic = 0x426b0001 (1114308609L)
 
* 0xF0C8 - 0xF0CC: Wii ID (same as certificate in later section)
 
* 0xF0CC - 0xF0D0: Number of files in this save file.
 
* 0xF0D0 - 0xF0D4: Size of all files in this save file.
 
* 0xF0D4 - 0xF0D8: Magic = 0x00000000 (0L)
 
* 0xF0D8 - 0xF0DC: Magic = 0x00000000 (0L)
 
* 0xF0DC - 0xF0E0: Post Header Length (This plus the data at 0xF0D0 equals the file size)
 
* 0xF0E0 - 0xF120: 64 (0x40) bytes of Zeros
 
* 0xF120 - 0xF124: Magic = 0x00010000 (65536L)
 
* 0xF124 - 0xF128: Four character program ID, e.g. "RSPE"
 
* 0xf128 - 0xF130: MAC address of Wii.  (plus two wasted bytes)
 
* 0xF130 - 0xF140: 16 byte hash.  Probably hashes Header (0x0000-0xF0C0) since it changes as that data changes.
 
  
-- Per File Data --
+
* What is the relationship between hash1 and the header?
* 0xF140 - 0xF144: Magic = 0x03adf17e (61731198L)
+
* Is the header a image? What format?
* 0xF144 - 0xF148: File Size of this file  (For this example, assume size of 0x20000)
+
* Why does hash2 always start with a zero? It tells me we're off by one byte somewhere.
* 0xF148 - 0xF149: Unknown Byte, values are 0x30, 0x34 and 0x3C
+
* What does the per file padding really look like?
* 0xF149 - 0xF14A: Unknown Byte, values are 0x00
+
* Verify all hash sizes.
* 0xF14A - 0xF14B: Unknown Byte, values are 0x01
 
* 0xF14b        : Zero terminated file name, e.g. 'RPSports.dat'
 
  
Unclear how things are ordered:
+
== Elliptical Hash Info ==
* Possible string file name filler
 
* File Data, length from 0xF144
 
* Possible Data Filler to round data out to 64 byte boundary
 
  
-- Done with Per File Data --
+
There is new information about the hash used in the save game file. See the forum post here: http://forums.nintendo-scene.com/index.php?topic=797.0. "The crypto used for wii savegame files is sect233r1"
Addresses assume file size of 0x20000
 
0x2F1C0 - 0x2F1FC: Hash data, 60 (0x3C) bytes long. This is suspect since it always starts with a zero byte.
 
0x2F1FC - 0x2F200: Magic = 0x00000000 (0L)
 
0x2F200 - 0x2F204: Magic = 0x00010002 (65538L)
 
0x2F204 - 0x2F240: Hash data, 60 (0x3C) bytes long
 
0x2F240 - 0x2F280: 64 (0x40) bytes of zeros
 
  
0x2F280 - 0x2F280: 64 (0x40) bytes of zeros
+
This refers to hash 6 from the output of the Savegame Parser. I was able to verify this by compiling OpenSSL, checkkey.c (from the forum and running it with the data from one of my save games. Here is the output (for what it's worth):
0x0002f280 | String RootCA ends after 26L bytes "Root-CA00000001-MS00000002"
 
0x0002f29b | Block 'Zeros' length 37L (0x25) bytes.
 
0x0002f2c0 |  Magic 0x00000002 (2L)...                  Check passed!
 
0x0002f2c4 | String NG ends after 10L bytes "NG0232097a"
 
  
 +
D:\>WiiCheckKey.exe 0010A5965B39842061168F9E548CD0C1DB77181BD470905071C41D7BB62C 0128946F2BEB5F3A621F1964212DED020C1239E256B50B60E321B1C95450
 +
Read key data:
 +
PUBX: 0010A5965B39842061168F9E548CD0C1DB77181BD470905071C41D7BB62C
 +
PUBY: 0128946F2BEB5F3A621F1964212DED020C1239E256B50B60E321B1C95450
 +
Checking key: **** Valid public key ****
  
* Yeah the math is off by one for the ending address.
+
It's interesting hash3 and hash5 didn't come up as valid keys. I don't know if that's a parser problem of something else.
 +
--PaceMaker

Latest revision as of 05:03, 12 August 2009

Hi all, I'm getting interested in the hack of the savegames. It looks a first step to hack all the encryption protections of the Wii, because it could provide many information about algorithms used by the console. In other hand, I'm interested in security and it seems to be a entertainment exercising the knowledgement.

I'm using a Wii and games bought in Germany. I've made several comparisons between savegames of Zelda and WiiSports.

I've converted the script to C# and written a small application which parses the savegames.

Comparing the data with the parser, the first remark is with the magic value right after the Mac Address. Instead of a 0xF5550000 I've got a 0x90900000. Hmmmmm... Different zone?

It is interesting for me the size of the hashes. The most used standard algorithms are: MD4 16 bytes (algorithm broken) MD5 16 bytes (algorithm broken, but still in use because it's an internet standard) RIPEMD 16 bytes SHA-1 20 bytes SHA-224 28 bytes SHA-256 32 bytes SHA-348 48 bytes SHA-512 64 bytes I don't know any hash algorithm with a digest of 60bytes like the most of the hashes sizes in the savegame file. Could it be a signed hash? In that case, the size of the signature depends on the size of the key. Hmmm more investigation is needed here.

The hash #1 is a 16 bytes array. It seems to be depending on the game. I have the same hash for all the WiiSports savegames and another for the all the Zelda ones. I would say it is some kind of hash of the header.


First experiment: I've saved twice in different cards the same savegame of Zelda. I've compared the two serialized files, and the only differences are in the Hashes #2, #5 and #6. The rest of the files are identical. In that case, I can suppose that some kind of Initialization Vector is used. But in this case the encrypted data is the same, which makes me think that its better some kind of timestamp, probably in the Hash #2, which makes different the other two hashes. So they don't use IV for encryption.

Second experiment: I've saved two games (Zelda and Wiisport) in different days. When comparing the files, I'm trying to check which data is the same, so it depends only on the Wii. Basically the header is different, the hash #1 too (which I think depends on the game) too, the block sizes are different and the encrypted data too. But hash #3, all the RootCA information and hash #4 are identical, which means they are independent of the game and the time.

Hmmm I'll continue investigating. Greetings! Aykito.

Why is it rejecting/accepting modified files inconsistently?

I've been tinkering with the save files and the results are bizarre. For example, I took a Wii Sports file and changed the "number of files" to 2, and it copied back to the system just fine. I tried some other values and it wouldn't copy anymore, so I tried 2 again and it still wouldn't! But after changing back to 1, it would copy again, and I checked no other bytes were changed. WTF? This happens in other cases too, such as the file size. It accepts the first change, but after that only the original file. 142.59.173.240 22:00, 22 March 2007 (PDT)

Things that need to be looked into

  • What is the relationship between hash1 and the header?
  • Is the header a image? What format?
  • Why does hash2 always start with a zero? It tells me we're off by one byte somewhere.
  • What does the per file padding really look like?
  • Verify all hash sizes.

Elliptical Hash Info

There is new information about the hash used in the save game file. See the forum post here: http://forums.nintendo-scene.com/index.php?topic=797.0. "The crypto used for wii savegame files is sect233r1"

This refers to hash 6 from the output of the Savegame Parser. I was able to verify this by compiling OpenSSL, checkkey.c (from the forum and running it with the data from one of my save games. Here is the output (for what it's worth):

D:\>WiiCheckKey.exe 0010A5965B39842061168F9E548CD0C1DB77181BD470905071C41D7BB62C 0128946F2BEB5F3A621F1964212DED020C1239E256B50B60E321B1C95450 Read key data: PUBX: 0010A5965B39842061168F9E548CD0C1DB77181BD470905071C41D7BB62C PUBY: 0128946F2BEB5F3A621F1964212DED020C1239E256B50B60E321B1C95450 Checking key: **** Valid public key ****

It's interesting hash3 and hash5 didn't come up as valid keys. I don't know if that's a parser problem of something else.

--PaceMaker