<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Picture Puzzle</title>
	<atom:link href="http://blog.didierstevens.com/2008/11/09/picture-puzzle/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.didierstevens.com/2008/11/09/picture-puzzle/</link>
	<description>(blog 'DidierStevens)</description>
	<lastBuildDate>Sun, 14 Mar 2010 21:22:33 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jim</title>
		<link>http://blog.didierstevens.com/2008/11/09/picture-puzzle/#comment-33719</link>
		<dc:creator>Jim</dc:creator>
		<pubDate>Thu, 13 Nov 2008 21:10:11 +0000</pubDate>
		<guid isPermaLink="false">http://didierstevens.wordpress.com/?p=863#comment-33719</guid>
		<description>That commandline can be sharpened up a touch ... I tend to build up a commandline one step at a time, makes it easy to see what&#039;s going on.

Once you get a good command-line solution, this can usefully form the basis of automated testing :-)

As Jordan says, the key here is to run ndisasm over the file, and notice the &#039;mov byte&#039; invocations. Collecting them with grep is simple, and then cut can be used to grab just the bytes themselves out.

ndisasm -u picture-puzzle.bmp &#124; grep &#039;mov byte&#039; &#124; cut -d, -f2

This produces the bytes we want, one per line. To make printf&#039;s job easier, we need to replace &#039;^0x&#039; with &#039;\x...&#039; (using single quotes here to make the \ safe from the shell, but still doubling it because of sed), and also replace &#039;x0$&#039; (the null) with &#039;x0a&#039; (LF)

... &#124; sed -e &#039;s/^0x/\\x/; s/x0$/x0a/&#039;

