<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>HackMii</title>
	<atom:link href="http://hackmii.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://hackmii.com</link>
	<description>Notes from inside your Wii</description>
	<lastBuildDate>Mon, 01 Feb 2010 14:08:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Lawsuit coming in 3.. 2.. 1..</title>
		<link>http://hackmii.com/2010/02/lawsuit-coming-in-3-2-1/</link>
		<comments>http://hackmii.com/2010/02/lawsuit-coming-in-3-2-1/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 12:12:50 +0000</pubDate>
		<dc:creator>blasty</dc:creator>
				<category><![CDATA[Wii]]></category>

		<guid isPermaLink="false">http://hackmii.com/?p=916</guid>
		<description><![CDATA[Recently I was informed that Datel has released a new version of their Action Replay Cheat Cartridge that allows you to cheat in DS games on a DSi console. Knowing that Nintendo put quite some effort in blocking any third party cartridges from working on the DSi I was curious to figure out how they [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was informed that Datel has released a new version of their Action Replay Cheat Cartridge that allows you to cheat in DS games on a DSi console. Knowing that Nintendo put quite some effort in blocking any third party cartridges from working on the DSi I was curious to figure out how they did it.</p>
<p>Before jumping in this article, I&#8217;ll give you a small warning that what is written here might be quite &#8220;techy&#8221; to some people, I advise reading lots of <a href="http://nocash.emubase.de/gbatek.htm">GBAtek</a> (And maybe a bit of <a href="http://dsibrew.org/">dsibrew</a>) when you get lost. <img src='http://hackmii.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p><span id="more-916"></span></p>
<p>Research&#0153; has shown that getting a DS cart to boot on a DSi requires quite a bit more effort then it did on a (DS)Lite. Cart timings are very important, you cannot eject the cartridge and insert a new one beyond the DSi menu. But most important of all, the DSi menu does additional integrity checking prior to booting the cartridge.</p>
<p>The integrity checking is there to ensure that the cartridge booted is a genuine licensed game cartridge. There is a whitelist stored in the DSi&#8217;s NAND, that has an entry for every DS game released, consisting of multiple SHA1 (How these hashes are constructed exactly hasn&#8217;t been confirmed) checksums for the cart header, ARM9 binary and ARM7 binary.</p>
<p>I hear you thinking, what about newly released DS games? How will they ever boot on a DSi without an update to the whitelist? Newer DS games come with a RSA signature in the header and so don&#8217;t need to be explicitly whitelisted.</p>
<p>So back to the Action Replay DSi cartridge, something that I immediatly noticed is that when the cartridge is inserted into a DSi the icon and title of the game &#8220;<strong><a href="http://ds.ign.com/articles/725/725434p1.html">Game &amp; Watch Collection</a></strong>&#8221; show up. That&#8217;s a little weird.. but when selecting the icon you are thrown into a AR DSi menu.</p>
<p>Let&#8217;s take a step back, if all game binaries and headers are checked against a whitelist or need to have a valid RSA signature, then how does this Datel cart manage to boot?</p>
<p>I went to find the sourcecode of my cartridge dumper and dumped the AR DSi cartridge on an old DS-Lite. after checking out the resulting binary I was surprised. No signs of the &#8220;Game &amp; Watch Collection&#8221; ROM header or icon data, or main data for that matter..</p>
<p><code style='font-size:8pt;color:blue;font-weight:bold'>$ hexdump -C ardsi.nds | head -n 2<br />
00000000  4d 45 44 49 41 50 4c 41  59 45 52 20 41 53 4d 41  |MEDIAPLAYER ASMA|<br />
00000010  30 31 00 00 07 00 00 00  00 00 00 00 00 00 00 04  |01..............|<br />
</code><br />
This doesn&#8217;t match up with what I saw when the cart was booted on a DSi, huh? Neither would this cartheader qualify as anything whitelisted/valid, so there is no way it could boot on a DSi like this.</p>
<p>After a small discussion with neimod he showed me a cart access trace he made of a game cartridge in a DSi. Something noticeable was that a DSi would send the ROM ID cart command right after the reset command, before sending the get header cmd. My dumper software was doing it in a bit different order&#8230; (The order an actual (DS)Lite would do it in)</p>
<p>This small difference in order of cart commands allows the AR DSi cartridge to distuingish between a DS(-Lite) and DSi console.</p>
<p>For the sake of clarity:</p>
<p><strong>DS-Lite cart init sequence</strong>:<br />
<code style='font-weight:bold'>CMD 9f00000000000000 # reset<br />
CMD 0000000000000000 # get header<br />
CMD 9000000000000000 # get rom_id<br />
CMD ...</code></p>
<p><strong>DSi cart init sequence</strong>:<br />
<code style='font-weight:bold'>CMD 9f00000000000000 # reset<br />
CMD 9000000000000000 # get rom_id<br />
CMD 0000000000000000 # get header<br />
CMD ...</code></p>
<p>After making this small change to my dumper software, I was indeed getting back something that looked like a Game&#038;Watch collection ROM.</p>
<p><code style='font-size:8pt;color:blue;font-weight:bold;'>$ hexdump -C ardsi2.nds | head -n 2<br />
00000000  47 41 4d 45 20 57 41 54  43 48 20 43 41 57 54 45  |GAME WATCH CAWTE|<br />
00000010  30 31 00 00 06 00 00 00  00 00 00 00 00 00 00 00  |01..............|<br />
</code></p>
<p>Almost there! .. or so I thought. When I started comparing the original game &#038; watch collection ROM against the result I just dumped, I got nothing but mismatches after the initial 0x8000 bytes (header + secure area).</p>
<p>More and more inspection of the dump and head-to-table banging later I noticed something funny, the data in the dump at 0x8000 (right where the mismatches start) was exactly the data that was supposed to be at 0x10C00, which coincendetly matched up with the exact start offset of the icon/title data. What&#8217;s going on? Why does this data show up in the wrong location of the dump?</p>
<p>Then a pattern started to emerge, the right data WAS there, just in the wrong order .. then it hit me. The AR DSI cart was completely ignoring the offset field in the read (0xB7) commands I was sending, and simply advancing a preconstructed buffer that would exactly match the reply data of the commands a DSi console would normally send. This has advantage that they only need to require a bare-minimum of data of the original game ROM.</p>
<p>With this knowledge in hand I tried reordering the dump in order to get a final ROM image. This proved to be quite tricky since I didn&#8217;t know when what was exactly read. I then proceeded to hack up Desmume to log all cart reads and match that against a table of the filesystem to figure out in what order the files we&#8217;re read. Even now it was hard to get a good reconstruction of the dump, some files are only read partially, etc.</p>
<p>So I decided to build a list of MD5 hashes of each 0x200 block in the original ROM dump, and the shuffled AR DSi dump .. which was the best idea of the day. A couple of minutes later I knew in which order to put what blocks back, and was left over with 3 blocks that didn&#8217;t match (0x600 bytes total) any of the blocks in the original ROM.</p>
<p>Due to the preceding read commands I could see where in the dump these 0x600 bytes should go (comparing it against the<br />
cart read access log I made using DesMuMe), and I finally had a final image. Now it was time to figure out how this<br />
thing actually worked it&#8217;s magic. The answer was obviously in those 3 changed blocks. <img src='http://hackmii.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>To give you a quick idea of exactly how much code/data they borrowed from the original ROM, there is 1984 blocks of 0x200 bytes from the original ROM, of which 1825 blocks are unique, 1825 * 0x200 = ~912Kb of data from the original ROM.</p>
<p>Sure enough the 3 new changed blocks didn&#8217;t fall within the area of the ARM9 or ARM7 binary of the game, else it wouldn&#8217;t pass the whitelist. I expected it to be a file-based exploit in one of the few files within the nitro filesystem on the cartridge, but all the offsets of those files weren&#8217;t in range.</p>
<p>I had a quick look at the 3 new blocks in a hex editor and noticed there was plain ARM opcodes in there, and a big landpad with EAFFFFFE&#8217;s in front (label: b label). I started by disassembling this code, not caring HOW it eventually ends up in memory.</p>
<p>The small amount of code does some basic initialisation, then proceeds to send a special cart command that puts the ARDSi cartridge in a different mode.  After this three read (0xB7) commands are executed to read and copy out the header, ARM9 binary and ARM7 binary respectively. By this I mean ofcourse the *actual* AR DSi menu header / binaries.</p>
<p>Knowing what their shellcode did was half of the job, now I had to figure out how it ended up executed in memory. Going back to the ROM I realized I didn&#8217;t check the *entire* filesystem range for the offset in which the blocks lie. To be more precise, I had only checked within the boundaries of the filesystem entries that have an entry in the File Name Table.</p>
<p>Nintendo DS ROMs can feature a thing that is known as &#8220;filesystem overlays&#8221; or &#8220;rom overlays&#8221;. These overlays are described in separate tables (pointed to by the NDS cartridge header). Overlay tables consist out of entries that look like this:<br />
<code style='font-size:8pt;color:black;font-weight:bold'><br />
    /* 0x00 */ u32 id;<br />
    /* 0x04 */ u32 ram_addr;<br />
    /* 0x08 */ u32 ram_size;<br />
    /* 0x0C */ u32 bss_size;<br />
    /* 0x10 */ u32 sinit_init;<br />
    /* 0x14 */ u32 sinit_init_end;<br />
    /* 0x18 */ u32 file_id;<br />
    /* 0x1C */ u32 unknown;<br />
</code></p>
<p>These overlays are pieces of code that normally aren&#8217;t loaded together with the main binary, but rather can be loaded on-demand by the main binary.</p>
<p>The important fields here are: id &#8211; a unique identifier (incrementing number) for the current overlay, ram_addr &#8211; the address the overlay is copied to in memory when it is loaded, ram_size &#8211; the size in RAM reserved for this overlay, file_id &#8211; the index of the overlay file in the filesystem table.</p>
<p>Cross checking the filesystem indexes of the overlays against my card access trace from desmume I determined that the 3 changed were infact the first 3 blocks of overlay 0x01.</p>
<p>To not make this article any more lenghty than it already is, here&#8217;s what happens:</p>
<ul>
<li>DSi console sends cart initialisation sequence</li>
<li>ARDSi cart determines it&#8217;s being ran on a DSi console and starts responding a fixed pattern on every read block request</li>
<li>Game&#8217;s header, ARM9 and ARM7 binary are loaded by the DSi menu and checked for integrity</li>
<li>Integrity checks pass since all data is 1:1 compared to the original ROM</li>
<li>Game starts running, parsing filename and file allocation tables of filesystem on cartridge</li>
<li>Game loads overlay 0x01 to 0x020BBF00</li>
<li>Game does more stuff and eventually branches to code inside loaded overlay @ 0x020BBFE8</li>
<li>The initial 0xE8 bytes of the datel payload are inifite-loop opcodes, entrypoint right behind it, payload gets executed</li>
<li>Payload sends secret <b>F005000000000000</b> (Not so secret anymore now, huh?) cart command to put cartridge in secondary mode</li>
<li>Payload uses normal 0xB7 read commands to read the header, ARM9 binary and ARM7 binary respectively</li>
<li>Some IPC magic is done to capture execution of the ARM7 cpu</li>
<li>Finally a softreset SVC/SWI is issued to execute the newly loaded ARM9 code</li>
</ul>
<p>And here I was hoping datel had a clever technique under their belt to leverage code in DS mode on a DSi. But it seems like everyone else (read: HK flashcart companies), they aswell had to resort to &#8216;borrowing&#8217; bits of a commerial game ROM. The only clever thing here is storing the actual payload inside a ROM overlay that is loaded early in the game. The overlays dont seem to be checked by the DSi menu during the integrity check, and they don&#8217;t have to rely on a buffer overflow or other tricky attack in order to get their code running.</p>
<p><b>EDIT:</b> Normmatt just mentioned on IRC that the DSi menu might be infact checking the ROM overlays. Comparing the SHA sums in the whitelist for a game that has overlays and for a game that doesn’t shows that one of the hashes is empty for a game that has _no_ ROM overlays. This all make sense, the DSi menu initially reads the overlays to check their integrity, but when the game is ran it loads the overlay on demand, different data is served and the system is fooled into loading the malicious code in memory.</p>
<p>The thing I&#8217;m wondering most is how Datel was planning to get away with this? Someone mentioned the argument of the ROM data being there &#8220;just for interoperability&#8221; and that would justify it a bit. But in my opinion borrowing roughly a megabyte of original ROM data is a different ballgame than borrowing a couple of (Ok, 48) bytes for the <a href="http://gbdev.gg8.se/wiki/articles/The_Cartridge_Header#0104-0133_-_Nintendo_Logo">Nintendo logo</a>. I would be interested to hear you guys&#8217; opinions on the ethical part of this whole thing.</p>
<p>Oh well, it made for a nice sunday of reverse engineering anyway. Hopefully you enjoyed the read as much as I did working this out, ciao! <b>;-]</b></p>
<p>P.S. Oh, and before I forget <a href="http://nightshade.nl/~blasty/ardsi/">here</a>&#8217;s some bonus picture material for you all.</p>
<p>P.P.S If you are interested in the quick disassembly I did: <a href='http://nightshade.nl/~blasty/ardsi/disas.txt'>click here</a>. Sorry for not having used the correct base-address in that listing, but the code is position independent, you should get the idea. I hope datel doesn&#8217;t mind me &#8216;borrowing&#8217; something from them.</p>
]]></content:encoded>
			<wfw:commentRss>http://hackmii.com/2010/02/lawsuit-coming-in-3-2-1/feed/</wfw:commentRss>
		<slash:comments>37</slash:comments>
		</item>
		<item>
		<title>The STM Release Exploit</title>
		<link>http://hackmii.com/2010/01/the-stm-release-exploit/</link>
		<comments>http://hackmii.com/2010/01/the-stm-release-exploit/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 23:32:33 +0000</pubDate>
		<dc:creator>marcan</dc:creator>
				<category><![CDATA[Wii]]></category>

		<guid isPermaLink="false">http://hackmii.com/?p=856</guid>
		<description><![CDATA[Wow, time does fly. More than a year ago, on October 23rd, 2008, Nintendo finally released an update that fixed the strncmp (fakesigning) exploit in all forks of IOS. This disabled any direct methods to install unofficial content on all updated Wii consoles. At the time, version beta9 of The Homebrew Channel had been in [...]]]></description>
			<content:encoded><![CDATA[<p>Wow, time does fly. More than a year ago, on October 23rd, 2008, Nintendo finally <a href="http://wiibrew.org/wiki/Wii_System_Updates#IOS51_.26_Updated_all_IOSes_except_IOS30.2C_IOS31_and_IOS37_.28these_were_already_partially_updated.2C_see_below.29.2C_added_some_IOSes_that_were_only_previously_available_from_Wii_Discs.2C_updated_Wii_Shop_Channel.">released an update</a> that fixed the strncmp (fakesigning) exploit in all forks of IOS. This disabled any direct methods to install unofficial content on all updated Wii consoles. At the time, version beta9 of The Homebrew Channel had been in the making for a while, so we decided to take the opportunity to use one of our stockpiled IOS exploits to work around the update and release beta9. These exploits differ from fakesigning in that they directly exploit the IOS runtime, injecting code that lets us take control and disable signatures altogether. Therefore, this was our first released IOS code execution exploit. HBC beta9 was <a href="http://hackmii.com/2008/10/the-homebrew-channel-beta9/">released</a> and worked great on all Wiis, as always.</p>
<p>In order to hinder Nintendo&#8217;s attempts at fixing it, and to avoid misuse by warez kiddies, sven and I had a lot of fun obfuscating the exploit over a couple afternoons. We decided not to release information about it, hoping it would last long enough to be useful for future installers and BootMii. Later we kind of forgot about this, but on a few occassions people have asked us to document it, and we proposed a challenge: we would document the exploit as soon as someone &#8220;broke&#8221; our obfuscation and figured out how the exploit works. The intent was to promote reverse engineering and also see just how long it would take people to crack it. Apparently, either people weren&#8217;t very interested or we did a pretty good obfuscation job, because it took pretty long <img src='http://hackmii.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Well, I&#8217;m happy to say that today I received an e-mail from an anonymous hacker who successfully reverse engineered our layers of obfuscation. He (or she!) discovered the inner workings of the STM Release Exploit, as I will be calling it, and did so after three weekends of reverse engineering. Hats off to you, and thank you for taking the challenge!<br />
<span id="more-856"></span><br />
This bug was discovered by accident, and in fact it is a real honest-to-goodness software bug that is not only exploitable, but a nuisance during regular use. To understand it, you need to understand how STM works.</p>
<p>STM is the IOS module in charge of random hardware functions such as handling the fan, &#8220;idle&#8221; (WC24) mode, the front slot LED (including the blink patterns), and the buttons. I have no clue what STM means, but I&#8217;ve seen it called &#8220;State-TM&#8221; somewhere on the Wii. One of the main functions of STM is to provide a way for PowerPC software to get notifications when either the Reset or the Power buttons are pressed. It&#8217;s worth noting that I have no clue why they did this &#8211;the PowerPC already knows about Reset via the legacy GameCube interface, and can be given direct access to Power including IRQ via the shared GPIO system, and IOS doesn&#8217;t use these buttons at all&#8211; but they did. It works like this: STM creates two devices, an &#8220;immediate&#8221; device, and an &#8220;event&#8221; device. The immediate device is used to issue commands to STM that take effect immediately, while the event device is the callback mechanism. The PowerPC code issues an <code>IOS_IoctlAsync()</code> call on the &#8220;event&#8221; device, and this call blocks (asynchronously) until there is an event (such as a button press). When this happens, the call returns with the event code, and the PowerPC code reissues it to listen for further events.</p>
<p>One problem with this approach is that the PowerPC needs a way to shut down the event callback. The IOS IPC mechanism doesn&#8217;t provide a way for the PowerPC to cancel an ongoing request; it must wait until its completion. When PowerPC code needs to hand off execution, it needs to clean up all references and file descriptors to IOS, so it needs a way to get rid of the event call. STM implements this by having a call on the immediate interface that forces the event call to return with a zero event code. So far so good. If you&#8217;re interested, check out stm.c on libogc (particularly the functions with <code>EventHook</code> in the name).</p>
<p>In order to better understand the mechanism, it&#8217;s worth looking at the individual messages as they are exchanged with IOS. Here&#8217;s what it might look like:</p>
<style type="text/css">
table.iostable { border: 2px solid #444; border-collapse: collapse; width: 100%; }
table.iostable th { border: 2px solid #444; padding: 0.2em; background-color: #ddd; }
table.iostable td { border: 1px solid #ccc; padding: 0.2em; }
div.ppc { float: left; }
div.ios { float: right; }
td.ppc { text-align: left; }
td.ios { text-align: right; }
td.note { text-align: center; background-color: #ddd; }
</style>
<table class="iostable">
<tr>
<th>
<div class="ppc">PowerPC</div>
<div class="ios">IOS</div>
</th>
</tr>
<tr>
<td class="note"><i>Initializing STM</i></tr>
<tr>
<td class="ppc">open(path=&#8221;/dev/stm/immediate&#8221;)</td>
</tr>
<tr>
<td class="ios">open() fd = 1</td>
</tr>
<tr>
<td class="ppc">open(path=&#8221;/dev/stm/eventhook&#8221;)</td>
</tr>
<tr>
<td class="ios">open() fd = 2</td>
</tr>
<tr>
<td class="ppc">ioctl(fd=2, num=EVENTHOOK, evbuf=0x12345600)</td>
</tr>
<tr>
<td class="note"><i>Time passes, user presses button</i></tr>
<tr>
<td class="ios"><i>Write event code to 0x12345600</i></td>
</tr>
<tr>
<td class="ios">ioctl(fd=2) result = 0</td>
</tr>
<tr>
<td class="ppc"><i>Read event code from 0x12345600</i></td>
</tr>
<tr>
<td class="ppc">ioctl(fd=2, num=EVENTHOOK, evbuf=0x12345600)</td>
</tr>
<tr>
<td class="note"><i>Time passes, software decides to shut down STM</i></tr>
<tr>
<td class="ppc">ioctl(fd=1, num=RELEASE)</td>
</tr>
<tr>
<td class="ios"><i>Write 0 event code to 0x12345600</i></td>
</tr>
<tr>
<td class="ios">ioctl(fd=2) result = 0</td>
</tr>
<tr>
<td class="ios">ioctl(fd=1) result = 0</td>
</tr>
<tr>
<td class="ppc">close(2)</td>
</tr>
<tr>
<td class="ios">close(2) result = 0</td>
</tr>
<tr>
<td class="ppc">close(1)</td>
</tr>
<tr>
<td class="ios">close(1) result = 0</td>
</tr>
</table>
<p></p>
<p>Now, when I was reverse engineering STM, I noticed that things didn&#8217;t work well when using the Twilight Hack. This is because Zelda&#8217;s STM eventhook is still active, and STM won&#8217;t let you register a new one. So I added an STM eventhook release to the Twilight Hack code. One slight issue is that we can&#8217;t know if there was an old eventhook or not, depending on what the state of the machine was (since the Twilight Hack can be relaunched from software, as an SD loader of sorts, and this was popular in the early days), so we just make it attempt to release the eventhook always. This is fine, as the release function will return an error if there is no eventhook active.</p>
<p>Then IOS started crashing sometimes.</p>
<p>Looking closely at the release function in STM, here&#8217;s what I found:</p>
<pre>
release_eventhook
                 MOV     R12, SP
                 STMFD   SP!, {R4-R6,R11,R12,LR,PC}
                 LDR     R4, =hook_msg
                 MOV     R6, R0
                 SUB     R11, R12, #4
                 LDR     R0, =aRelease
                 BL      printf_disabled
                 LDR     R3, [R4]
                 MOV     R5, #0
                 CMP     R3, R5
                 MOVL    R1, -6
                 MOV     R0, R6
                 BEQ     loc_20300C04

loc_20300BD8
                 STR     R5, [R4]
                 MOV     R0, R3
                 LDR     R3, [R3,#0x18]
                 MOV     R1, R5
                 STR     R5, [R3]
                 BL      AckMessage
                 MOV     R0, R6
                 MOV     R1, R5
                 BL      AckMessage
                 LDMFD   SP, {R4-R6,R11,SP,LR}
                 BX      LR

loc_20300C04
                 BL      AckMessage
                 LDR     R3, [R4]
                 B       loc_20300BD8
</pre>
<p>This translates to the following C code:</p>
<pre>
struct ios_message {
    // this isn't exactly right on the IOS side, but it doesn't matter here
    u32 command;      // 0x00 = 6 for ioctl
    s32 result;       // 0x04
    s32 fd;           // 0x08
    // arguments for ioctl
    u32 ioctl_number; // 0x0c
    void *buffer_in;  // 0x10
    u32 in_size;      // 0x14
    void *buffer_out; // 0x18
    u32 out_size;     // 0x1c
};

struct ios_message *hook_msg;

void release_eventhook(ios_message *imm_msg)
{
    struct ios_message *the_hook_msg = hook_msg;

    printf_disabled("Release\n");
    if (!the_hook_msg) {
        AckMessage(imm_msg, -6);
    }
    hook_msg = NULL;
    *(u32*)the_hook_msg->buffer_out = 0;
    AckMessage(the_hook_msg, 0);
    AckMessage(imm_msg, 0);
}
</pre>
<p>Notice anything wrong? They forgot a <code>return;</code> statement right at the end of the <code>if(!the_hook_msg)</code> block! This means that if there is no callback registered, it will try to ack the immediate message twice (which does nothing), it will try to ack a NULL message (which the kernel catches and does nothing), but most importantly, <b>it will dereference a NULL structure, get a pointer from it, and write 0 to the address pointed to by that pointer</b>. In other words, that line of code becomes <code>**(u32**)0x18 = 0;</code>, as 0x18 is the offset of <code>buffer_out</code> inside the structure. And 0x18 is an address in low MEM1 that we completely control from the PowerPC. Whoops.</p>
<p>In the Twilight Hack, this location usually contained some odd value, which caused IOS to crash with an unaligned access exception. We added a workaround in a later release of the Twilight Hack so IOS will no longer crash. It looks like this:</p>
<pre>
    // STM bug workaround
    // On attempt to release callback when it's already released
    // or when it has fired and auto-released, STM dereferences a
    // member of a NULL IPC structure and then tries to write 0
    // to outbuf. End result, STM tries to:
    // **((u32**)0x18) = 0;
    // so we set 0x18 here to a valid address (0x14) to prevent
    // a crash.
    *((u32*)0x80000018) = 0x00000014;
    sync_after_write((void*)0x80000014, 8);
    printf("Releasing STM callback...");
    /* ... */
</pre>
<p>The comment was removed from the Twilight Hack public source code release ( <img src='http://hackmii.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ), but the code is <a href="http://git.infradead.org/users/segher/savezelda.git/blob/HEAD:/loader/ios.c#l236">still there</a>.</p>
<p>I chose IOS34 for the exploit because it is not used for homebrew or any games that I own (so I can patch it for debugging with impunity), and it shares the same STM binary with IOS35, which is mostly what I&#8217;ve been reverse engineering. The exploit is quite simple: we simply find the address of the stack location that contains the return address for the function (LR), and write it to 0x18. Then we release the STM callback twice. The second time around, STM zeroes out the return address and the function returns to execute code at address 0. We place our own code there, and clean up afterwards by jumping to the real return location, so STM keeps on running happily.</p>
<p>But wait, we need to somehow break into the kernel to disable the signature check. How can we do that? Well, it turns out that Nintendo left behind some useful IOS syscalls. They look like this:</p>
<pre>
wtf1
                 MOVS    R3, #3
                 STR     R3, [R0]
                 MOVS    R3, #0
                 STRH    R3, [R1]
                 BX      LR

wtf2
                 MOVS    R3, #1
                 STR     R3, [R0]
                 MOVS    R3, #0
                 STRH    R3, [R1]
                 BX      LR
</pre>
<p>Which translates to:</p>
<pre>
void wtf1(u32 *a, u16 *b)
{
    *a = 3;
    *b = 0;
}

void wtf2(u32 *a, u16 *b)
{
    *a = 1;
    *b = 0;
}
</pre>
<p>These functions appear to be used as configuration for certain global settings, such as whether IOS is monolithic or modular, so they just return constant values by dereferencing their arguments. In any case, there are no permission checks and these calls happily write to any address that you want, with full kernel permissions. We just pass along an address inside the signature check function that we want patched out, and we win.</p>
<p>Now, this exploit isn&#8217;t just caused by the small bug in STM; it&#8217;s also a consequence of poor security in IOS in general:</p>
<ul>
<li>IOS should unmap the zero page and cause NULL dereferences to abort.</li>
<li>IOS should <b>NEVER</b> allow or use execute permission for memory controlled by the PowerPC (<b>!!!</b>).</li>
<li>IOS system calls should be code-reviewed and checked for validation of arguments, as they are critical to security.</li>
<li>Nintendo needs to backport security fixes to all IOSes. They had found the syscall bug and fixed it in newer IOS forks, but this is useless without backporting it back to all older IOSes. In fact, changes like that draw attention to the bugs.</li>
<li>Which of course brings us to the fact that having dozens of forks of security-critical software is a maintenance nightmare and a really <b>really</b> bad idea.</li>
</ul>
<p>Unfortunately, given later exploits and Nintendo&#8217;s changes to IOS, it seems they can&#8217;t be bothered to do any of the above. They fixed the STM bug and backported the syscall fix from other IOSes, but there are others with similar bugs.</p>
<p>Hope you had fun reading this latest episode of How To Pwn a Nintendo <img src='http://hackmii.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://hackmii.com/2010/01/the-stm-release-exploit/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>The weird and wonderful CIC</title>
		<link>http://hackmii.com/2010/01/the-weird-and-wonderful-cic/</link>
		<comments>http://hackmii.com/2010/01/the-weird-and-wonderful-cic/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 04:43:22 +0000</pubDate>
		<dc:creator>Segher</dc:creator>
				<category><![CDATA[Other consoles]]></category>

		<guid isPermaLink="false">http://hackmii.com/?p=827</guid>
		<description><![CDATA[I have been spending some time on reverse engineering the Nintendo CIC ROMs.  The CIC is the &#8220;lockout&#8221; chip in NES/SNES/N64 cartridges, used to get an iron grip on the market prevent people from copying games.  It was manufactured by Sharp and is likely one of their old &#8220;one-chip microcomputers&#8221;, used in calculators [...]]]></description>
			<content:encoded><![CDATA[<p>I have been spending some time on reverse engineering the Nintendo CIC ROMs.  The CIC is the &#8220;lockout&#8221; chip in NES/SNES/N64 cartridges, used to <del>get an iron grip on the market</del> prevent people from copying games.  It was manufactured by Sharp and is likely one of their old &#8220;one-chip microcomputers&#8221;, used in calculators and TV remotes and the like.  I couldn&#8217;t find a document describing the instruction set it uses (or its architecture!), so I made it all up (combining information from lots of sources: old datasheets, old patents, and the low-res die photographs).</p>
<p>The N64 chips are different, and I haven&#8217;t seen a ROM dump of those yet, so all of the following is NES/SNES only.</p>
<p>There is one chip inside the console, and one in every cartridge; the code inside the chip decides what to do based on a pin strap (the console one will be the &#8220;lock&#8221;, and the cartridge one will be the &#8220;key&#8221;).  The two chips run off the same clock, and they run the same code, so they run in lockstep (sometimes they execute different codepaths, but the code is careful to take the same number of cycles on both paths in these cases).  The chips communicate over two wires, one from key to lock, one from lock to key.  Both chips calculate what bits they will send, and what the other guy should send; if what they receive is not the same as what they should have received, they panic, and the lock chip resets the console.<br />
<span id="more-827"></span><br />
Here is the pinout of the CIC:</p>
<pre>              +------------------+
 DATA_OUT &lt;-- | 1 P0.0    +5V 16 |
  DATA_IN --&gt; | 2 P0.1        15 |  ?
     SEED --&gt; | 3 P0.2        14 |  ?
LOCK/-KEY --&gt; | 4 P0.3        13 |  ?
              | 5 Xout   P1.3 12 | &lt;-- RESET_SPEED_B
              | 6 Xin    P1.2 11 | &lt;-- RESET_SPEED_A
              | 7 RESET  P1.1 10 | --&gt; SLAVE_CIC_RESET
              | 8 GND    P1.0  9 | --&gt; -HOST_RESET
              +------------------+</pre>
<p>The LOCK/-KEY pin is the strap pin I talked about above.  The SEED pin has a capacitor connected to it; the discharge time of that is supposedly somewhat random, the lock chip times it and uses that as a random generator, to decide which of 16 possible streams to generate.  It tells the key chip which one it chose.</p>
<p>The lock chip can reset the key chip (pin 10 on the lock is wired to pin 7 on the key), and it can reset the console.  The RESET_SPEED pins are used on the 3195 to decide at what speed to &#8220;blink&#8221; the reset line (it&#8217;s connected to a LED as well): about 0.4s, 0.6s, 0.8s, 1.0s each of on/off.</p>
<p>There are dumps of the ROMs <a href="http://www.nesmuseum.com/10nes/nescicrom.txt">here</a>, <a href="http://www.nesmuseum.com/10nes/D411_ROM.txt">here</a>, and <a href="http://www.neviksti.com/CIC/3195A_rom_bits_final.txt">here</a>.  All credits for doing these go to neviksti; thanks!</p>
<p>All the bits in those dumps are inverted (0 vs. 1); if you want to play along with the disassembler I&#8217;ll give a link to in a second, you&#8217;ll need to fix that; also, that third ROM is 768 bytes, which I don&#8217;t handle in my little conversion script, so you&#8217;ll need to remove the extra columns (they are empty anyway).  Or enhance the script if you want to.</p>
<p>Okay then, here is <a href="http://git.infradead.org/users/segher/dis-cic.git">that disassembler</a>.  Usage should be self-explanatory.</p>
<p>This ancient CPU looks mighty strange to modern eyes.  Let me try to explain the architecture:</p>
<p>First, it is a 4-bit CPU.  Yessir.  It has an accumulator register, A, and a secondary register, X, both 4 bits.  All RAM accesses are done via a single pointer register B, which is 6 bits; the CIC chip only has 32 nybbles of RAM though.  There is also a carry flag, C.</p>
<p>Then, there is the process counter, PC.  It is 10 bits, but there are only 512 bytes of ROM (except on the 3195, it has 768).  The ROM is divided into banks of 128 bytes.  When the CPU increments PC, it never touches the bank number.</p>
<p>Well, &#8220;increments&#8221;.  To save chip area, they didn&#8217;t use a binary counter, but a polynomial counter; &#8220;incrementing&#8221; works by shifting the PC by one bit to the right, and setting the the top bit to 1 if and only if the bottom two bits were the same.</p>
<p>There are no conditional branch instructions; instead, various instructions can skip the next instruction if some condition is true (the instruction still takes time, it just doesn&#8217;t do anything).  Oh, all instructions take one cycle; except for the two byte instructions, which take two cycles.</p>
<p>Finally, there is a four entry stack for the PC; it&#8217;s not in RAM, it is separate.</p>
<p>Now the instruction set:</p>
<pre>"skip" means "do not execute next instruction"
"M" means "the RAM nybble addressed by B"
"BL" means "the low four bits of B"
"BM" means "the high two bits of B"
"PN" means "I/O port number BL"
"x.y" means "bit y of x"

00+N  adi N     "add immediate", A := A + N, skip if overflow   (00 is nop)
10+N  skai N    "skip acc immediate", skip if A = N
20+N  lbli N    "load B low immediate", BL := N
30+N  ldi N     "load immediate", A := N

40    l         "load", A := M
41    x         "exchange", swap A with M
42    xi        "exchange and increment", swap A with M, increment BL, skip if overflow
43    xd        "exchange and decrement", swap A with M, decrement BL, skip if underflow
44    nega      "negate acc", A := -A (two's complement)
46    out       "output", PN := A
47    out0      "output zero", PN := 0
48    sc        "set carry", C := 1
49    rc        "reset carry", C := 0
4a    s         "store", M := A
4c    rit       "return", pop PC from stack
4d    ritsk     "return and skip", pop PC from stack, skip
52    li        "load and increment", A := M, increment BL, skip if overflow
54    coma      "complement acc", A := ~A (ones' complement)
55    in        "input", A := PN
57    xal       "exchange acc and low", swap A with BL
5c    lxa       "load X with acc", X := A
5d    xax       "exchange X and acc", swap X with A
5e     ?        SPECIAL MYSTERY INSTRUCTION

60+N  skm N     "skip memory", skip if M.N = 1
64+N  ska N     "skip acc", skip if A.N = 1
68+N  rm N      "reset memory", M.N := 0
6c+N  sm N      "set emmory", M.N := 1

70    ad        "add", A := A + M
72    adc       "add with carry", A := A + M + C
73    adcsk     "add with carry and skip", A := A + M + C, skip if overflow

74+N  lbmi N    "load B high immediate", BM := N

78+N NN  tl NNN    "transfer long", PC := NNN
7c+N NN  tml NNN   "transfer module long", push PC+2, PC := NNN
80+NN    t NN      "transfer", low bits of PC := NN</pre>
<p>It would seem that on the 3195, the sc and rc instructions are swapped, as are the coma and nega instructions.</p>
<p>If you look at the code in the ROMs, you&#8217;ll notice something strange with the ldi instructions: sometimes it runs two in a row.  Descriptions for similar CPUs say that if you have two or more ldi instructions in a row, all but the first are skipped.  The code still doesn&#8217;t make sense then; I suspect that this CPU does this skip only if some condition that I do not know yet is true.</p>
<p>This architecture is quite different from what we are used to today, and so it requires quite different programs; I&#8217;ll leave it to you to discover all the intricacies yourself though, it&#8217;s more fun that way!</p>
<p>I put a commented disassembly of these ROMs <a href="http://segher.ircgeeks.net/cic-roms/">here</a>.  Some of that is a work in progress.</p>
<p>I hope you all find this as fascinating as I did!</p>
<p>[edit: fixed op 52 "li" description]</p>
]]></content:encoded>
			<wfw:commentRss>http://hackmii.com/2010/01/the-weird-and-wonderful-cic/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>lostscrews</title>
		<link>http://hackmii.com/2010/01/lostscrews/</link>
		<comments>http://hackmii.com/2010/01/lostscrews/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 12:58:54 +0000</pubDate>
		<dc:creator>bushing</dc:creator>
				<category><![CDATA[Wii]]></category>

		<guid isPermaLink="false">http://hackmii.com/?p=821</guid>
		<description><![CDATA[One thing CCC shows me every year is how amazing it can be when you get a bunch of random hackers (who have never met each other) into a room, and you start bouncing ideas off each other.
I&#8217;ve tried to create a similar environment here (on this blog), on IRC, and to a lesser extent, [...]]]></description>
			<content:encoded><![CDATA[<p>One thing CCC shows me every year is how amazing it can be when you get a bunch of random hackers (who have never met each other) into a room, and you start bouncing ideas off each other.</p>
<p>I&#8217;ve tried to create a similar environment here (on this blog), <a href="http://hackmii.com/2008/07/hackmii-irc/">on IRC</a>, and to a lesser extent, on the <a href="http://forum.wiibrew.org/index.php?5">Wiibrew forum</a>.  I realized that  there is a need for a place where we can have high-quality conversations over a long period of time, and where we can moderate out all the noise.</p>
<p>So, my latest experiment is <a href="http://lostscrews.com/">http://lostscrews.com/</a> &#8212; come by, <a href="http://lostscrews.com/viewtopic.php?f=3&#038;t=7">read the explanation</a>, and participate!</p>
]]></content:encoded>
			<wfw:commentRss>http://hackmii.com/2010/01/lostscrews/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>26c3 wrap up</title>
		<link>http://hackmii.com/2010/01/26c3-wrap-up/</link>
		<comments>http://hackmii.com/2010/01/26c3-wrap-up/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 20:02:54 +0000</pubDate>
		<dc:creator>bushing</dc:creator>
				<category><![CDATA[Wii]]></category>

		<guid isPermaLink="false">http://hackmii.com/?p=808</guid>
		<description><![CDATA[The annual Chaos Communication Congress (CCC) is always a bittersweet experience for me &#8212; I always go there with projects that I hope to work on (this year: SPMP, a TV Plug&#8217;n'Play version of Bejeweled with an SPG chip inside, a couple of DSis + TWLFPGA boards, SD cards and a logic analyzer to work [...]]]></description>
			<content:encoded><![CDATA[<p>The annual <a href="http://events.ccc.de/congress/2009/wiki/Main_Page" target="_blank">Chaos Communication Congress</a> (CCC) is always a bittersweet experience for me &#8212; I always go there with projects that I hope to work on (this year: <a href="http://hackaday.com/2009/12/23/reverse-engineering-off-brand-media-players/" target="_blank">SPMP</a>, a <a href="http://jakks.com/plug-it-in-and-play-tv-games-bejeweled" target="_blank">TV Plug&#8217;n'Play version of Bejeweled </a>with an <a href="http://web.archive.org/web/20080803101759/http://www.sunplusmm.com/products/game/g220.asp" target="_blank">SPG chip</a> inside, a couple of DSis + TWLFPGA boards, SD cards and a logic analyzer to work on BootMii/SD card fail), and I almost never get a chance to work on any of them.  This year was no different, so I really should know better at this point.</p>
<p>We once again managed to snag a couple of tables in the Hackcenter for console hacking, and we did actually have a few consoles &#8212; mainly some Wiis and DSis in pieces.  Hardware was exchanged, and we looked at soldering the 50+ wires needed to connect up a <a href="http://www.flickr.com/photos/micahdowty/4210798468/" target="_blank">twlfpga</a> board to a DSi and just sort of gave up due to lack of lighting and the chaotic environment.   No, CCC is more of an occasion to meet old friends and make new ones.  I was also selling <a href="http://www.proxmark.org/" target="_blank">Proxmark3</a>s that I had made for the occasion, and had the chance to meet some of the people behind that project.</p>
<p>There were plenty of interesting talks, and the nice thing about CCC (compared to the American conferences I&#8217;ve been to) is that you can watch them from home, either live via streaming video, or download the video in a variety of formats after the conference.  Here are some of the ones I considered to be personal highlights:</p>
<p><span id="more-808"></span></p>
<p>All presentation links contain a further description and slides or a video torrent.</p>
<ul>
<li><a href="http://events.ccc.de/congress/2009/Fahrplan/events/3654.en.html" target="_blank">GSM: SRSLY?</a> was a talk on how it&#8217;s now possible to launch passive and active attacks on GSM calls with &lt;$10K of equipment (depending on the setup).  Fascinating and scary stuff &#8212; they were supposed to give the world&#8217;s first public live demo of this on the fourth day of the conference, but <a href="http://www.nytimes.com/2009/12/29/technology/29hack.html" target="_blank">were threatened</a> and <a href="http://events.ccc.de/congress/2009/wiki/The_demonstration_is_canceled" target="_blank">backed out of it</a> at the last minute. <img src='http://hackmii.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </li>
<li><a href="http://events.ccc.de/congress/2009/Fahrplan/track/Hacking/3490.en.html" target="_blank">Building a Debugger</a> was one of the more personally interesting and useful ones; Travis Goodspeed talked about his neighborly open-source &#8220;universal&#8221; hardware debugger interface / serial interface, <a href="http://goodfet.sourceforge.net/" target="_blank">GoodFET</a>.  It currently supports a couple of JTAG-based protocols (mainly TI products, but there&#8217;s no reason you couldn&#8217;t add support for other processor families) and SPI-based protocols (SPI flash, AVR ISP).  It also supports voltage-glitching, and Travis explained how you can use that to read out the code from locked AVR chips.  It&#8217;s free as in speech, and about as close to free as in beer as you can get &#8212; if you can solder a couple of surface-mount parts, Travis will be neighborly enough to send you a free PCB if you email him and ask nicely (see the project webpage for his email address), and you can sample one of the <a href="http://focus.ti.com/docs/prod/folders/print/msp430f2618.html" target="_blank">chips</a> for free from TI and then order the other one from <a href="http://parts.digikey.com/1/parts/1501974-ic-usb-serial-uart-28-ssop-ft232rl-r.html" target="_blank">DigiKey</a>, etc.  Neat stuff &#8212; I used the SPI flash client to dump the SPI flash chip on the DSi&#8217;s Wifi dongle.   He also introduced a new &#8220;<a href="http://www.youtube.com/watch?v=TbiMZMd7v4g" target="_blank">FYN-FYTN protocol</a>&#8220;, which was unfortunately cut from the final, archived video &#8212; fortunately, I preserved it for posterity.</li>
<li><a href="http://events.ccc.de/congress/2009/Fahrplan/events/3631.en.html" target="_blank">Finding the key in the haystack</a> was a great introduction to Differential Power Analysis, a side-channel attack on AES which shows a lot of promise for use on things like the DSi (if you can wade through the math, at least <img src='http://hackmii.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> )</li>
<li><a href="http://events.ccc.de/congress/2009/Fahrplan/events/3670.en.html" target="_blank">Blackbox JTAG Reverse Engineering</a> (by our very own tmbinc!) gave a great insight into how JTAG actually works and how it can be used on random devices.  We&#8217;re still looking for it on the Hollywood and the DSi&#8217;s CPU&#8230;</li>
</ul>
<p>There are too many presentations for me to list, so I suggest you go look at the <a href="http://events.ccc.de/congress/2009/Fahrplan/events.en.html" target="_blank">full schedule</a> yourself.</p>
<p>Afterwards, we went to the traditional c-base afterparty, where we gave marcan a couple of drinks and <a href="http://www.youtube.com/watch?v=agKndwOjwWg" target="_blank">watched him code up a rotating cube</a> on the spot on some random computer.</p>
<p>Sadly, I can&#8217;t say that we have any new breakthroughs from the event &#8212; work still is underway on the DSi front.  If nothing else, it was a lot of fun to see everyone &#8212; I believe we had the majority of Team Twiizers in attendance.</p>
]]></content:encoded>
			<wfw:commentRss>http://hackmii.com/2010/01/26c3-wrap-up/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>26c3 roll-call</title>
		<link>http://hackmii.com/2009/12/26c3-roll-call/</link>
		<comments>http://hackmii.com/2009/12/26c3-roll-call/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 13:41:23 +0000</pubDate>
		<dc:creator>bushing</dc:creator>
				<category><![CDATA[Wii]]></category>

		<guid isPermaLink="false">http://hackmii.com/?p=805</guid>
		<description><![CDATA[Many of us are planning on attending 26C3 in Berlin in a few weeks &#8212; we hope to get a table again in the Hackcenter this year, but no guarantees.
We will not be presenting anything this year, sorry!  There&#8217;s not much new to report with the Wii, and we don&#8217;t have anything complete enough to show [...]]]></description>
			<content:encoded><![CDATA[<p>Many of us are planning on attending <a href="http://events.ccc.de/congress/2009/wiki/index.php/Welcome">26C3</a> in Berlin in a few weeks &#8212; we hope to get a table again in the Hackcenter this year, but no guarantees.</p>
<p>We will not be presenting anything this year, sorry!  There&#8217;s not much new to report with the Wii, and we don&#8217;t have anything complete enough to show for the DSi.   Also, honestly, I&#8217;m looking forward to actually getting some sleep this year and seeing some presentations &#8212; I barely emerged from the basement for the last two years.</p>
<p>If we do get some space to set up, we&#8217;ll probably have at least one Wii, hopefully a DSi-hacking setup, and then you&#8217;ll get to see the rest of the projects that have occupied our time over the last year &#8212; lasers, all sorts of SunPlus devices, etc.  Should be good times.</p>
<p>Post a comment if you&#8217;re planning on attending.</p>
]]></content:encoded>
			<wfw:commentRss>http://hackmii.com/2009/12/26c3-roll-call/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>bricks wanted?</title>
		<link>http://hackmii.com/2009/11/bricks-wanted/</link>
		<comments>http://hackmii.com/2009/11/bricks-wanted/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 01:04:33 +0000</pubDate>
		<dc:creator>bushing</dc:creator>
				<category><![CDATA[Wii]]></category>

		<guid isPermaLink="false">http://hackmii.com/?p=798</guid>
		<description><![CDATA[To continue with the theme of my last post on updates and bricking:
I don&#8217;t have an actual explanation for any of the 4.2 bricking, and I suspect Nintendo doesn&#8217;t really, either &#8212; I don&#8217;t think they keep a copy of the NAND keys for each device, and I doubt they have any readily-available way of retrieving [...]]]></description>
			<content:encoded><![CDATA[<p>To continue with the theme of my last post on <a href="http://hackmii.com/2009/11/updates-and-bricking/">updates and bricking</a>:</p>
<p>I don&#8217;t have an actual explanation for any of the 4.2 bricking, and I suspect Nintendo doesn&#8217;t really, either &#8212; I don&#8217;t think they keep a copy of the NAND keys for each device, and I doubt they have any readily-available way of retrieving them.   As a matter of personal curiosity, I would be interested in doing a post-mortem on such a Wii myself.</p>
<p>If you have a bricked Wii that fulfills the following requirements:</p>
<p><span id="more-798"></span></p>
<ul>
<li>Worked just fine before the 4.2 update</li>
<li>Is now unusable after the 4.2 update (black screen, error message from system menu, etc)</li>
<li>Has an old, vulnerable boot1 (such that BootMii/boot2 could be installed), or</li>
<li>Has a known set of keys (either from a BootMii NAND backup or running xyzzy at some point in the past)</li>
<li>Did not have anything too odd done to the system menu or boot IOS (but I&#8217;m a bit flexible on this point)</li>
</ul>
<p>&#8230; please let me know.   I would be interested in getting a dump of the NAND from the system so I can figure out exactly what caused it to die &#8212; if you already had such a dump (and the keys), that would be great, but if I not I could dump it myself (again, assuming you have the keys or it&#8217;s old enough that I could install BootMii/boot2 with a flash programmer.)</p>
]]></content:encoded>
			<wfw:commentRss>http://hackmii.com/2009/11/bricks-wanted/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>updates and bricking</title>
		<link>http://hackmii.com/2009/11/updates-and-bricking/</link>
		<comments>http://hackmii.com/2009/11/updates-and-bricking/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 09:43:42 +0000</pubDate>
		<dc:creator>bushing</dc:creator>
				<category><![CDATA[Wii]]></category>

		<guid isPermaLink="false">http://hackmii.com/?p=791</guid>
		<description><![CDATA[I keep getting questions along the lines of &#8220;should I update to 4.2? Are you guys going to make a &#8217;safe boot2 updater&#8217;?&#8221;   (The answer is &#8216;no&#8217;, but keep reading.)
Somewhere in the noise about this most recent update the point I was trying to make got lost.  Let me recap the facts:

The most recent [...]]]></description>
			<content:encoded><![CDATA[<p>I keep getting questions along the lines of &#8220;should I update to 4.2? Are you guys going to make a &#8217;safe boot2 updater&#8217;?&#8221;   (The answer is &#8216;no&#8217;, but keep reading.)</p>
<p><span id="more-791"></span>Somewhere in the noise about this most recent update the point I was trying to make got lost.  Let me recap the facts:</p>
<ul>
<li>The <a href="http://wii.marcansoft.com/wiimpersonator/reports/USA/20090929-033734.log" target="_blank">most recent system update</a> was the <a href="http://wii.marcansoft.com/wiimpersonator/reports/USA/20090929-033734.log" target="_blank">largest update</a> ever done &#8212; 32 titles were added or updated, and each system downloaded approximately 50MB of data.</li>
<li>A certain firmware graybeard tells me that, on average, 1 in 1000 updates (of any software, on any system) will fail.</li>
<li>The Wii performs updates atomically on a per-title basis.  What this means is that the system menu downloads each title from the Nintendo Update Server and feeds the data directly to IOS/ES.  As each chunk of data for a given title is downloaded, IOS writes it into /import, and then once the entire title has finished downloading, it renames the files in /import to overwrite the older version of the title (in one step, &#8220;atomically&#8221;).  That rename step probably only takes a second or two for each title.</li>
<li>Contrary to <a href="http://techforums.nintendo.com/nins/board/message?board.id=wii_tech&amp;message.id=29898#M29898" target="_blank">Nintendo&#8217;s claims</a>, an update will not start over from the beginning if interrupted.  Rather, the updates will be downloaded and installed in this order: boot2, IOS of the new system menu, a new system menu, and then everything else.  If the update is interrupted after (for example) the IOS is installed but before the System Menu has finished downloading, the partially downloaded System Menu will be deleted upon the next reboot.  You will still be told &#8220;an update is available&#8221;, and it will restart the update &#8212; but since it won&#8217;t reinstall the same version of something that&#8217;s already there, it will skip over boot2 and the IOS and restart downloading the system menu.</li>
<li>Any failed update on three of those pieces (boot2, system menu, IOS) will cause the system to irreparably brick.</li>
<li>Any failed update on another part of the system (for example, another IOS) could either cause strange behavior (certain games won&#8217;t launch) or could cause the system to brick (if it damaged the filesystem in NAND).</li>
</ul>
<p>As far as updating boot2 goes:</p>
<ul>
<li>The 1-in-1000 number applies to boot2, although there are some protection mechanisms in place to try to mitigate that risk.   There are two separate copies of boot2 stored in flash, and if one is corrupted, it will try to boot the other &#8212; this is the only real &#8220;safety mechanism&#8221; in the entire device.</li>
<li>The boot2 update code is completely separate from any other update code, and has never been used before on any retail Wiis.  That does not mean it&#8217;s necessarily broken or buggy, just that it has been nearly as well-tested as any of the other updater code.</li>
<li>During the development of <a href="http://bootmii.org/" target="_blank">BootMii/the HackMii Installer</a>, I ran into a bug where the ECC data was not always written when writing boot2.  Let me be clear here &#8212; this is not a huge bug.  It only applies to the boot2-area blockmap page, and when it happens, the effect is generally harmless &#8212; if there is a bit error in that page, it will not be detected or corrected, but there are three copies of that data in that page and boot1 will choose the best 2 out of 3.  (The only real indication you will see of this is if you find the message &#8220;Ninty forgot to write spare data for page xxx&#8221; in your installer.log file after installing BootMii/boot2.)  I don&#8217;t really think this will cause a system to get bricked, but it&#8217;s evidence that the code has not been thoroughly tested.</li>
<li>Our boot2 updater code presumably carries the same 1-in-1000 risk of failure, but a failure there will still allow at least one of the two old copies of boot2 to work.  (We do something mildly clever there to avoid overwriting each copy, and to prevent problems with BC/MIOS.)</li>
<li>There is no benefit or pitfall to installing boot2v4, other than the fact that if you don&#8217;t install it, it will keep trying to install it whenever you update, and if you had BootMii/boot2 installed, it will overwrite it.</li>
</ul>
<p>Various employees of Nintendo &#8212; from lowly tech support staff and forum moderators to executives &#8212; have made the claim that &#8220;<a href="http://techforums.nintendo.com/nins/board/message?board.id=wii_tech&amp;message.id=30946#M30946" target="_blank">most of the bricked systems were a result of other modifications to the system</a>.&#8221;  This is a lie, and I&#8217;m disappointed in Nintendo for trying to make this claim.  It&#8217;s not supported by evidence &#8212; how could they possibly get that kind of statistic?   (There hasn&#8217;t been time for them to get bricked units back and do much analysis, and even in the case where they do have a bricked console in their hands, <a href="http://hackmii.com/2009/04/warranty/" target="_blank">there&#8217;s nothing they can do to see whether it was modified or not</a>.)  It&#8217;s not supported by logic, either &#8212; the reason why this update &#8220;kills homebrew&#8221; is because it overwrites EVERYTHING, but the same is true for unmodified Wiis.   It&#8217;s not even supported anecdotally &#8212; there were comments on Nintendo&#8217;s official Tech Forums from people who had bought a new Wii that day and had it brick the first time they did their connection test and system update.</p>
<p>If we were to write a boot2 installer, there&#8217;s no guarantee that it would be any safer than Nintendo&#8217;s.  We sincerely believe it to be safe &#8212; we&#8217;ve tested it as much as we possibly can, we have an unreasonable number of safety checks in there, and I have yet to hear of a single case of bricking in somewhere between 10-20,000 installs &#8212; but then again, I&#8217;m sure Nintendo feels the same way about their code.</p>
<p>The distinction here is a more subtle than &#8220;whose code is buggier&#8221;.  When you run the HackMii installer and install anything we&#8217;ve written, you are taking some risk.  The difference here is that</p>
<ul>
<li>For the (say) 20,000 people that run the HackMii installer, each one of them has done so deliberately and with some goal in mind &#8212; tinkering with their system, playing homebrew games, whatever.  In the case of BootMii/boot2, we even give you a strong defense against bricking your console through updates (oh, the irony).  If you run into problems, you can be mad at us, you can be mad at yourselves, but at the end of the day, you took a calculated risk.</li>
<li>For the 55 million people who own Wiis but did not run the HackMii Installer &#8212; yet are forced to update anyway &#8212; they run the risk of bricking with no tangible benefit to them whatsoever, and no choice in the matter.</li>
</ul>
<p>If we take this 1-in-1000 statistic of failed updates, and say that 1-in-100 of those failed updates will result in a bricked system, and then extrapolate that over the top two groups &#8212; you end up with maybe one or two homebrew-running people with bricked Wiis, and 550 unmodified, bricked Wiis.  If you have one of those, go to Nintendo and ask them to fix it for free.   If you haven&#8217;t updated, there&#8217;s no good reason to &#8212; other than to stop it nagging at you to update.   If you do feel compelled to update, your chances of running into problems are no better and no worse than anyone else&#8217;s,  and they wouldn&#8217;t be much different if we wrote the update code instead of Nintendo.</p>
<p>This is the reason why it&#8217;s a big deal when anyone releases a bootloader update &#8212; it&#8217;s inherently risky, and for most people, it&#8217;s not worth the risk.</p>
]]></content:encoded>
			<wfw:commentRss>http://hackmii.com/2009/11/updates-and-bricking/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>HBC freeze fix</title>
		<link>http://hackmii.com/2009/10/hbc-freeze-fix/</link>
		<comments>http://hackmii.com/2009/10/hbc-freeze-fix/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 20:37:27 +0000</pubDate>
		<dc:creator>dhewg</dc:creator>
				<category><![CDATA[Wii]]></category>

		<guid isPermaLink="false">http://hackmii.com/?p=786</guid>
		<description><![CDATA[HBC v1.0.5  freezes. Like forever. But only for some users. Fixed that, and some other minor hiccups. Launch HBC to update it. Or grab fresh installer. BootMii and DVDX unchanged.
And please:

 Read our updated FAQs first. For the HackMii installer and The Homebrew Channel, see here. For BootMii, see here. Better read those twice.
We [...]]]></description>
			<content:encoded><![CDATA[<p>HBC v1.0.5  freezes. Like forever. But only for some users. Fixed that, and some other minor hiccups. Launch HBC to update it. Or grab fresh installer. BootMii and DVDX unchanged.</p>
<p>And <strong>please</strong>:</p>
<ul>
<li> Read our updated FAQs first. For the HackMii installer and The Homebrew Channel, see <a href="http://hbc.hackmii.com/faq/">here</a>. For BootMii, see <a href="http://bootmii.org/faq/">here</a>. Better read those twice.</li>
<li>We have a bug tracker. If you think you found a bug, be so kind and open an item <a href="http://bugs.hackmii.com/">here</a>.</li>
</ul>
<p><a href="http://bootmii.org/download/">Download</a>.</p>
<p>As always: Please link to this post instead of mirroring the binary, thanks.</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://hackmii.com/2009/10/hbc-freeze-fix/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Silly games</title>
		<link>http://hackmii.com/2009/09/silly_games/</link>
		<comments>http://hackmii.com/2009/09/silly_games/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 15:53:12 +0000</pubDate>
		<dc:creator>dhewg</dc:creator>
				<category><![CDATA[Wii]]></category>

		<guid isPermaLink="false">http://hackmii.com/?p=761</guid>
		<description><![CDATA[As you all know, Nintendo pushed a huge update yesterday. Turns out it&#8217;s a rather lame attempt to block, among other things, our installer. They also remove The Homebrew Channel and DVDX on every system menu startup, but for that they just hardcoded the used title IDs.  So let&#8217;s play this silly game: let&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>As you all know, Nintendo pushed a <a title="Wiimpersonator log" href="http://wii.marcansoft.com/wiimpersonator/reports/USA/20090929-033734.log">huge</a> update yesterday. Turns out it&#8217;s a rather <a href="http://hackmii.com/2009/09/wii-menu-4-2-a-lack-of-imagination/">lame</a> attempt to block, among other things, our installer. They also remove <em>The Homebrew Channel</em> and <em>DVDX</em> on every system menu startup, but for that they just hardcoded the used title IDs.  So let&#8217;s play this silly game: let&#8217;s switch title IDs!</p>
<p><strong>Beware</strong>: Everything installable with this installer works with every system menu version, you do not have to update to v4.2! We even advise you not to update! On the <a href="http://hackmii.com/2009/09/wii-menu-4-2-a-lack-of-imagination/">last article</a> bushing wrote:</p>
<blockquote><p>The [boot 2 update] code [from Ninty] is so buggy that we decided to write our own for the HackMii installer.</p></blockquote>
<p>It&#8217;s really sad, but that wasn&#8217;t exaggerated at all. The first reports about bricks due to this official boot2 update are reported on <a href="http://techforums.nintendo.com/nins/board/message?board.id=wii_tech&amp;thread.id=29914">Nintendo&#8217;s forums</a>. Replies, which Ninty doesn&#8217;t like, are getting <a href="http://static.hackmii.com/nintybrickfail.png">deleted</a>. Anyway, it&#8217;s up to you if you want to risk it.</p>
<p>If you<strong> already updated</strong> to v4.2, this version is the only one that works. If you don&#8217;t have <em>HBC</em> installed, use e.g. <a href="http://hackmii.com/2009/09/indiana-pwns/">Indiana Pwns</a> to launch this installer.</p>
<p>If you <strong>want</strong> to update to v4.2, you should install <em>HBC</em> <strong>before</strong> updating. Because of the new title IDs, the <em>HBC</em> and <em>DVDX</em> version from this installer won&#8217;t get deleted on v4.2. Installing the new <em>HBC</em> before updating ensures that you have a working <em>HBC</em> afterwards.</p>
<p>If you updated to v4.2:</p>
<ul>
<li> <em>BootMii/boot2</em> was wiped only if your boot2 version was v2 or v3. Just reinstall it.</li>
<li><em>BootMii/IOS</em> will still be there.</li>
<li><em>DVDX</em> got deleted, reinstall it.</li>
</ul>
<p>General advice: Don&#8217;t use some random update application, just update through the system menu if you really want to update.</p>
<p>General note: If you install anything with this installer version, update all the components you have already installed. E.g.: <em>BootMii</em> required some changes too, so the <em>HBC</em> with the new title ID gets loaded.</p>
<p>Note about <em>DVDX</em> enabled applications: Because of the new title ID, all current applications will fail to load <em>DVDX</em>. <em>libogc</em> needs additional code that checks for the new title ID. All <em>DVDX</em> enabled apps need to be recompiled afterwards.</p>
<p>Because Ninty fails to deliver new features with the latest update, I guess we have to compensate for that. Focus on this release are the promised improvements for <em>HBC</em>.</p>
<p>The changelog:</p>
<p><strong>HackMii installer (v0.5</strong>):</p>
<ul>
<li>New exploit to enable (un-)installation of all components on fully updated Wiis.</li>
<li>Fix hangs on some setups (they&#8217;re all related to retarded IOS patches).</li>
</ul>
<p><strong>BootMii beta 4 (v1.1)</strong>:</p>
<ul>
<li>Properly write the keys to <em>nand.bin</em>.<br />
This fixes the &#8220;NAND dump is from another Wii&#8221; issue on restoring beta 3 backups. If you don&#8217;t know how to fix those dumps, you have to backup the NAND again. Dumps from  all other versions are not affected.</li>
</ul>
<p><strong><strong>The Homebrew Channel v1.0.5</strong>:</strong></p>
<ul>
<li>Faster startup.</li>
<li>Prefer <em>boot.elf</em> over <em>boot.dol</em> when launching apps.</li>
<li>New shiny fonts, tweaked to the last subpixel.</li>
<li>Widescreen support.<br />
If your Wii is set to 16:9 in the system menu options, HBC  won&#8217;t  stretch the picture like it did on older versions. Unfortunately the fonts might look a little weird then, it really depends on the used display unit. Blame the lack of true widescreen support on the Wii for that.</li>
<li>Grid view.<br />
Hit 2/Y while browsing applications to switch between the old and the new view. This shows 4 columns on 16:9 setups, 4:3 users only get 3.</li>
<li>Device hot-plugging.<br />
You can remove and insert devices (front  SD slot, USB mass storage, and SDGecko in both slots) at all times now without reloading HBC.<br />
To change to another device, hit 1/X to bring up a simple option dialog.</li>
<li>Application sort order.<br />
You can now choose how to sort the shown entries. Current options: either by the name or by the release date.<br />
Note that for the latter sort order a valid <em>release_date</em> tag has to be present in the <em>meta.xml</em> file.<br />
Again, hit 1/X for the options dialog to set this.</li>
<li><em>wiiload</em> overhaul.<br />
On-the-fly compression: Uploaded files are automatically compressed on PC side: This makes it way faster, especially on bigger files. <a title="ScummVM homepage" href="http://scummvm.org">ScummVM</a>, anyone?<br />
Improved USBGecko support: Faster uploads, and you don&#8217;t have to stop reading debug messages from the device while uploading files.<br />
<em>libftdi</em> support: Because <em>ftdi-sio</em> fails, especially on OSX.<br />
<strong>Note</strong>: Because of these improvements, older <em>wiiload</em> version and 3rd party upload clients are incompatible. Use the bundled v0.5, binaries and source code are included.</li>
<li>Basic application management.<br />
To add apps: Just wiiload a ZIP archive, it will then get extracted to the active device. The ZIP file must be structured in a certain way, check <a title="Tasktracker entry" href="http://bugs.hackmii.com/index.php?do=details&amp;task_id=150">this</a> description for the details.<br />
To delete apps: There&#8217;s a new button on the application dialog.</li>
</ul>
<p><strong>DVDX</strong>:</p>
<ul>
<li>Allow PPC side hardware access.<br />
Also known as the magic <a href="http://hackmii.com/2009/08/of-tmds-and-hardware/"><em>HW_AHBPROT</em></a> register.</li>
<li>TMD version bumped to <em>2</em>, in case anyone needs to check for e.g. <em>HW_AHBPROT</em>.</li>
</ul>
<p>Either grab the new installer <a href="http://bootmii.org/">here</a>, or use the <em>HBC</em> online update (a confirmation dialog should pop up when launching <em>HBC</em>).</p>
<p>As always: Please link to this post instead of mirroring the binary, thanks.</p>
<p>Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://hackmii.com/2009/09/silly_games/feed/</wfw:commentRss>
		<slash:comments>156</slash:comments>
		</item>
	</channel>
</rss>
