<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Simeon Pilgrim</title>
	
	<link>http://simeonpilgrim.com/blog</link>
	<description />
	<lastBuildDate>Thu, 26 Jan 2012 18:49:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/SimeonPilgrim" /><feedburner:info uri="simeonpilgrim" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>New Transformers are Crazy Hard</title>
		<link>http://feedproxy.google.com/~r/SimeonPilgrim/~3/JHHOpn8vaVc/</link>
		<comments>http://simeonpilgrim.com/blog/2012/01/04/new-transformers-are-crazy-hard/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 13:02:39 +0000</pubDate>
		<dc:creator>Simeon</dc:creator>
				<category><![CDATA[Toys]]></category>

		<guid isPermaLink="false">http://simeonpilgrim.com/blog/?p=2173</guid>
		<description><![CDATA[When I was ten, Transformers where not that hard to transform. Meet modern Bumblebee, This transformer was crazy hard to transform, in the couple of days I was visting with the 4 year old owner, the head &#8220;popped off&#8221; multiple &#8230; <a href="http://simeonpilgrim.com/blog/2012/01/04/new-transformers-are-crazy-hard/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When I was ten, Transformers where not that hard to<em> transform</em>.</p>
<p>Meet modern <a href="http://en.wikipedia.org/wiki/Bumblebee_(Transformers)">Bumblebee</a>,</p>
<p><img class="alignnone size-full wp-image-2174" title="Bumblebee" src="http://simeonpilgrim.com/blog/wp-content/uploads/2012/01/Bumblebee.jpg" alt="" width="312" height="448" /></p>
<p>This transformer was crazy hard to transform, in the couple of days I was visting with the 4 year old owner, the head &#8220;popped off&#8221; multiple times, and I couldn&#8217;t get it back on without feeling I was going to break the toy. Lucky said child&#8217;s mother had the magic touch.</p>
<p>But transforming challenge aside, it was a pretty cool model/toy. Just not like the <a href="http://en.wikipedia.org/wiki/Starscream">Starscream</a> or <a href="http://en.wikipedia.org/wiki/Optimus_Prime">Optimus Prime</a> of my days gone by&#8230;.</p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="medium" count="1" href="http://simeonpilgrim.com/blog/2012/01/04/new-transformers-are-crazy-hard/"></g:plusone></div><img src="http://feeds.feedburner.com/~r/SimeonPilgrim/~4/JHHOpn8vaVc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://simeonpilgrim.com/blog/2012/01/04/new-transformers-are-crazy-hard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://simeonpilgrim.com/blog/2012/01/04/new-transformers-are-crazy-hard/</feedburner:origLink></item>
		<item>
		<title>Expectation Stress</title>
		<link>http://feedproxy.google.com/~r/SimeonPilgrim/~3/72K4Rbv4D68/</link>
		<comments>http://simeonpilgrim.com/blog/2012/01/04/expectation-stress/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 12:48:44 +0000</pubDate>
		<dc:creator>Simeon</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://simeonpilgrim.com/blog/?p=2170</guid>
		<description><![CDATA[Wow, since doing the easy work of decrypting the newer Nikon firmware, I&#8217;ve felt an immense pressure to pull another rabbit from the hat, when in reality the last reversing engineering project I worked on took years (2-5), and thus I feeling real burnt out. a) due to trying &#8230; <a href="http://simeonpilgrim.com/blog/2012/01/04/expectation-stress/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Wow, since doing the easy work of decrypting the newer Nikon firmware, I&#8217;ve felt an immense pressure to pull another rabbit from the hat, when in reality the last reversing engineering project I worked on took years (2-5), and thus I feeling real burnt out. a) due to trying to find the next &#8220;cool&#8221; insight, and 2) wanting to be part of the action, and keep up with others are finding.  (<em>the index scheme is an insiders joke</em>)</p>
<p>To this end, I point would-be-helpers to <a href="http://nikonhacker.com/index.php">nikonhacker.com</a>, I&#8217;ve been contributing there, as best I can.</p>
<p>It&#8217;s very addictive having such large inflows of traffic to your site/blog, that I was reluctant to redirect it, but I have also felt since November a presure not to post stupid stuff like I used too, or am about to post, thus have been silent (besides the travel and working on things that are not up for chatter).</p>
<p>So there&#8217;s <strong>my</strong> Nikon update&#8230;. I have been having a good family holiday..</p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="medium" count="1" href="http://simeonpilgrim.com/blog/2012/01/04/expectation-stress/"></g:plusone></div><img src="http://feeds.feedburner.com/~r/SimeonPilgrim/~4/72K4Rbv4D68" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://simeonpilgrim.com/blog/2012/01/04/expectation-stress/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://simeonpilgrim.com/blog/2012/01/04/expectation-stress/</feedburner:origLink></item>
		<item>
		<title>Monopoly Deal</title>
		<link>http://feedproxy.google.com/~r/SimeonPilgrim/~3/7nj0wG6De54/</link>
		<comments>http://simeonpilgrim.com/blog/2012/01/04/monopoly-deal/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 12:29:35 +0000</pubDate>
		<dc:creator>Simeon</dc:creator>
				<category><![CDATA[Games]]></category>

		<guid isPermaLink="false">http://simeonpilgrim.com/blog/?p=2166</guid>
		<description><![CDATA[The family was given Monopoly Deal for Christmas, and it&#8217;s a fantastic game. My first game was a six person double deck game, which was slower, and very brutal. Since then I have played many a game with Jacob (single &#8230; <a href="http://simeonpilgrim.com/blog/2012/01/04/monopoly-deal/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://simeonpilgrim.com/blog/wp-content/uploads/2012/01/Monopoly_Deal.jpeg"><img class="size-full wp-image-2167 alignright" title="Monopoly_Deal" src="http://simeonpilgrim.com/blog/wp-content/uploads/2012/01/Monopoly_Deal.jpeg" alt="" width="300" height="300" /></a>The family was given <a href="http://en.wikipedia.org/wiki/Monopoly_Deal">Monopoly Deal</a> for Christmas, and it&#8217;s a fantastic game.</p>
<p>My first game was a six person double deck game, which was slower, and very brutal. Since then I have played many a game with Jacob (single player) and it&#8217;s fast and fun.</p>
<p>In fine to twenty minutes, you can compact all the fun and rage of the full 4 hour game, but it&#8217;s done, and you can move on so much quicker. It has stealing, ripping people off, double crossing, saying no (it&#8217;s a card, but it the best feeling in the game rejecting a big play, just watch out for the reverse no,back at you&#8230;).</p>
<p>It&#8217;s a very fun game, and while there it can have all the rage of the original it, also can be started and finished within 30 minutes.. so many hands can be played giving the &#8220;balance&#8221; missing from Monopoly.</p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="medium" count="1" href="http://simeonpilgrim.com/blog/2012/01/04/monopoly-deal/"></g:plusone></div><img src="http://feeds.feedburner.com/~r/SimeonPilgrim/~4/7nj0wG6De54" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://simeonpilgrim.com/blog/2012/01/04/monopoly-deal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://simeonpilgrim.com/blog/2012/01/04/monopoly-deal/</feedburner:origLink></item>
		<item>
		<title>IDA Script: Fixing 16bit pushed data segment references</title>
		<link>http://feedproxy.google.com/~r/SimeonPilgrim/~3/Uxo5VRZXhuo/</link>
		<comments>http://simeonpilgrim.com/blog/2012/01/03/ida-script-fixing-16bit-pushed-data-segment-references/#comments</comments>
		<pubDate>Tue, 03 Jan 2012 20:18:36 +0000</pubDate>
		<dc:creator>Simeon</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[ida-pro]]></category>
		<category><![CDATA[idc script]]></category>

		<guid isPermaLink="false">http://simeonpilgrim.com/blog/?p=2152</guid>
		<description><![CDATA[A good friend has started reversing an old 16bit Borland C++ (3.1?) program, and had lots of stack push data segment offsets that were not correctly cross referencing. After telling him the shortcuts for manually fixing the issue (press O &#8230; <a href="http://simeonpilgrim.com/blog/2012/01/03/ida-script-fixing-16bit-pushed-data-segment-references/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A good friend has started reversing an old 16bit Borland C++ (3.1?) program, and had lots of stack push data segment offsets that were not correctly cross referencing.</p>
<p>After telling him the shortcuts for manually fixing the issue (press <strong>O</strong> for the data segment, or <strong>Alt-R</strong> for any segment offset), he wrote an IDC script to do it en mass.</p>
<p>Thus (made up example code)</p>
<pre class="brush: plain; title: ; notranslate">

push ds;

mov ax, 0x1234;

push ax
</pre>
<p>should look like:</p>
<pre class="brush: plain; title: ; notranslate">

push ds;

mov ax, ds:dword_1234;

push ax
</pre>
<p>Here&#8217;s his script:</p>
<pre class="brush: plain; title: ; notranslate">
#include &lt;idc.idc&gt;

static main()
{
    auto seg, loc;
    auto movloc, movtarget;
    auto xref;
    auto dsegbase;

    dsegbase = SegByName(&quot;dseg&quot;) * 16;
    Message(&quot;dsegbase=%x\n&quot;, dsegbase);

    Message(&quot;========================================\n&quot;);
    seg = FirstSeg();

    while(seg != BADADDR )
    {
        Message(&quot;----------------------------------------\n&quot;);

        loc = SegStart(seg);

        if( Byte(loc) != 0xCD || Byte(loc+1) != 0x3F)
        {
            Message(&quot;Fixing indirect push [ds:xx] refs from %s\n&quot;, SegName(seg));

            while(loc != BADADDR &amp;&amp; loc &lt; SegEnd(seg))
            {
                if (GetMnem(loc) != &quot;push&quot; || GetOpnd(loc, 0) != &quot;ds&quot;)
                {
                    loc = NextHead(loc, BADADDR);
                    continue;
                }
                loc = NextHead(loc, BADADDR);

                if (GetMnem(loc) != &quot;mov&quot; || GetOpType(loc, 1) != o_imm)
                {
                    loc = NextHead(loc, BADADDR);
                    continue;
                }
                movloc = loc;
                movtarget = GetOpnd(movloc, 0);
                loc = NextHead(loc, BADADDR);

                if (GetMnem(loc) != &quot;push&quot; || GetOpnd(loc, 0) != movtarget)
                {
                    continue;
                }

                // At this point, we know we're pushing a [ds:x] combo.
                //Message(&quot;%x: mov %s, %s\n&quot;, movloc, movtarget, GetOpnd(movloc, 1));

                // Abort if there already exists a Dxref
                xref = Dfirst(movloc);
                if (xref != BADADDR)
                {
                    continue;
                }

                Message(&quot;  Updating %s:%04x\n&quot;, SegName(seg), (movloc - seg) &amp; 0xffff);
                OpOff(movloc, 1, dsegbase);
            }
        }

        seg = NextSeg(seg);
    }
}
</pre>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="medium" count="1" href="http://simeonpilgrim.com/blog/2012/01/03/ida-script-fixing-16bit-pushed-data-segment-references/"></g:plusone></div><img src="http://feeds.feedburner.com/~r/SimeonPilgrim/~4/Uxo5VRZXhuo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://simeonpilgrim.com/blog/2012/01/03/ida-script-fixing-16bit-pushed-data-segment-references/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://simeonpilgrim.com/blog/2012/01/03/ida-script-fixing-16bit-pushed-data-segment-references/</feedburner:origLink></item>
		<item>
		<title>Nikon Firmware Insights #05</title>
		<link>http://feedproxy.google.com/~r/SimeonPilgrim/~3/s4lIZNZrR-M/</link>
		<comments>http://simeonpilgrim.com/blog/2011/12/06/nikon-firmware-insights-05/#comments</comments>
		<pubDate>Tue, 06 Dec 2011 18:20:45 +0000</pubDate>
		<dc:creator>Simeon</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://simeonpilgrim.com/blog/?p=2009</guid>
		<description><![CDATA[Just to let people know, yes I&#8217;ve been working on understanding the D5100 firmware. I&#8217;ve got most the area&#8217;s of code identified (where they are, not what they do), but there are some puzzles, with some chunks of code that &#8230; <a href="http://simeonpilgrim.com/blog/2011/12/06/nikon-firmware-insights-05/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Just to let people know, yes I&#8217;ve been working on understanding the D5100 firmware.</p>
<p>I&#8217;ve got most the area&#8217;s of code identified (where they are, not what they do), but there are some puzzles, with some chunks of code that are used (eg selects a picture to be shown based on shooting mode) but the code it self is not directly linked to, and it&#8217;s address in not present in the image. There is defiantly some form of jump/call table compression/encoding done, as there are functions that do some maths, and then call the result. So that needs to be puzzled out.</p>
<p>So to help map the data (and thus remove possible options from above puzzle), I previous mentioned mapping the jpg&#8217;s out:</p>
<p><img class="alignnone size-full wp-image-2010" title="Embedded Jpg's" src="http://simeonpilgrim.com/blog/wp-content/uploads/2011/12/Embedded_Jpgs.png" alt="" width="610" height="446" /></p>
<p>As can be seen in this small sample, there&#8217;s the icons for the different shooting modes, and three colour schemes.</p>
<p>Last night I was working on using a modified version of BinViz (original <a href="http://www.gh1-hack.info/wiki/BinaryFileAnalysysTools">found here</a>) and have found how the font&#8217;s and overlay text/images are packed, and I am in the process of tracking down how the width/size information is encoded in the associated data tables. Shown below is the same block of data shown, but at two different widths, showing the &#8220;Dial&#8221; overlays and the &#8220;Bulb Time&#8221; text:</p>
<p><img class="alignnone size-full wp-image-2012" title="Overlay Images 2" src="http://simeonpilgrim.com/blog/wp-content/uploads/2011/12/Overlay_Images_2.png" alt="" width="201" height="316" /><img class="alignnone size-full wp-image-2011" title="Overlay Images 1" src="http://simeonpilgrim.com/blog/wp-content/uploads/2011/12/Overlay_Images_1.png" alt="" width="214" height="286" /></p>
<p><del>It&#8217;s quite neat looking at the Asian font sets, as the fonts/overlays use <a href="http://en.wikipedia.org/wiki/Subpixel_rendering">subpixel rendering</a>, which can be seen in the green arm of the sports mode dial icon above.</del> Much simpler, the normal overlays are just black/white, and now look better X/Y scaled.</p>
<p>I started a Google Code Project called <a href="http://code.google.com/p/nikon-firmware-tools/">Nikon Firmware Tools</a> in which I&#8217;m placing the tools I&#8217;m using and the changes I&#8217;m making to them as I go. So interested developers can look there. Sorry only code so far.</p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="medium" count="1" href="http://simeonpilgrim.com/blog/2011/12/06/nikon-firmware-insights-05/"></g:plusone></div><img src="http://feeds.feedburner.com/~r/SimeonPilgrim/~4/s4lIZNZrR-M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://simeonpilgrim.com/blog/2011/12/06/nikon-firmware-insights-05/feed/</wfw:commentRss>
		<slash:comments>33</slash:comments>
		<feedburner:origLink>http://simeonpilgrim.com/blog/2011/12/06/nikon-firmware-insights-05/</feedburner:origLink></item>
		<item>
		<title>Nikon Firmware Insights #04</title>
		<link>http://feedproxy.google.com/~r/SimeonPilgrim/~3/a0_IEhlXqSQ/</link>
		<comments>http://simeonpilgrim.com/blog/2011/11/25/nikon-firmware-insights-04/#comments</comments>
		<pubDate>Fri, 25 Nov 2011 21:41:16 +0000</pubDate>
		<dc:creator>Simeon</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Firmware]]></category>
		<category><![CDATA[nikon]]></category>

		<guid isPermaLink="false">http://simeonpilgrim.com/blog/?p=1992</guid>
		<description><![CDATA[A little under 24 hours ago, and roos posted he and Kungsholmens Kameraklubb found the checksum for the D7000 A &#38; B firmware , but it didn&#8217;t work on the d5100 firmware. The code they used was the big endian form &#8230; <a href="http://simeonpilgrim.com/blog/2011/11/25/nikon-firmware-insights-04/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A little under 24 hours ago, and <a href="http://www.flickr.com/people/69296392@N07/">roos posted he and Kungsholmens Kameraklubb found the checksum for the D7000 A &amp; B firmware</a> , but it didn&#8217;t work on the d5100 firmware.</p>
<p>The code they used was the big endian form of the CRC16, but running on little endian CPUs.</p>
<p>Turning the <a href="http://en.wikipedia.org/wiki/Computation_of_CRC">Wikipedia CRC code</a> into C# follows:</p>
<p><del datetime="2011-11-28T02:12:11+00:00">For the D7000 A &amp; B, D300S A&amp;B, D3S A &amp; B, D3100 A, D5100 A firmware files use start: 0&#215;0000, mask=0&#215;1021<br />
</del><br />
For all models (D3S, D300S, D7000, D5100 &amp; D3100) the CRC is a normal Xmodem CRC16, the originally reported difference for D5100 &amp; D3100 was due to a XOR error (by me), that is now found &amp; fixed.</p>
<pre class="brush: plain; title: ; notranslate">
static int crcBig(byte[] data, int len)
{
    int rem = 0x0;

    for (int i = 0; i &lt; len; i++)
    {
        rem = rem ^ (data[i] &lt;&lt; 8);
        for (int j = 0; j &lt; 8; j++)
        {
            if ((rem &amp; 0x8000) != 0)
            {
                rem = (rem &lt;&lt; 1) ^ 0x1021;
            }
            else
            {
                rem = rem &lt;&lt; 1;

            }
            rem = rem &amp; 0xFFFF; // Trim remainder to 16 bits
        }
    }
    // A popular variant complements rem here
    return rem;
}
</pre>
<p><del datetime="2011-11-28T02:12:11+00:00">For the D5100 B firmware use start= 0x4ed4, mask= 0&#215;1021</del></p>
<div id="attachment_1993" class="wp-caption alignnone" style="width: 650px"><img class="size-full wp-image-1993" title="D5100_Updating" src="http://simeonpilgrim.com/blog/wp-content/uploads/2011/11/D5100_Updating.jpg" alt="" width="640" height="480" /><p class="wp-caption-text">D5100 checksum passed, now loading firmware</p></div>
<p>&nbsp;</p>
<div id="attachment_1994" class="wp-caption alignnone" style="width: 650px"><img class="size-full wp-image-1994" title="D5100_Firmware_Help" src="http://simeonpilgrim.com/blog/wp-content/uploads/2011/11/D5100_Firmware_Help.jpg" alt="" width="640" height="480" /><p class="wp-caption-text">D5100 HaCkEd firmware running.</p></div>
<p>The D3100 B firmware also matches the same start value, so I&#8217;d assume it&#8217;s common to both. And the only thing I modified here was the firmware help message, and I&#8217;ve not tested if you can load the 1.01 firmware over top it&#8217;s self. That is the next step. Also to make a tool (Vitaliy?) the patches and encrypts for you to avoid typo&#8217;s.</p>
<p>[Update]<br />
Very import and good news, firmware lets you flash same version over top it&#8217;s self. Thus my camera is now back running normal Nikon 1.01 firmware. Warranty <strong>unbroken</strong>!<br />
[Update 2: 27 Nov] Fixed CRC code in light of XOR code change.</p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="medium" count="1" href="http://simeonpilgrim.com/blog/2011/11/25/nikon-firmware-insights-04/"></g:plusone></div><img src="http://feeds.feedburner.com/~r/SimeonPilgrim/~4/a0_IEhlXqSQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://simeonpilgrim.com/blog/2011/11/25/nikon-firmware-insights-04/feed/</wfw:commentRss>
		<slash:comments>67</slash:comments>
		<feedburner:origLink>http://simeonpilgrim.com/blog/2011/11/25/nikon-firmware-insights-04/</feedburner:origLink></item>
		<item>
		<title>Donate Button Removed</title>
		<link>http://feedproxy.google.com/~r/SimeonPilgrim/~3/MeFZW9insqY/</link>
		<comments>http://simeonpilgrim.com/blog/2011/11/20/donate-button-removed/#comments</comments>
		<pubDate>Sun, 20 Nov 2011 17:30:01 +0000</pubDate>
		<dc:creator>Simeon</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Firmware]]></category>
		<category><![CDATA[nikon]]></category>

		<guid isPermaLink="false">http://simeonpilgrim.com/blog/?p=1977</guid>
		<description><![CDATA[Yesterday after a couple of suggestions, I added a PayPal donate button, I thought I&#8217;d done it correctly, but it appears it didn&#8217;t work. I also said I would be happy to accept money in order to pay for a &#8230; <a href="http://simeonpilgrim.com/blog/2011/11/20/donate-button-removed/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Yesterday after a couple of suggestions, I added a PayPal donate button, I thought I&#8217;d done it correctly, but it appears it didn&#8217;t work.</p>
<p>I also said I would be happy to accept money in order to pay for a legit version of IDA Pro. I&#8217;ll return the one donation I did get.</p>
<p>I then proceeded to have many emails with Vitaliy about how the work could be done with the free version. While his methods will technically work, I&#8217;m just not sure I want to publicly endorse them.</p>
<p>So to avoid offending &#8216;the scene&#8217; with personal greed, I&#8217;m pulling my hat from the race. I&#8217;ll just be the guy that solved the encryption and stick with that.</p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="medium" count="1" href="http://simeonpilgrim.com/blog/2011/11/20/donate-button-removed/"></g:plusone></div><img src="http://feeds.feedburner.com/~r/SimeonPilgrim/~4/MeFZW9insqY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://simeonpilgrim.com/blog/2011/11/20/donate-button-removed/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		<feedburner:origLink>http://simeonpilgrim.com/blog/2011/11/20/donate-button-removed/</feedburner:origLink></item>
		<item>
		<title>Nikon Firmware Insights #03</title>
		<link>http://feedproxy.google.com/~r/SimeonPilgrim/~3/98pqFA_eXL8/</link>
		<comments>http://simeonpilgrim.com/blog/2011/11/18/nikon-firmware-insights-03/#comments</comments>
		<pubDate>Sat, 19 Nov 2011 04:12:36 +0000</pubDate>
		<dc:creator>Simeon</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Firmware]]></category>
		<category><![CDATA[nikon]]></category>

		<guid isPermaLink="false">http://simeonpilgrim.com/blog/?p=1958</guid>
		<description><![CDATA[The B firmware is were the major action is, and it&#8217;s based on the Fujitsu FR chipset. This seems to be the same chip as used by the earlier Nikon DSLRs and the Pentax cameras. Looking at the B firmware &#8230; <a href="http://simeonpilgrim.com/blog/2011/11/18/nikon-firmware-insights-03/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The B firmware is were the major action is, and it&#8217;s based on the Fujitsu FR chipset. This seems to be the same chip as used by the earlier <a href="http://wiki.berndlux.de/doku.php?id=elektr:kabeld70s#hardware_der_nikon_d70s">Nikon DSLR</a>s and the <a href="http://www.pentaxforums.com/forums/pentax-dslr-discussion/67897-pentax-firmware-hack-site-20.html">Pentax cameras</a>.</p>
<p>Looking at the B firmware you can see text, for example English @ 0x5ACC68 to but the table of addresses prior to this text block have the same relative spacing of values but are 0&#215;40000 bytes higher in value.</p>
<p><img class="alignnone size-full wp-image-1959" title="Text_Locations" src="http://simeonpilgrim.com/blog/wp-content/uploads/2011/11/Text_Locations.png" alt="" width="526" height="302" /></p>
<p>Browsing elsewhere in the file, shows this pattern holds up for the entire file. You can check by finding some text, ad 0&#215;40000 to the text file address, then search for that resulting hex value, ta-da</p>
<p>So we can assume the code is loaded starting at 0&#215;40000.</p>
<p>Next is what we are going to decode the file with. If you have commercial version of IDA Pro then your in luck as it comes with the Fujitsu FR CPU decoder built in. I only have the free version, so am not so luckly.</p>
<p><a href="http://www.kw.igs.net/~schoedel/">Kevin Schoedel</a> however has written a<a href="http://scratchpad.wikia.com/wiki/Disassemblers/DFR"> pretty good dissembler for the FR CPU</a>, as part of previous Pentax firmware work. I struggled to get the original code working correctly, so I rewrote it in C# and now understand how to use it, and really appreciate his efforts. But I am left oh-so-much wanting IDA Pro style <strong>everything</strong>. The worst thing is I almost want to pay the $500USD to have that IDA Pro magic, but if I have that money &#8216;spare&#8217; why didn&#8217;t I just buy the D7000 to start with.</p>
<p>Anyway, my present D5100 B firmware DFR import file looks like:</p>
<pre class="brush: plain; title: ; notranslate">
# File map: D5100
-i 0x00040000-0x00BFFFFF=0x00000000

# Memory map:
-m 0x00040000-0x00040947=CODE
-m 0x00040948-0x000409b3=DATA:L
-m 0x000409b4-0x00050068=CODE

# interupt vector table.
-m 0x000dfc00-0x000dffff=DATA:L

#-m 0x000e0000-0x0x000fffff=DATA:L // this is 0xFF rubbish

-m 0x00100000-0x00236A4A=CODE
</pre>
<p>and heres my <a href="http://simeonpilgrim.com/blog/wp-content/uploads/2011/11/dfr_csharp.zip">C# port of DFR</a>, to use the above with.</p>
<p>If <a href="http://hexblog.com/about.html">Ilfak</a> wants to give me a free copy of <a href="http://www.hex-rays.com/products/ida/index.shtml">IDA Pro</a>, or even just the FR processor that works with 5.0, I would be very humbled.</p>
<p>The <a href="http://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;ved=0CBwQFjAA&amp;url=http%3A%2F%2Fwww.fujitsu.com%2Fdownloads%2FCN%2Ffss%2Fservices%2Fmcu%2F32bit%2Fprogfr-cm71-00101-5e.pdf&amp;ei=BSrHTuTyIIHsggedy-01&amp;usg=AFQjCNEBCY-5KokcIQ9FT2dk25mOZmXAHw">FR &#8211; CM71-00101-5E.pdf</a> instruction manual from Fujitsu is very useful.</p>
<p>Here the first 0x4a bytes of the firmware, you can see the interupt vector table being loaded at 0x4002c.</p>
<pre class="brush: plain; title: ; notranslate">
Disassemble 0x00040000-0x00040947 (file 0x00000000) as CODE

00040000 (00000000)  9F80 5000 0000         LDI:32  #0x50000000,R0
00040006 (00000006)  C011                   LDI:8   #0x01,R1
00040008 (00000008)  1501                   STH     R1,@R0          ; 0x50000000
0004000A (0000000A)  9B00 03E0              LDI:20  #0x003E0,R0
0004000E (0000000E)  9F81 4700 0000         LDI:32  #0x47000000,R1
00040014 (00000014)  1401                   ST      R1,@R0          ; 0x000003E0
00040016 (00000016)  9B00 03E7              LDI:20  #0x003E7,R0
0004001A (0000001A)  C031                   LDI:8   #0x03,R1
0004001C (0000001C)  1601                   STB     R1,@R0          ; 0x000003E7
0004001E (0000001E)  8710                   STILM   #0x10
00040020 (00000020)  9F8F 6800 0800         LDI:32  #0x68000800,R15
00040026 (00000026)  9F80 000D FC00         LDI:32  #0x000DFC00,R0
0004002C (0000002C)  B300                   MOV     R0,TBR
0004002E (0000002E)  9B00 0600              LDI:20  #0x00600,R0
00040032 (00000032)  9B41 0185              LDI:20  #0x40185,R1
00040036 (00000036)  1401                   ST      R1,@R0          ; 0x00000600
00040038 (00000038)  9B00 0640              LDI:20  #0x00640,R0
0004003C (0000003C)  C401                   LDI:8   #0x40,R1
0004003E (0000003E)  1401                   ST      R1,@R0          ; 0x00000640
00040040 (00000040)  9B00 0680              LDI:20  #0x00680,R0
00040044 (00000044)  9F81 799F 9910         LDI:32  #0x799F9910,R1
0004004A (0000004A)  1401                   ST      R1,@R0          ; 0x00000680
</pre>
<p>The second address in parens is the original file offset to help with looking up the file.</p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="medium" count="1" href="http://simeonpilgrim.com/blog/2011/11/18/nikon-firmware-insights-03/"></g:plusone></div><img src="http://feeds.feedburner.com/~r/SimeonPilgrim/~4/98pqFA_eXL8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://simeonpilgrim.com/blog/2011/11/18/nikon-firmware-insights-03/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		<feedburner:origLink>http://simeonpilgrim.com/blog/2011/11/18/nikon-firmware-insights-03/</feedburner:origLink></item>
		<item>
		<title>Nikon Firmware Insights #02</title>
		<link>http://feedproxy.google.com/~r/SimeonPilgrim/~3/l_bZzlyF0_c/</link>
		<comments>http://simeonpilgrim.com/blog/2011/11/18/nikon-firmware-insights-02/#comments</comments>
		<pubDate>Sat, 19 Nov 2011 03:20:29 +0000</pubDate>
		<dc:creator>Simeon</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Firmware]]></category>
		<category><![CDATA[nikon]]></category>

		<guid isPermaLink="false">http://simeonpilgrim.com/blog/?p=1948</guid>
		<description><![CDATA[So once the D5100 1.01 firmware was update was released, I couldn&#8217;t help but decrypt it. As noted in the previous post, the bundle is checksum&#8217;ed, but I didn&#8217;t mention that each sub-file is also checksum&#8217;ed. But you can see &#8230; <a href="http://simeonpilgrim.com/blog/2011/11/18/nikon-firmware-insights-02/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So once the D5100 1.01 firmware was update was released, I couldn&#8217;t help but decrypt it.</p>
<p>As noted in the previous post, the bundle is checksum&#8217;ed, but I didn&#8217;t mention that each sub-file is also checksum&#8217;ed. But you can see the checksum at the end of the files:</p>
<p><img class="alignnone size-full wp-image-1949" title="File Checksum" src="http://simeonpilgrim.com/blog/wp-content/uploads/2011/11/File_Checksum.png" alt="" width="522" height="127" /></p>
<p>Now on some Pentax forum I was reading about people wondering if the checksum was checked. So I altered the help file text for the viewing firmware information to make the &#8216;c&#8217; of camera upper case.</p>
<p><img class="alignnone size-full wp-image-1950" title="D5100_Help_Text" src="http://simeonpilgrim.com/blog/wp-content/uploads/2011/11/D5100_Help_Text.png" alt="" width="541" height="122" /></p>
<p><img class="alignnone size-full wp-image-1952" title="Firmware version" src="http://simeonpilgrim.com/blog/wp-content/uploads/2011/11/DSC07855.jpg" alt="" width="468" height="292" /></p>
<p>Now the file is just XOR&#8217;d with the larger one time pad discussed earlier, and &#8216;c&#8217; to &#8216;C&#8217; is just XOR&#8217;ing with 0&#215;20, applying the same XOR to the encrypted file at the same location, will have the net result of making the output upper case.</p>
<p>I put this altered firmware on a SD stick, and popped in into the D5100. Long story short, it recognized the update, <span style="text-decoration: underline;">but</span> once I started the update, it quit really early in the process. The amount of time I&#8217;d expect for the checksum to be checked&#8230;</p>
<p><img class="alignnone size-full wp-image-1953" title="Update?" src="http://simeonpilgrim.com/blog/wp-content/uploads/2011/11/DSC07856.jpg" alt="" width="434" height="226" /></p>
<p>So I then turned to the internet for checksum algorithms, and it doesn&#8217;t appear to be a <a href="http://en.wikipedia.org/wiki/Cyclic_redundancy_check">CRC-16-anything</a>, as I brute forced the full possibility space, that was a fun adventure in multi-threading batch processing. Nor does it seam to be a <a href="http://en.wikipedia.org/wiki/Fletcher%27s_checksum">Fletcher&#8217;s Checksum</a>.</p>
<p>So now I&#8217;m up to searching for the answer in code&#8230;</p>
<p>[Update: 25 Nov] Answer found by Roos, see <a href="http://simeonpilgrim.com/blog/2011/11/25/nikon-firmware-insights-04/">here</a></p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="medium" count="1" href="http://simeonpilgrim.com/blog/2011/11/18/nikon-firmware-insights-02/"></g:plusone></div><img src="http://feeds.feedburner.com/~r/SimeonPilgrim/~4/l_bZzlyF0_c" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://simeonpilgrim.com/blog/2011/11/18/nikon-firmware-insights-02/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		<feedburner:origLink>http://simeonpilgrim.com/blog/2011/11/18/nikon-firmware-insights-02/</feedburner:origLink></item>
		<item>
		<title>Nikon Firmware Insights #01</title>
		<link>http://feedproxy.google.com/~r/SimeonPilgrim/~3/iJeZn-cGHxs/</link>
		<comments>http://simeonpilgrim.com/blog/2011/11/18/nikon-firmware-insights-01/#comments</comments>
		<pubDate>Sat, 19 Nov 2011 02:35:21 +0000</pubDate>
		<dc:creator>Simeon</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Firmware]]></category>
		<category><![CDATA[nikon]]></category>

		<guid isPermaLink="false">http://simeonpilgrim.com/blog/?p=1941</guid>
		<description><![CDATA[Here&#8217;s the first post in my Nikon Firmware investigations. Firstly after removing the encryption from the Nikon DSLR firmware bundle file, we should extract each file from the bundle. Form my looking at the files I have, there is 0&#215;20 bytes of &#8230; <a href="http://simeonpilgrim.com/blog/2011/11/18/nikon-firmware-insights-01/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s the first post in my Nikon Firmware investigations.</p>
<p>Firstly after removing the <a href="http://simeonpilgrim.com/blog/2011/11/07/how-to-decode-the-nikon-dslr-firmware/">encryption from the Nikon DSLR firmware</a> bundle file, we should extract each file from the bundle.</p>
<p>Form my looking at the files I have, there is 0&#215;20 bytes of fluff, then there is a file count, header length, and a couple of dummy int32&#8242;s. Then there&#8217;s 0&#215;10 bytes of file name, file start, length, and two more dummy int32&#8242;s. After that there&#8217;s a word &#8216;checksum&#8217; and some padding bytes.</p>
<p>Thus this code (C#) pulls the files out of the bundle file decoded by the previous post:</p>
<pre class="brush: plain; title: ; notranslate">
static void ExactFirmware3(string fileName)
{
    if (File.Exists(fileName))
    {
        BinaryReader br = null;

        try
        {
            br = new BinaryReader(File.Open(fileName + &quot;.out.bin&quot;,
                FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
            br.BaseStream.Seek(0x20, SeekOrigin.Begin);

            uint count = ReadUint32(br);
            uint headerlen = ReadUint32(br);
            uint dummy1 = ReadUint32(br);
            uint dummy2 = ReadUint32(br);

            var header = new List&lt;Tuple&lt;string,uint,uint&gt;&gt;();

            // Read Header
            for (int c = 0; c &lt; count; c++)
            {
                string firmwareName = Path.Combine( Path.GetDirectoryName(fileName),
                    ReadString(br, 16));
                uint start = ReadUint32(br);
                uint len = ReadUint32(br);
                uint hdummy1 = ReadUint32(br);
                uint hdummy2 = ReadUint32(br);

                header.Add(new Tuple&lt;string, uint, uint&gt;(firmwareName, start, len));
            }

            foreach (var t in header)
            {
                DumpFile(br, t.Item1, t.Item2, t.Item3);
            }
        }
        finally
        {
            if (br != null)
                br.Close();
        }
    }
}

static void DumpFile(BinaryReader br, string fileName, uint start, uint len)
{
    BinaryWriter bw = null;

    try
    {
        bw = new BinaryWriter(File.Open(fileName, FileMode.Create, FileAccess.Write,
            FileShare.ReadWrite));

        br.BaseStream.Seek(start, SeekOrigin.Begin);

        var data = br.ReadBytes((int)len);

        bw.Write(data);
    }
    finally
    {
        if (bw != null)
            bw.Close();
    }
}
</pre>
<p>Now for the D5100 we have two files, a640m010100.bin and b640101b.bin. The D7000 firmware is x75xxxx.BIN, the D3100 is x74xxxx.BIN, D300S is x81xxx.BIN and the D3S is xD3Sxxx.BIN.</p>
<p>All these systems are running the &#8216;Softune REALOS/FR is Realtime OS for FR Framily&#8217;, the Axxxx.BIN firmware is for the IO control CPU (metering, focus, buttons) and the larger Bxxxxx.BIN is the main processor firmware, with the main UI and processing (Fujitsu FR CPU).</p>
<p>Some great insight was found from the <a href="http://wiki.berndlux.de/doku.php?id=elektr:kabeld70s#hardware_der_nikon_d70s">D70 Hack Project</a>, which was the only remaining information I found. It&#8217;s in German, so thank you Google Translate. Also <a href="http://www.chipworks.com/en/technical-competitive-analysis/resources/recent-teardowns/2011/01/teardown-of-the-nikon-d7000-dslr/">D7000 tear by</a> by Chipworks was very inspiring.</p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="medium" count="1" href="http://simeonpilgrim.com/blog/2011/11/18/nikon-firmware-insights-01/"></g:plusone></div><img src="http://feeds.feedburner.com/~r/SimeonPilgrim/~4/iJeZn-cGHxs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://simeonpilgrim.com/blog/2011/11/18/nikon-firmware-insights-01/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		<feedburner:origLink>http://simeonpilgrim.com/blog/2011/11/18/nikon-firmware-insights-01/</feedburner:origLink></item>
	</channel>
</rss>