The tr command is a great way to strip out all the newlines, and make this one single line for the printf command ... which wraps around the whole commandline using the $() operator from bash (easier to read than the traditional shell ` backticks)

printf $(ndisadm ...&#124;tr -d &#039;\n&#039;)

Oh noes! An alphabet substitution ... quickly fixed with the caesar program, which will do a quick letter frequency count to determine the correct rotation to use ... in this case, it&#039;s 13 of course.

printf $(ndisasm -u picture-puzzle.bmp &#124; grep &#039;mov byte&#039; &#124; cut -d, -f2 &#124;
 sed -e &#039;s/^0x/\\x/; s/x0$/x0a/&#039; &#124; tr -d &#039;\n&#039; ) &#124; caesar

Hello from BMP shellcode!
hfre32
ZrffntrObkN</description>
		<content:encoded><![CDATA[<p>That commandline can be sharpened up a touch &#8230; I tend to build up a commandline one step at a time, makes it easy to see what&#8217;s going on.</p>
<p>Once you get a good command-line solution, this can usefully form the basis of automated testing <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>As Jordan says, the key here is to run ndisasm over the file, and notice the &#8216;mov byte&#8217; invocations. Collecting them with grep is simple, and then cut can be used to grab just the bytes themselves out.</p>
<p>ndisasm -u picture-puzzle.bmp | grep &#8216;mov byte&#8217; | cut -d, -f2</p>
<p>This produces the bytes we want, one per line. To make printf&#8217;s job easier, we need to replace &#8216;^0x&#8217; with &#8216;\x&#8230;&#8217; (using single quotes here to make the \ safe from the shell, but still doubling it because of sed), and also replace &#8216;x0$&#8217; (the null) with &#8216;x0a&#8217; (LF)</p>
<p>&#8230; | sed -e &#8217;s/^0x/\\x/; s/x0$/x0a/&#8217;</p>
<p>The tr command is a great way to strip out all the newlines, and make this one single line for the printf command &#8230; which wraps around the whole commandline using the $() operator from bash (easier to read than the traditional shell ` backticks)</p>
<p>printf $(ndisadm &#8230;|tr -d &#8216;\n&#8217;)</p>
<p>Oh noes! An alphabet substitution &#8230; quickly fixed with the caesar program, which will do a quick letter frequency count to determine the correct rotation to use &#8230; in this case, it&#8217;s 13 of course.</p>
<p>printf $(ndisasm -u picture-puzzle.bmp | grep &#8216;mov byte&#8217; | cut -d, -f2 |<br />
 sed -e &#8217;s/^0x/\\x/; s/x0$/x0a/&#8217; | tr -d &#8216;\n&#8217; ) | caesar</p>
<p>Hello from BMP shellcode!<br />
hfre32<br />
ZrffntrObkN</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Didier Stevens</title>
		<link>http://blog.didierstevens.com/2008/11/09/picture-puzzle/#comment-33718</link>
		<dc:creator>Didier Stevens</dc:creator>
		<pubDate>Thu, 13 Nov 2008 20:48:15 +0000</pubDate>
		<guid isPermaLink="false">http://didierstevens.wordpress.com/?p=863#comment-33718</guid>
		<description>I&#039;ll post my solution for Windows in the coming weeks</description>
		<content:encoded><![CDATA[<p>I&#8217;ll post my solution for Windows in the coming weeks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sh4Rkb8</title>
		<link>http://blog.didierstevens.com/2008/11/09/picture-puzzle/#comment-33717</link>
		<dc:creator>sh4Rkb8</dc:creator>
		<pubDate>Thu, 13 Nov 2008 20:43:27 +0000</pubDate>
		<guid isPermaLink="false">http://didierstevens.wordpress.com/?p=863#comment-33717</guid>
		<description>... and the ascii table was superfluous (should have looked more closely at the text table in the hex editor).

I&#039;ll shut up now.</description>
		<content:encoded><![CDATA[<p>&#8230; and the ascii table was superfluous (should have looked more closely at the text table in the hex editor).</p>
<p>I&#8217;ll shut up now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sh4Rkb8</title>
		<link>http://blog.didierstevens.com/2008/11/09/picture-puzzle/#comment-33716</link>
		<dc:creator>sh4Rkb8</dc:creator>
		<pubDate>Thu, 13 Nov 2008 20:20:26 +0000</pubDate>
		<guid isPermaLink="false">http://didierstevens.wordpress.com/?p=863#comment-33716</guid>
		<description>I was able to find the string Jordan was referring to by opening the file in a hex editor, did a hex-ascii conversion, and applying rot13 (like Jordan) arrived at the answer. 

However, that was clearly the easy part. I&#039;m still trying to figure out how to trim it down to that particular string from the whole hex dump. Mind you, I don&#039;t have nearly the skills Jordan clearly does.</description>
		<content:encoded><![CDATA[<p>I was able to find the string Jordan was referring to by opening the file in a hex editor, did a hex-ascii conversion, and applying rot13 (like Jordan) arrived at the answer. </p>
<p>However, that was clearly the easy part. I&#8217;m still trying to figure out how to trim it down to that particular string from the whole hex dump. Mind you, I don&#8217;t have nearly the skills Jordan clearly does.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sh4Rkb8</title>
		<link>http://blog.didierstevens.com/2008/11/09/picture-puzzle/#comment-33712</link>
		<dc:creator>sh4Rkb8</dc:creator>
		<pubDate>Thu, 13 Nov 2008 14:58:58 +0000</pubDate>
		<guid isPermaLink="false">http://didierstevens.wordpress.com/?p=863#comment-33712</guid>
		<description>Complete neophyte here - arrived by way of another blog.

I&#039;m very interested in learning about these analyses that you describe in your various posts. 

Are there useful tools (such as the shellcode wrapper or debugger that Jordan mentions) available as freeware for Windows?

Thanks!</description>
		<content:encoded><![CDATA[<p>Complete neophyte here &#8211; arrived by way of another blog.</p>
<p>I&#8217;m very interested in learning about these analyses that you describe in your various posts. </p>
<p>Are there useful tools (such as the shellcode wrapper or debugger that Jordan mentions) available as freeware for Windows?</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jordan</title>
		<link>http://blog.didierstevens.com/2008/11/09/picture-puzzle/#comment-33696</link>
		<dc:creator>Jordan</dc:creator>
		<pubDate>Mon, 10 Nov 2008 22:30:54 +0000</pubDate>
		<guid isPermaLink="false">http://didierstevens.wordpress.com/?p=863#comment-33696</guid>
		<description>Thanks!  &quot;If it can&#039;t be done on the command-line, it isn&#039;t worth doing&quot; is my motto... or something like that. ;-)

FYI if anybody tries to copy/paste: the smart quotes from WordPress will likely get in the way.  

Also, my method is certainly not the recommended way to actually learn from the challenge.  Dump into a shellcode wrapper or debugger for maximum enjoyment.</description>
		<content:encoded><![CDATA[<p>Thanks!  &#8220;If it can&#8217;t be done on the command-line, it isn&#8217;t worth doing&#8221; is my motto&#8230; or something like that. <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>FYI if anybody tries to copy/paste: the smart quotes from WordPress will likely get in the way.  </p>
<p>Also, my method is certainly not the recommended way to actually learn from the challenge.  Dump into a shellcode wrapper or debugger for maximum enjoyment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Didier Stevens</title>
		<link>http://blog.didierstevens.com/2008/11/09/picture-puzzle/#comment-33692</link>
		<dc:creator>Didier Stevens</dc:creator>
		<pubDate>Mon, 10 Nov 2008 13:10:21 +0000</pubDate>
		<guid isPermaLink="false">http://didierstevens.wordpress.com/?p=863#comment-33692</guid>
		<description>Nice command-line skills Jordan!</description>
		<content:encoded><![CDATA[<p>Nice command-line skills Jordan!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jordan</title>
		<link>http://blog.didierstevens.com/2008/11/09/picture-puzzle/#comment-33691</link>
		<dc:creator>Jordan</dc:creator>
		<pubDate>Mon, 10 Nov 2008 12:57:21 +0000</pubDate>
		<guid isPermaLink="false">http://didierstevens.wordpress.com/?p=863#comment-33691</guid>
		<description>Too late for a prize, I know, but my static method to find the answer without doing a whole lot of disassembly work:

Look through file, observe some shellcode sequences, dump the whole thing straight into ndisasm:

ndisasm -u picture-puzzle.bmp

Notice all the bytes being directly written to a local, so grep out the interesting bytes:

dd if=picture-puzzle.bmp bs=1 2&gt;/dev/null&#124;ndisasm -u -&#124;grep &#039;mov byte&#039;&#124;sed &#039;s/[^,]*,0/\\/g&#039;&#124;tr -d &#039;\n&#039;

Run through printf after changing null bytes to newlines:

printf &#039;\x55\x72\x79\x79\x62\x20\x73\x65\x62\x7a\x20\x4f\x5a\x43\x20\x66\x75\x72\x79\x79\x70\x62\x71\x72\x21\x0a\x75\x73\x65\x72\x33\x32\x0a\x4d\x65\x73\x73\x61\x67\x65\x42\x6f\x78\x41\x0a&#039;

Uryyb sebz OZC furyypbqr!
user32
MessageBoxA

Looks like alphabetic substitution on the interesting string, notice no obvious operations in the shellcode to deobfuscate it, take a wild shot on rot13, get lucky, and done.</description>
		<content:encoded><![CDATA[<p>Too late for a prize, I know, but my static method to find the answer without doing a whole lot of disassembly work:</p>
<p>Look through file, observe some shellcode sequences, dump the whole thing straight into ndisasm:</p>
<p>ndisasm -u picture-puzzle.bmp</p>
<p>Notice all the bytes being directly written to a local, so grep out the interesting bytes:</p>
<p>dd if=picture-puzzle.bmp bs=1 2&gt;/dev/null|ndisasm -u -|grep &#8216;mov byte&#8217;|sed &#8217;s/[^,]*,0/\\/g&#8217;|tr -d &#8216;\n&#8217;</p>
<p>Run through printf after changing null bytes to newlines:</p>
<p>printf &#8216;\x55\x72\x79\x79\x62\x20\x73\x65\x62\x7a\x20\x4f\x5a\x43\x20\x66\x75\x72\x79\x79\x70\x62\x71\x72\x21\x0a\x75\x73\x65\x72\x33\x32\x0a\x4d\x65\x73\x73\x61\x67\x65\x42\x6f\x78\x41\x0a&#8217;</p>
<p>Uryyb sebz OZC furyypbqr!<br />
user32<br />
MessageBoxA</p>
<p>Looks like alphabetic substitution on the interesting string, notice no obvious operations in the shellcode to deobfuscate it, take a wild shot on rot13, get lucky, and done.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Didier Stevens</title>
		<link>http://blog.didierstevens.com/2008/11/09/picture-puzzle/#comment-33690</link>
		<dc:creator>Didier Stevens</dc:creator>
		<pubDate>Sun, 09 Nov 2008 22:30:56 +0000</pubDate>
		<guid isPermaLink="false">http://didierstevens.wordpress.com/?p=863#comment-33690</guid>
		<description>Correct! Static or dynamic analysis?</description>
		<content:encoded><![CDATA[<p>Correct! Static or dynamic analysis?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ostracon</title>
		<link>http://blog.didierstevens.com/2008/11/09/picture-puzzle/#comment-33689</link>
		<dc:creator>Ostracon</dc:creator>
		<pubDate>Sun, 09 Nov 2008 22:25:57 +0000</pubDate>
		<guid isPermaLink="false">http://didierstevens.wordpress.com/?p=863#comment-33689</guid>
		<description>The message is: &quot;Hello from BMP shellcode!&quot;</description>
		<content:encoded><![CDATA[<p>The message is: &#8220;Hello from BMP shellcode!&#8221;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
