<?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/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
>

<channel>
	<title>ISIS &#187; Crypto</title>
	<atom:link href="http://isisblogs.poly.edu/category/crypto/feed/" rel="self" type="application/rss+xml" />
	<link>http://isisblogs.poly.edu</link>
	<description>Information Systems and Internet Security</description>
	<lastBuildDate>Mon, 20 Oct 2008 17:57:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<creativeCommons:license>http://creativecommons.org/licenses/by/3.0/us/</creativeCommons:license>
		<item>
		<title>F-Secure Khallenge Level 1</title>
		<link>http://isisblogs.poly.edu/2008/08/15/f-secure-khallenge-level-1/</link>
		<comments>http://isisblogs.poly.edu/2008/08/15/f-secure-khallenge-level-1/#comments</comments>
		<pubDate>Fri, 15 Aug 2008 05:18:21 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Crypto]]></category>
		<category><![CDATA[Reverse Engineering]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://isisblogs.poly.edu/?p=165</guid>
		<description><![CDATA[Thanks to Aleksey and Phn1x for dealing with my constant stream of questions while reversing this. You&#8217;d think it was the first time I opened a debugger!
The level 1 challenge was a binary that asked for input and, if your input was correct, printed out an e-mail address you could use to get the level [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to Aleksey and <a href="http://hamsterswheel.com/techblog/?p=128">Phn1x</a> for dealing with my constant stream of questions while reversing this. You&#8217;d think it was the first time I opened a debugger!</p>
<p>The level 1 <a href="http://www.f-secure.com/security_center/asm.html">challenge</a> was a binary that asked for input and, if your input was correct, printed out an e-mail address you could use to get the level 2 binary. The Khallenge is a contest of speed, so the first person to get to and beat level 3 wins. Unfortunately, I solved level 1 after the contest ended and the level 2 and 3 binaries aren&#8217;t online yet, so no prizes and no info on those.</p>
<p><span id="more-165"></span></p>
<p>The first thing I did was open the binary is a disassembler and try to get a general feel for it. This would help me develop an attack strategy. In IDA, you can easily identify that your input is being XOR&#8217;d almost a dozen times and with a global variable somewhere. It quickly overwhelmed me, so I took out a pen and paper and started writing things down. I also had lots of problems identifying exact addresses and byte offsets in IDA (I haven&#8217;t used it much before), so I switched to <a href="http://www.immunitysec.com/products-immdbg.shtml">Immunity Debugger</a> at this point.</p>
<p>The first set of instructions your input needs to pass through are at addresses<br />
69001081 to 6900108F, and it turns out they are a compiler-optimized strlen function. Pseudocode for these addresses looks like this:</p>
<pre>if(strlen(input) != 4)
    fail();
else
    ...</pre>
<p><a href="http://isisblogs.poly.edu/wp-content/uploads/fsecure-strlen.png" rel="lightbox[165]"><img src="http://isisblogs.poly.edu/wp-content/uploads/fsecure-strlen-300x62.png" alt="compiler-optimized strlen" title="fsecure-strlen" width="300" height="62" class="size-medium wp-image-168" /></a></p>
<p>The XORs start immediately after this check. After staring at it for a while, you will figure out that your input is being used as a key to decrypt a global variable located at 0&#215;690030D0. This global variable becomes the answer e-mail. I wrote out the encrypted e-mail in a column and mapped the XOR&#8217;d input bytes to it. Here is that table (encompasses addresses 69001095 to 690010F6):</p>
<pre>e-mail @ 0x690030D4		input @ 69003100
e-mail[0]: 0x07		XOR	input[0]
e-mail[1]: 0x2E		XOR	input[1]
e-mail[2]: 0x35		XOR	input[2]
e-mail[3]: 0x29		XOR	input[3]
e-mail[4]: 0x70		XOR	input[0]
e-mail[5]: 0x20		XOR	input[1]
e-mail[6]: 0x76		XOR	input[2]
e-mail[7]: 0x68		XOR	input[3]</pre>
<p><a href="http://isisblogs.poly.edu/wp-content/uploads/fsecure-xors.png" rel="lightbox[165]"><img src="http://isisblogs.poly.edu/wp-content/uploads/fsecure-xors-300x80.png" alt="obfuscated XORs" title="fsecure-xors" width="300" height="80" class="size-medium wp-image-169" /></a></p>
<p>After all the XOR&#8217;s, the application starts to check the final values of 4 select bytes in the e-mail buffer.</p>
<pre>e-mail[4]: 0x70		XOR	input[0] == 0x32
e-mail[1]: 0x2E		XOR	input[1] == 0x61
e-mail[6]: 0x76		XOR	input[2] == 0x30
e-mail[3]: 0x29		XOR	input[3] == 0x79</pre>
<p><a href="http://isisblogs.poly.edu/wp-content/uploads/fsecure-compares.png" rel="lightbox[165]"><img src="http://isisblogs.poly.edu/wp-content/uploads/fsecure-compares-300x66.png" alt="The compares that give it away" title="fsecure-compares" width="300" height="66" class="size-medium wp-image-170" /></a></p>
<p>If you do the XOR in reverse, you can find out the input they are looking for:</p>
<pre>0x70	XOR	0x32 = input[0] = 0x42 = B
0x2E	XOR	0x61 = input[1] = 0x4F = O
0x76	XOR	0x30 = input[2] = 0x46 = F
0x29	XOR	0x79 = input[3] = 0x50 = P</pre>
<p>Run the executable, put BOFP into the prompt, all the XORs happen, all the checks pass, and the e-mail buffer decrypts to &#8220;Easy2o08.&#8221; Done!</p>
<p><a href="http://isisblogs.poly.edu/wp-content/uploads/f-secure_khallenge1_running.png" rel="lightbox[165]"><img src="http://isisblogs.poly.edu/wp-content/uploads/f-secure_khallenge1_running-300x262.png" alt="the completed khallenge" title="f-secure_khallenge1_running" width="300" height="262" class="size-medium wp-image-172" /></a></p>
<p>Thanks again Aleksey and Phn1x!</p>
]]></content:encoded>
			<wfw:commentRss>http://isisblogs.poly.edu/2008/08/15/f-secure-khallenge-level-1/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by/3.0/us/</creativeCommons:license>
	</item>
		<item>
		<title>Countermeasures to Cold Booting Attacks</title>
		<link>http://isisblogs.poly.edu/2008/02/23/countermeasures-to-cold-booting-attacks/</link>
		<comments>http://isisblogs.poly.edu/2008/02/23/countermeasures-to-cold-booting-attacks/#comments</comments>
		<pubDate>Sun, 24 Feb 2008 00:24:21 +0000</pubDate>
		<dc:creator>dan</dc:creator>
				<category><![CDATA[Crypto]]></category>
		<category><![CDATA[Forensics]]></category>
		<category><![CDATA[Physical Security]]></category>

		<guid isPermaLink="false">http://isisblogs.poly.edu/2008/02/23/countermeasures-to-cold-booting-attacks/</guid>
		<description><![CDATA[There&#8217;s been a bit of a back and forth discussion on one of our mailing lists regarding Ed Felten&#8217;s recent cold-booting attacks on software FDE (BitLocker, FileVault, dm-crypt etc.). I thought it might be worthwhile to collect some of the potential software-only modifications that would protect against his attacks.
 First though, a [paraphrased] summary of [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s been a bit of a back and forth discussion on one of our <a href="https://isis.poly.edu/mailman/listinfo/infosec">mailing lists</a> regarding <a href="http://www.freedom-to-tinker.com/?p=1257">Ed Felten&#8217;s</a> <a href="http://www.youtube.com/watch?v=JDaicPIgn9U">recent</a> <a href="http://blog.wired.com/27bstroke6/2008/02/researchers-dis.html">cold-booting</a> <a href="http://www.schneier.com/blog/archives/2008/02/cold_boot_attac.html">attacks</a> on software FDE (BitLocker, FileVault, dm-crypt etc.). I thought it might be worthwhile to collect some of the potential software-only modifications that would protect against his attacks.</p>
<p><span id="more-61"></span> First though, a [paraphrased] summary of the discussion thus far:</p>
<blockquote><p><em>Dan F</em>: Why not extend the ISA of the CPU to offload crypto operations to an ASIC or a special part of the CPU? To avoid slowing down the CPU you&#8217;d need to widen the issue and decode/dispatch or add another word if it&#8217;s VLIW. Op fusion might come to your rescue in a future ISA, too.</p></blockquote>
<blockquote><p> <em>Mike P</em>: Good thing MacBooks get nice and hot <img src='http://isisblogs.poly.edu/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> . Why not add a register for the encryption key that gets wiped with the last bit of power in the CPU?</p></blockquote>
<blockquote><p> <em>Me</em>: Can&#8217;t we just encrypt all of RAM too? Lots of consumer computers have TPMs with crypto-coprocessors already. Wait a minute, we&#8217;d need to shove one on the same bus as the RAM and CPU and where would we store <em>those</em> keys? D&#8217;oh! Oh and Dan F, <a href="http://www.news.com/IBM-bakes-security-into-processors/2100-7355_3-6059276.html">IBM beat you to it</a>.</p></blockquote>
<blockquote><p><em>Dan F</em>: I wonder what affect this has on power consumption and overall throughput?</p></blockquote>
<p>Computer forensics people have been getting physical memory dumps for years and what about malicious root-owned processes? The threat has always been there. Hasn&#8217;t <em>anyone</em> been aware of the threats and developed <em>any</em> countermeasures?</p>
<p>I picked up the <a href="http://www.oreilly.com/catalog/secureprgckbk/">Secure Programming Cookbook</a> to look for answers. Here are excerpts from recipes I found that might be applicable to this debate. Since Ed&#8217;s code reads through memory and tries to pick out things that looks like keys, maybe you can obfuscate them to look like something else?</p>
<p><em>DISCLAIMER: I&#8217;ve never dumped the contents of memory and inspected it, I&#8217;ve never written crypto that handled keys securely, I didn&#8217;t test any of these countermeasures, and so on. This is all baseless conjecture.</em></p>
<blockquote><p>Recipe 4.13 &#8211; Managing Key Material Securely<br />
Securely erase keys are soon as you have finished using them. Use the spc_memzero function from Recipe 13.2 or SecureZeroMemory() if you&#8217;re using a new version of Windows.</p></blockquote>
<blockquote><p>Recipe 12.4 &#8211; Performing Bit and Byte Obfuscation<br />
Use the <a href="http://echelon.pl/pubs/">Obcode library</a> by Pawel Krawcykz. The size of variables are inflated eightfold and the library provides many standard byte and integer operations.</p></blockquote>
<blockquote><p>Recipe 12.6 &#8211; Merging Scalar Variables<br />
Problem: Scalar variables with constant or initialized values disclose information about ranges of values.<br />
Solution: Merge multiple scalar values into a single, larger scalar value to make simple, unrelated values appear to be a large value or bitfield.</p></blockquote>
<blockquote><p>Recipe 12.7 &#8211; Splitting Variables<br />
Problem: Large scalar variables that cannot be merged, or that have large values that cannot easily be manipulated with a constant transform, need to be obfuscated.<br />
Solution: You&#8217;ll have to buy the book, I can&#8217;t explain it <img src='http://isisblogs.poly.edu/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p></blockquote>
<blockquote><p>Recipe 12.10 &#8211; Restructuring Arrays</p>
<ul>
<li>Split a one-dimensional array into multiple one-dimensional arrays</li>
<li>Fold a one-dimensional array into a multi-dimensional array</li>
<li>Flatten a multi-dimensional array into a single one-dimensional array</li>
<li>Merge two one-dimensional arrays into a single one-dimensional array</li>
</ul>
</blockquote>
<blockquote><p>Recipe 12.11 &#8211; Hiding Strings<br />
See the book</p></blockquote>
<p>I also read through all of the comments on <a href="http://www.freedom-to-tinker.com/">Freedom to Tinker</a> to look for potential solutions and bring them to light. Here are some of the more interesting comments I found:</p>
<blockquote><p><a href="http://www.freedom-to-tinker.com/?p=1257#comment-382112">Will Michaels said</a>, &#8220;Full Disk Encrypting (FDE) hard drives perform the encryption in hardware directly on the hard drive, using a key that never leaves the drive. Such FDE drives are protected against this attack on off-drive encryption.&#8221;</p></blockquote>
<blockquote><p><a href="http://www.freedom-to-tinker.com/?p=1257#comment-382125">Laszlo Hars said</a>, &#8220;&#8230;However, it has been recommended for ages that encryption keys are never stored in RAM. They have to stay in a locked part of the processor cache. It was not because of the chilled-RAM effects, but because of virtual memory (swap file), or hibernation. The OS might write any info from RAM to disk, where an attacker can find it later. It is surprising that BitLocker does not follow this practice. TrueCrypt is known to be weak both in the choice of algorithms and their implementation (an example is their recent choice to implement the IEEE P1619 encryption standard meant for completely different type of applications)&#8230;.&#8221;</p></blockquote>
<blockquote><p><a href="http://www.freedom-to-tinker.com/?p=1257#comment-382130">Brad Templeton said</a>, &#8220;Sorry, Ed, Iâ€™ve been hearing about this technique since the 90s. Itâ€™s not new. Rumor is that spooks have been using it for some time. Hereâ€™s an <a href="http://www.madisonlinux.org/pipermail/madlug/2003-October/007264.html">old message board thread</a> a quick Google search found.</p></blockquote>
<blockquote><p><a href="http://www.freedom-to-tinker.com/?p=1257#comment-382138">Laszlo Hars said</a>, &#8220;The real issue revealed by the paper is not weaknesses in disk encryption software, but a cheap way to go around DRM, and code privacy. You run the protected code, like a DVD player or a game in one PC, freeze and move the RAM to another machine (can be the same one rebooted to DOS), where you can analyze the memory at your leisure. You can disassemble protected code, find media keys, etc. It is simpler and cheaper than using high speed, logic analyzers on memory lines.&#8221;</p></blockquote>
<blockquote><p><a href="http://www.freedom-to-tinker.com/?p=1257#comment-382153">Justin Wells said</a>, &#8220;&#8230;Even were the disk encryption key problem resolved somehow the attacker could still use this technique to recover data the user had thought was secure. Recovering the key simply allows the attacker to recover ALL the data, rather than only the data in RAM&#8230;.&#8221;</p>
<p>and, &#8220;The â€œkey stored in CPUâ€ used to encrypt RAM, or used to encrypt the disk key stored in RAM, need be nothing more than some randomized values in a few registers that are then preserved. All access to the encrypted data would then make use of the randomized values. The randomized memory encryption key stored in the CPU can be recreated on every boot of the systemâ€“there is no need to preserve it over time. Its purpose is simply to make memory unreadable.&#8221;</p></blockquote>
<blockquote><p><a href="http://www.freedom-to-tinker.com/?p=1257#comment-382186">Christopher said</a>, &#8220;Youâ€™re right, some common platforms use a hardware assist to look in the page tables. IA-64 can turn off hardware assistance, so that a TLB miss raises an exception rather than turning to the page table-handling hardware, but the vanilla IA-32 needs its page tables loaded in memory, and as you point out, the TLB isnâ€™t designed for recovering values stored in it.</p>
<p>Of course, if weâ€™re talking about IA-64 or x86_64, weâ€™ve got a lot of registers available to us, we might be able to hold four of them aside with a modified compiler, but that also assumes you can ensure these registers wonâ€™t get pushed to the stack on an interrupt request, or cleared by a context change.</p>
<p>OK, registers, TLB, cache. Is there anywhere else a person can find 256 bits of volatile storage on the die of a modern CPU? Hardware performance counters? You can read those, but I donâ€™t know if you can write them, or turn off their updating.</p></blockquote>
<blockquote><p><a href="http://www.freedom-to-tinker.com/?p=1257#comment-382244">Anonymous pointed out</a>, &#8220;I saw something similar to this presented at Black Hat DC last year. Except they were semantically rebuilding the memory image to extract the TrueCrypt keys. <a href="http://www.blackhat.com/presentations/bh-dc-07/Walters/Paper/bh-dc-07-Walters-WP.pdf">link</a>&#8220;</p></blockquote>
<blockquote><p><a href="http://www.freedom-to-tinker.com/?p=1257#comment-382251">Todd said</a>, &#8220;&#8230;Also no one has mentioned graphics card memory! OUCH! While there may not be tons of useful data there, it is conceivable that a illegitimate user could cull the image(s) of recent used documents&#8230;.&#8221;</p></blockquote>
<blockquote><p><a href="http://www.freedom-to-tinker.com/?p=1257#comment-382256">Andreas said</a>, &#8220;Some processor architectures, like the SPARC architecture for example, provide general registers that are not saved onto the stack (e.g. %g1 to %g7 in case of SPARC) and support multiple register sets, including one exclusively for the operating system. On these architectures it would be feasible to keep the key permantly in registers which would never be copied into memory.&#8221;</p></blockquote>
<blockquote><p><a href="http://www.freedom-to-tinker.com/?p=1257#comment-382332">Richard L. Enison claimed</a> to have <a href="http://www.google.com/patents?vid=USPAT4262329">a patent</a> on storing encryption keys in hardware. sigh.</p></blockquote>
<p>You&#8217;re welcome for reading that entire thread for you, and yes, this is how I spend my weekends.</p>
<p>EDIT: I saw that <a href="http://rdist.root.org/2008/02/24/memory-remanence-attack-analysis/">Nate Lawson</a> of <a href="http://www.rootlabs.com/">Root Labs</a> entered the discussion today with a post on his blog. He seems to agree with Dan F that adding crypto the processor is the best long term solution <img src='http://isisblogs.poly.edu/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  but he also suggests things FDE developers can do in the meantime.</p>
]]></content:encoded>
			<wfw:commentRss>http://isisblogs.poly.edu/2008/02/23/countermeasures-to-cold-booting-attacks/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	<creativeCommons:license>http://creativecommons.org/licenses/by/3.0/us/</creativeCommons:license>
	</item>
	</channel>
</rss>
