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

<channel>
	<title>AwghBlog &#187; awgh</title>
	<atom:link href="http://www.awgh.org/archives/author/awgh/feed" rel="self" type="application/rss+xml" />
	<link>http://www.awgh.org</link>
	<description>Shaking Your Tree</description>
	<lastBuildDate>Sun, 04 Dec 2011 06:30:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Geolocation of IP addresses using GeoIP and Google Maps</title>
		<link>http://www.awgh.org/archives/276</link>
		<comments>http://www.awgh.org/archives/276#comments</comments>
		<pubDate>Fri, 22 Oct 2010 23:44:32 +0000</pubDate>
		<dc:creator>awgh</dc:creator>
				<category><![CDATA[Fun]]></category>
		<category><![CDATA[attachment]]></category>
		<category><![CDATA[geoip]]></category>
		<category><![CDATA[geolocation]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[google earth]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[ip address]]></category>
		<category><![CDATA[maxmind]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.awgh.org/?p=276</guid>
		<description><![CDATA[People mean totally different things when they use the word &#8220;hack&#8221;. To me, hacking is what Dr. Frankenstein did just before he created his monster. Today&#8217;s creation will glue a few parts together to make a web site that will show the geographical location of an IP address on Google Maps.  This script also lets [...]]]></description>
			<content:encoded><![CDATA[<p>People mean totally different things when they use the word &#8220;hack&#8221;.</p>
<p>To me, hacking is what Dr. Frankenstein did just before he created his monster.</p>
<p>Today&#8217;s creation will glue a few parts together to make a web site that will show the geographical location of an IP address on Google Maps.  This script also lets the user look up the geolocation by DNS hostname.</p>
<p>The advantage of my approach over some others on the net is that this method is totally free and requires no API key.  I&#8217;ve also made it portable to shared hosting sites, and it will run just as easily on Linux, OSX or Windows web servers.</p>
<div id="attachment_275" class="wp-caption alignnone" style="width: 310px"><a href="http://www.awgh.org/wp-content/uploads/2010/10/iplocate-screen1.png"><img class="size-medium wp-image-275" title="iplocate.php screenshot" src="http://www.awgh.org/wp-content/uploads/2010/10/iplocate-screen1-300x196.png" alt="" width="300" height="196" /></a><p class="wp-caption-text">Screenshot of iplocate.php in action</p></div>
<p>First, an ingredients list:</p>
<ol>
<li>A web server or web hosting site that supports PHP.</li>
<li>A copy of the latest version of MaxMind&#8217;s GeoIP City database, which provides the mappings from IP to map coordinates in latitude and longitude.  You can download the <a title="latest free version here" href="http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz" target="_blank">latest free version here</a>.</li>
<li>The scripts require two PEAR modules:  Net_DNS and Net_GeoIP.  If you are running this on your own server, just use &#8216;pear install Net_DNS Net_GeoIP&#8217;.  If you are on Dreamhost, you can follow the <a href="http://www.yinfor.com/blog/archives/2008/04/how_to_install_pear_on_dreamho.html" target="_blank">awesome instructions on David Yin&#8217;s blog</a> to get Pear installed first.</li>
</ol>
<p>Once you have everything ready, all you need to do is download <a href="http://www.awgh.org/files/iplocate.php.txt" target="_blank">this PHP script</a>, and customize it in a few places:</p>
<ol>
<li>If you are on Dreamhost, and you had to install Pear in your home directory, uncomment the Dreamhost section at the top of the file (and replace the path with the real path to the &#8220;php&#8221; subdirectory of your Pear installation.  If you followed David Yin&#8217;s instructions above, the path will be:<br />
<code>/home/USERNAME/pear/php</code></li>
<li>Replace the fake path on this line:<br />
<code>$geoip = Net_GeoIP::getInstance("/FIX-THIS-PATH/GeoLiteCity.dat");</code><br />
with the real path to your GeoIP City database file.</li>
<li>Replace the fake IP addresses on this line:<br />
<code>$resolver-&gt;nameservers = array('YOUR.FIRST.DNS.HERE','YOUR.SECOND.DNS.HERE','YOUR.THIRD.DNS.HERE');</code><br />
with the real DNS servers that you want to use for looking up hostnames.</li>
<li>Finally, copy the edited file into the documents folder of your web server (make sure that it has a .php extension) and point your browser at it!</li>
</ol>
<p>You should now be able to enter an IP address or a hostname and have it pull up a Google Map of the correct coordinates!  If the hostname lookups don&#8217;t work off the bat, double-check step 2 above and try uncommenting the two DNS debugging lines in the PHP file.  Remember to give it DNS servers relative to your web server.</p>
<p>At this point, you might be wondering why I&#8217;m posting the PHP code instead of simply hosting this page myself.  Turns out that Maxmind&#8217;s license for the free GeoIP database forbids you from providing a publicly-available interface that allows translating IP addresses into coordinates.  The only way to do this (legally) using the free database is to either run this on an internal web server (not accessible to the public) or to password-protect the page using .htaccess files.</p>
<p>Obviously, this could be easily extended to add some stuff like plotting multiple different records from the DNS queries instead of just the first hit.  Another idea is to make it spit out KML so that it would just magically work with Google Earth as well.  I will leave that to you (or perhaps to some kindly strangers down in the comments).</p>
<p>Also, the hostname lookup feature reveals something interesting when you use it on edge-cached domains or clouds, but I&#8217;ll leave that for the home experimenter to explore.</p>
<p>&#8230; It <em>lives</em>, my creation <strong>LIVES</strong>&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.awgh.org/archives/276/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Jabbercracky: A Hash Cracking Web Service</title>
		<link>http://www.awgh.org/archives/253</link>
		<comments>http://www.awgh.org/archives/253#comments</comments>
		<pubDate>Sun, 01 Aug 2010 06:43:28 +0000</pubDate>
		<dc:creator>awgh</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[cracking]]></category>
		<category><![CDATA[cuda]]></category>
		<category><![CDATA[gpu]]></category>
		<category><![CDATA[halflm]]></category>
		<category><![CDATA[hash]]></category>
		<category><![CDATA[lm]]></category>
		<category><![CDATA[md5]]></category>
		<category><![CDATA[ntlm]]></category>
		<category><![CDATA[nvidia]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[rcrack]]></category>
		<category><![CDATA[rcracki_mt]]></category>
		<category><![CDATA[web service]]></category>

		<guid isPermaLink="false">http://www.awgh.org/archives/253</guid>
		<description><![CDATA[It is with great pleasure that today I announce the first release of Jabbercracky, the hash-cracking web service.  MD5, NTLM, LM, and HalfLM are currently fully supported.  Jabbercracky will only work on Linux/Posix systems. Jabbercracky makes use of a two-pass hash cracking method.  In the first pass, the submitted hash is tried against a local [...]]]></description>
			<content:encoded><![CDATA[<p>It is with great pleasure that today I announce the first release of Jabbercracky, the hash-cracking web service.  MD5, NTLM, LM, and HalfLM are currently fully supported.  Jabbercracky will only work on Linux/Posix systems.</p>
<p>Jabbercracky makes use of a two-pass hash cracking method.  In the first pass, the submitted hash is tried against a local collection of rainbow tables.  In the second pass, the hash is passed along to a Cuda-compatable GPU for brute-forcing.</p>
<p>I’ve been hosting a Jabbercracky server with a large collection of rainbow tables on <a href="http://wiki.hamburg.ccc.de/index.php/ChaosVPN" target="_blank">ChaosVPN</a> since January, and I’ve recently done a bit of work packaging it as a Python module, so you can host your own cracking service with your own collection of rainbow tables!</p>
<p><a href="http://www.awgh.org/wp-content/uploads/2010/07/jabbercrackyscreenshot.png"><img style="display: inline; border: 0px;" title="jabbercracky-screenshot" src="http://www.awgh.org/wp-content/uploads/2010/07/jabbercrackyscreenshot_thumb.png" border="0" alt="jabbercracky-screenshot" width="443" height="311" /></a></p>
<p>On ChaosVPN, the service is available at: <a href="http://hash.colab.hack">http://hash.colab.hack</a> or <a href="http://10.100.23.1">http://10.100.23.1</a></p>
<p>The Jabbercracky module is currently being hosted on the <a href="http://pypi.python.org/pypi/jabbercracky/0.1.0" target="_blank">Python Package Index</a>, so all you need to do to install is:</p>
<p>1) easy_install jabbercracky</p>
<p>2) Go to the jabbercracky egg directory in site-packages and follow the installation instructions in INSTALL.txt</p>
<p>In future versions, Jabbercracky will live up to its name and also provide an XMPP-based interface, so you can crack hashes on your beefy hardware at home from the comfort of your mobile phone!</p>
<p>If you have any interest in participating in the development of Jabbercracky, please drop me a line!</p>
<p>Greetings to mc.fly and ryd and Defcon 18!</p>
<p>- awgh</p>
]]></content:encoded>
			<wfw:commentRss>http://www.awgh.org/archives/253/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>How To Connect a PS/2 Keyboard to the iPhone</title>
		<link>http://www.awgh.org/archives/154</link>
		<comments>http://www.awgh.org/archives/154#comments</comments>
		<pubDate>Tue, 13 Oct 2009 10:44:11 +0000</pubDate>
		<dc:creator>awgh</dc:creator>
				<category><![CDATA[Fun]]></category>
		<category><![CDATA[Hardware Hacks]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[attachment]]></category>
		<category><![CDATA[efi]]></category>
		<category><![CDATA[elf conspiracy]]></category>
		<category><![CDATA[iphone keyboard]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[ps2]]></category>

		<guid isPermaLink="false">http://www.awgh.org/?p=154</guid>
		<description><![CDATA[Although I&#8217;ve seen many pictures of PS/2 keyboards plugged into iPhones on the Internet, no one has yet published a detailed howto on how to get this working yourself.  Until now, that is. In this article I will show you how you can make a PS/2 keyboard to iPhone converter, including all hardware and software [...]]]></description>
			<content:encoded><![CDATA[<p>Although I&#8217;ve seen many pictures of PS/2 keyboards plugged into iPhones on the Internet, no one has yet published a detailed howto on how to get this working yourself.  Until now, that is.</p>
<p>In this article I will show you how you can make a PS/2 keyboard to iPhone converter, including all hardware and software instructions.  As the bugs get worked out, or improvements are made, I&#8217;ll update this page.<span id="more-154"></span></p>
<h2><strong>Motivation: The Great Apple-Elf Conspiracy</strong></h2>
<p>After using an iPhone for a couple years, I have started to believe that the developers of the iPhone actually hate those of us with broad, round thumbs.  I can&#8217;t make very efficient use of the virtual keyboard, even in landscape, and they refuse to add real support for Bluetooth or really any external keyboards.  I have a friend with pointy little thumbs who can type like 36 wpm on the thing.  I&#8217;ve also noticed that of all the Apple employees I&#8217;ve actually met, they all seem to be relatively nimble and elf-like, with pointy little thumbs.  Coincidence?</p>
<div id="attachment_165" class="wp-caption alignnone" style="width: 310px"><a href="http://www.awgh.org/wp-content/uploads/2009/10/thumbs-800x600.jpg"><img class="size-medium wp-image-165" title="thumbs" src="http://www.awgh.org/wp-content/uploads/2009/10/thumbs-800x600-300x225.jpg" alt="My thumbs are round, which is apparently an afront to Steve Jobs and his nimble elven-fingered lackies." width="300" height="225" /></a><p class="wp-caption-text">My thumbs are round, which is apparently an afront to Steve Jobs and his nimble elven-fingered lackies.</p></div>
<p>Perhaps if Apple employed more broad-thumbed people, they wouldn&#8217;t be so stubborn about actively disallowing using external keyboards on the iPhone.</p>
<p>If you are wondering why someone would want to be typing quickly into an iPhone, I can say with great certainty that you are on the wrong web site. Unless you got here by searching for &#8220;Elf Conspiracy&#8221;, then you should email me.  Please include a picture of your thumbs for verification.</p>
<h1><strong>Prerequisites </strong></h1>
<ul>
<li>Jailbroken iPhone &#8211; The official SDK doesn&#8217;t allow access to the serial port due to the Elf Conspiracy, so the jailbreak is required.  All you need to know about jailbreaking is at the <a href="http://blog.iphone-dev.org/">iPhone Dev Team Blog</a>.</li>
<li><a href="http://www.arduino.cc/en/Main/ArduinoBoardDiecimila">Arduino Diecimila</a> or <a href="http://www.arduino.cc/en/Main/ArduinoBoardDuemilanove">Dumilanove</a><strong> </strong>(or clone), available from <a href="http://arduino.cc/en/Main/Buy">many places</a>.  This howto assumes that your Arduino is assembled.</li>
<li>An iPod Breakout board, like <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=8295">this one from Sparkfun</a>.  Any similar product will work.</li>
<li>A Female PS/2 (Din 6) Keyboard connector.  Pull one off an old computer or buy one from <a href="http://search.digikey.com/scripts/DkSearch/dksus.dll?lang=en&#038;site=us&#038;KeyWords=CP-2260-ND">Digikey</a> or similar vendor.</li>
<li>Wire, preferably several colors and about 24 gauge.  I&#8217;m using a spool from <a href="http://www.radioshack.com/product/index.jsp?productId=2062656">RadioShack</a> in the pics below.</li>
<li>One 500k Resistor.  I&#8217;m using an axial through-hole resistor from RadioShack, but you could add this to your Digikey order as well.</li>
<li>Soldering Iron and Solder.  If you don&#8217;t know how to solder, you can learn <a href="http://www.mediacollege.com/misc/solder/">here</a> and <a href="http://www.instructables.com/id/How-to-solder/">here</a>.</li>
<li>(Optional) Pin Headers, like <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=117">these</a>.  I break these off and solder them to the ends of wires, so that they plug nicely into the Arduino.</li>
<li>(Optional) Sweet 9v Battery harness so your Arduino becomes portable available from the <a href="http://www.makershed.com/ProductDetails.asp?ProductCode=MKSEEED4">Maker Store</a>.</li>
<li>(Optional) Stereo Headphone Jack from RadioShack or Digikey.</li>
</ul>
<h1><strong>Wiring Things Up</strong></h1>
<p>Once all your ingredients arrive, fire up the soldering iron and have a quick look at the <a href="http://pinouts.ru/PortableDevices/ipod_pinout.shtml">iPod Connector Pin-Out</a>.</p>
<p>We&#8217;ll be making use of four of these pins for the keyboard: 11, 13, 16 and 21.  The definition of pin 21 says we need to place a 500k resistor between pin 21 and ground to enable serial communications to the iPhone, so we&#8217;re going to stick a resistor between pin 21 and pin 16, which is the serial ground.  We&#8217;re also going to be adding pin headers to pins 11 and 13, which will act as the TX and RX pins for serial communications.  Since we&#8217;ll ONLY be sending to the iPhone, we only make use of the iPhone&#8217;s RX pin, so we&#8217;ll also be adding a piece of wire to connect pin 11, the unused TX pin,  directly to the ground at pin 16.</p>
<p>You can also optionally add the stero headphone jack to pins 2, 3 and 4 right now and it will work whenever the breakout is plugged in.  This has nothing to do with the keyboard, but if you have a 1G iPhone with the lame non-standard headphone jack, this will fix it.</p>
<div id="attachment_156" class="wp-caption alignnone" style="width: 310px"><a href="http://www.awgh.org/wp-content/uploads/2009/10/step1-800x600.jpg"><img class="size-medium wp-image-156" title="step1" src="http://www.awgh.org/wp-content/uploads/2009/10/step1-800x600-300x225.jpg" alt="iPhone Breakout Wiring - Front" width="300" height="225" /></a><p class="wp-caption-text">iPhone Breakout Wiring - Front</p></div>
<p>Here is the front of the fully wired-up breakout board.  Click on the image to have a closer look.</p>
<p>The backside is below.</p>
<div id="attachment_157" class="wp-caption alignnone" style="width: 310px"><a href="http://www.awgh.org/wp-content/uploads/2009/10/step2-800x600.jpg"><img class="size-medium wp-image-157" title="step2" src="http://www.awgh.org/wp-content/uploads/2009/10/step2-800x600-300x225.jpg" alt="iPhone Breakout Wiring - Back" width="300" height="225" /></a><p class="wp-caption-text">iPhone Breakout Wiring - Back</p></div>
<p>I&#8217;ve put the jumper between pin 11 and pin 16 on the back of the breakout board.  It can be a bit tricky to fit everything on to pin 16, so I recommend first sticking the resistor through the hole, then wrapping the end of the jumper wire around it and soldering them together before clipping off the resistor lead.</p>
<p>Another tactic which may be useful here is to first tin the ends of your wire, then blob a little solder on the hole you want to stick the wire to.  Use the side of the soldering iron to warm your blob of solder and the SLIDE the tinned end of the wire into the blob.  Remove the iron, let blob cool, then let go of wire.</p>
<div id="attachment_158" class="wp-caption alignnone" style="width: 310px"><a href="http://www.awgh.org/wp-content/uploads/2009/10/step3-800x600.jpg"><img class="size-medium wp-image-158" title="step3" src="http://www.awgh.org/wp-content/uploads/2009/10/step3-800x600-300x225.jpg" alt="PS/2 Connector Wiring - Front" width="300" height="225" /></a><p class="wp-caption-text">PS/2 Connector Wiring - Front</p></div>
<p>There is no path you can take through the pin numbering of the PS/2 Connector that makes any kind of sense outside the context of the deranged ramblings of a committee meeting.  Don&#8217;t think too hard about the pin numbers, just check out the picture above.</p>
<p>We&#8217;ll be making use of four pins here, and connecting all of them to the Arduino.  Ground will be wired to Ground on the Arduino, VCC will be wired to 5V, and the Data and Clock pins will be brought over to two of the Arduino&#8217;s digital pins (3 and 4).</p>
<div id="attachment_159" class="wp-caption alignnone" style="width: 310px"><a href="http://www.awgh.org/wp-content/uploads/2009/10/step4-800x600.jpg"><img class="size-medium wp-image-159" title="step4" src="http://www.awgh.org/wp-content/uploads/2009/10/step4-800x600-300x225.jpg" alt="PS/2 Connector Wiring - Bottom" width="300" height="225" /></a><p class="wp-caption-text">PS/2 Connector Wiring - Bottom</p></div>
<p>The bottom of the PS/2 Connector is even less intuitive than the numbering scheme.  I recommend checking this picture, but also verifying that the pins on the bottom of your connector match the numbered pins you think they do before soldering anything.  You can check for connectivity with a regular multimeter by setting it to measure resistance and connecting one probe to the pin on the bottom and sticking the other in the hole.  If there is any resistance at all, then that pin is connected to that hole.</p>
<p>I&#8217;m using the Green wire for the Clock pin, the Red wire for VCC, the White wire for Data, and the Black wire for ground.</p>
<p><a href="http://www.awgh.org/wp-content/uploads/2009/10/step5-800x600.jpg"><img class="alignnone size-medium wp-image-160" title="step5" src="http://www.awgh.org/wp-content/uploads/2009/10/step5-800x600-300x225.jpg" alt="step5" width="300" height="225" /></a></p>
<p>Once you&#8217;ve got the connectors wired up, strip the other ends of the wires and solder the leads to pin headers.  This will let you plug them in to the Arduino easily.  If you didn&#8217;t get the pin headers, you can try carefully tinning the wires to make them stay in the Arduino pin holes better.</p>
<p>I attached some wires to the pin headers on pins 11 and 13 of the iPhone breakout board.  The Black wire is to Ground (pin 11) and the Red wire is to VCC (pin 13).  I&#8217;ve then soldered pin headers to the leads for the two wires from the breakout board and the four coming from the PS/2 connector.</p>
<p><a href="http://www.awgh.org/wp-content/uploads/2009/10/step6-800x600.jpg"><img class="alignnone size-medium wp-image-161" title="step6" src="http://www.awgh.org/wp-content/uploads/2009/10/step6-800x600-300x225.jpg" alt="step6" width="300" height="225" /></a></p>
<p>I&#8217;m using an Arduino Diecimila, since this program doesn&#8217;t require a better chip.  This is shown with a 9V battery harness from SparkFun for portability.</p>
<div id="attachment_162" class="wp-caption alignnone" style="width: 310px"><a href="http://www.awgh.org/wp-content/uploads/2009/10/step7-800x600.jpg"><img class="size-medium wp-image-162" title="step7" src="http://www.awgh.org/wp-content/uploads/2009/10/step7-800x600-300x225.jpg" alt="Attach PS/2 leads to the Arduino." width="300" height="225" /></a><p class="wp-caption-text">Attach PS/2 leads to the Arduino.</p></div>
<p>Next, we connect the PS/2 Connector to the Arduino.  Connect the Clock wire to Digital Pin 3, the Data wire to Digital Pin 4, and connect the Ground wire to Ground on the Arduino and the VCC wire to the 5V pin.</p>
<div id="attachment_163" class="wp-caption alignnone" style="width: 310px"><a href="http://www.awgh.org/wp-content/uploads/2009/10/step8-800x600.jpg"><img class="size-medium wp-image-163" title="step8" src="http://www.awgh.org/wp-content/uploads/2009/10/step8-800x600-300x225.jpg" alt="Attach iPhone leads to the Arduino." width="300" height="225" /></a><p class="wp-caption-text">Attach iPhone leads to the Arduino.</p></div>
<p>To connect the iPhone breakout, simply connect the lead from Pin 13 to the TX Pin on the Arduino (Digital Pin 1) and then connect the lead from Pin 11 to any available Ground on the Arduino.</p>
<p><strong>IMPORTANT: </strong>To avoid trouble with flashing the Arduino, please disconnect the TX Pin on the Arduino before flashing.  More on this later.</p>
<div id="attachment_164" class="wp-caption alignnone" style="width: 310px"><a href="http://www.awgh.org/wp-content/uploads/2009/10/step9-800x600.jpg"><img class="size-medium wp-image-164" title="step9" src="http://www.awgh.org/wp-content/uploads/2009/10/step9-800x600-300x225.jpg" alt="Putting it all together." width="300" height="225" /></a><p class="wp-caption-text">Putting it all together.</p></div>
<p>After that, all the soldering is done.  Now it&#8217;s time to move on to programming the Arduino!</p>
<h1><strong>The Arduino Code</strong></h1>
<p>The Arduino software clocks data out of the keyboard, translates the keyboard scan codes to key codes, and handles presses of the shift and caps lock keys.</p>
<p>First off, download and install the Arduino development environment from <a href="http://arduino.cc/en/Main/Software">here</a>.  Follow the directions on the site, but be sure to install the appropriate FTDI driver from the drivers directory in the Arduino installation.</p>
<p>Next, you&#8217;ll need an additional Arduino library for PS/2.  Download the file &#8220;ps2.zip&#8221; from <a href="http://www.arduino.cc/playground/ComponentLib/Ps2mouse">this page</a>.  To install, unzip the download to a folder and move that folder to be a subdirectory of the &#8220;hardware/libraries&#8221; directory under your Arduino installation.  On OSX, you can go to Arduino.app and &#8220;Show Package Contents&#8221; first.</p>
<p>Once Arduino and the ps2 library are installed, download the source code from <a href="http://awgh.org/files/iPhonePS2.txt">here</a>.  Open the Arduino application, create a new project, and paste the source code into it.  Save, and then go to Sketch-&gt;Verify/Compile to make sure that it builds.  If it doesn&#8217;t, make sure the library is installed correctly.</p>
<p>On a side note, I actually wrote absolutely no code for this project.  I started out trying to use the <a href="http://www.arduino.cc/playground/Main/PS2KeyboardExt2">PS2KeyboardExt2 library</a>, but that library is based on interrupts and while it can run on an Arduino that is also speaking serial at 9600 bps, once I cranked the serial up to 19200 bps, the interrupts stopped working in a stable way.  So I yanked all of the nice code out of PS2KeyboardExt2, including the key definitions and the nice handling of shifts and caps lock and reworked it into a program that doesn&#8217;t use interrupts and makes use of a different, much simpler PS/2 library.  This makes it capable of handling 19200 bps serial in a reliable manner.</p>
<p>Now, to program the Arduino!</p>
<p>Disconnect the lead going to Pin 1 on the Arduino.  Then, connect the Arduino to your computer via USB cable.  You may need to restart the Arduino application so that it detects the new USB serial device correctly.  Load the saved sketch with <a href="http://awgh.org/files/iPhonePS2.txt">the source</a>, and then hit the Upload button to program the Arduino.</p>
<p>Once the program is uploaded, plug the keyboard into the PS/2 connector.  You should see the lights flash.  You can open up the Serial Monitor in the Arduino application and try typing some letters on the keyboard.  You should see those letters show up in the Serial Monitor.  Try turning the Caps Lock on and off, the light on the keyboard should go on and off and the characters should come out correctly capitalized.</p>
<h1><strong>The iPhone Client</strong></h1>
<p>Now to set up the iPhone client program.</p>
<p>For the client code, I&#8217;m using a program I found on <a href="http://code.google.com/p/ipod-tools/wiki/TouchClient">Anthony Pray&#8217;s Google Code page</a>.  This program reads input from the serial port at 19200 bps and then injects the appropriate keyboard event using a VNC client library.  I&#8217;ve made a local text-only mirror of the source <a href="http://awgh.org/files/TouchClient.c">here</a>, which can be easily fetched with wget.</p>
<p>Since we&#8217;ll be injecting keypresses by VNC, you&#8217;ll also need to be running a VNC Server on the iPhone.  We&#8217;re going to use <a href="http://www.tuaw.com/2008/09/18/veency-vnc-server-for-iphone/">Veency</a> (which is awesome and you should install anyway).</p>
<p>Go to Cydia or Icy and install the following packages:</p>
<ul>
<li> <strong>Veency </strong>- Provides the VNC Server, configure it to run at startup<strong> </strong></li>
<li><strong>LibVNCServer </strong>- Provides libvncclient</li>
<li><strong>iPhone 2.0 Toolchain </strong>- Provides a build environment (gcc, libgcc, ldid, libz are required if you go another route)</li>
<li><strong>MobileTerminal </strong>- So you can access the iPhone terminal</li>
<li><strong>wget </strong>- So you can pull down the source file</li>
</ul>
<p>Now to download and build the source.  Either open up MobileTerminal or SSH into your phone, and then do the following:</p>
<ul>
<li><strong><span style="font-family: monospace, 'Times New Roman', 'Bitstream Charter', Times, serif;">wget http://awgh.org/files/TouchClient.c</span></strong><span style="font-family: monospace, 'Times New Roman', 'Bitstream Charter', Times, serif;"><br />
</span></li>
<li><strong><span style="font-family: monospace, 'Times New Roman', 'Bitstream Charter', Times, serif;">gcc -static-libgcc -o TouchClient TouchClient.c -lvncclient </span></strong><span style="font-family: monospace, 'Times New Roman', 'Bitstream Charter', Times, serif;"><br />
</span></li>
<li><strong><span style="font-family: monospace, 'Times New Roman', 'Bitstream Charter', Times, serif;">ldid -S TouchClient</span></strong></li>
</ul>
<p>The last step, using ldid, fakes signing the binary.  Without it, the iPhone OS will kill your process immediately.</p>
<p>To start the program, run it from Mobile Terminal with:</p>
<p><strong>./TouchClient</strong></p>
<p>This will cause Veency to pop up a dialog asking if you want to accept the VNC connection.  Hit Accept.</p>
<p>I&#8217;ve noticed that running this from MobileTerminal keeps the program alive even when you leave MobileTerminal, but it would be better to use launchd.  I haven&#8217;t figured that out just yet.</p>
<p><strong>Finishing Touches and Future Work</strong></p>
<p>To finish up, reconnect the lead from Pin 13 on the iPhone breakout to the TX pin (pin 1) on the Arduino.  Disconnect the USB cable and switch the Arduino to external power.  Plug the iPhone breakout into your iPhone.</p>
<p>If:</p>
<ul>
<li>TouchClient is running on your iPhone</li>
<li>The PS2 software is running on your Arduino</li>
<li>The Keyboard is plugged into the connector, and the connector wired to the Arduino correctly</li>
<li>Veency is running and you have accepted the connection from TouchClient</li>
<li>Nothing else is screwed up</li>
</ul>
<p>You should be able to type on the PS/2 keyboard and have those keystrokes translated to the appropriate iPhone keystrokes.  This will work anywhere in the iPhone, in any app or native feature.</p>
<p>This solution isn&#8217;t perfect, but it&#8217;s a general-purpose approach to using the Arduino to add PS/2 keyboard support to almost anything that can read simple serial messages.</p>
<p>Future work:</p>
<ul>
<li>The scan code mapping could be moved entirely to the iPhone, and the hardware part of this project could be reimplemented on a much cheaper and lower power consumption chip, like a PIC.  This would reduce the cost of the unit by about $30, although it would require a PIC programmer.</li>
<li>Not all special keys are correctly mapped, but if you look in the Arduino code and then at the iPhone code, you&#8217;ll see that this is an incredibly simple process.  Please post any changes you make back here as a comment!</li>
<li>Rather than being a crazy wire hack, I&#8217;d like to see this fit into a snug little enclosure for real portability.  Any ideas in this department would be appreciated.</li>
<li>I would like to give TouchClient a password for Veency so that there isn&#8217;t that annoying Accept/Decline pop-up.</li>
<li>This exact method could be used to add a Bluetooth keyboard.  Simply add a Bluetooth-Serial module to the iPhone breakout and keep using TouchClient &amp; Veency.</li>
</ul>
<p>That&#8217;s it.  I hope you enjoyed the howto!  Looking forward to your comments.</p>
<p>Regards,</p>
<p>-awgh</p>
]]></content:encoded>
			<wfw:commentRss>http://www.awgh.org/archives/154/feed</wfw:commentRss>
		<slash:comments>44</slash:comments>
		</item>
		<item>
		<title>How To Win At Java Code Audit</title>
		<link>http://www.awgh.org/archives/4</link>
		<comments>http://www.awgh.org/archives/4#comments</comments>
		<pubDate>Mon, 02 Feb 2009 22:14:57 +0000</pubDate>
		<dc:creator>awgh</dc:creator>
				<category><![CDATA[Java Security]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[code audit]]></category>
		<category><![CDATA[exploit]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.awgh.org/?p=4</guid>
		<description><![CDATA[Reviewing Java source code can pose a challenge for a security auditor, as methods used to exploit programs in C or C++, namely memory corruption bugs, are mitigated by Java itself, which hides the details of memory management from the programmer.  This same tendency to hide implementation details with a layer of abstraction leads to [...]]]></description>
			<content:encoded><![CDATA[<p>Reviewing Java source code can pose a challenge for a security auditor, as methods used to exploit programs in C or C++, namely memory corruption bugs, are mitigated by Java itself, which hides the details of memory management from the programmer.  This same tendency to hide implementation details with a layer of abstraction leads to an entire class of common Java programming errors which can have a critical impact on the security of the application.</p>
<p>Java vulnerabilities are most commonly found in places where unsanitized user input is passed, directly or indirectly, on to an underlying library or service.  To put it another way, vulnerabilities aren&#8217;t found in the Java code itself, they are found by following user input through the Java source and out the other side.</p>
<p>The tendency of Java to hide implementation details from the developer actually creates these vulnerabilities in places where it might not otherwise exist.  Java developers use wrapper libraries for backend services, such as SQL or LDAP, and assume that they automatically sanitize their inputs, when usually they do not.  In most cases, Java wrapper libraries themselves are simply classes that store and manipulate strings which are just passed directly on to the wrapped service.  In many of these implementations, such as the ORM library Hibernate, there are architectural reasons why this behavior can not be changed.</p>
<p>In this post, I will describe a class of extremely common Java vulnerabilities, specifically these &#8220;pass-through&#8221; bugs, characterized by user input passing directly through Java unexamined.</p>
<p><span id="more-4"></span></p>
<p>For our first example, we&#8217;ll look at one of the most commonly used (and misused) constructs in the Java programming language:</p>
<p><strong>The File Class Constructor</strong></p>
<p>The File class has several constructors, but the most common takes a single string argument, which is the full path to a file.  The second most commonly used constructor takes two string arguments, which are effectively appended together and treated the same as the single string argument.</p>
<p>The Java documentation uses the word &#8216;Canonicalization&#8217; all over the place.  All paths fed in to the File constructor are canonicalized.  Many people understand this as &#8220;All the dot-dot-slashes are removed.&#8221;</p>
<p>While this is technically true, a canonicalized path has no path meta-characters, canonicalization doesn&#8217;t simply remove them &#8211; it resolves them correctly!</p>
<p>For example, the path &#8220;/www/hosts/mydomain.org/docs/../../../../etc/&#8221; would be &#8220;/etc/&#8221; after canonicalization.</p>
<p>This confusion over what canonicalization means commonly leads to directory traversal vulnerabilities in Java-based services.</p>
<p>Imagine a simple web server in Java, which does the following:</p>
<ol>
<li>Accept an HTTP request for a particular URL:  &#8220;http://www.mydomain.org/PATH&#8221;</li>
<li>Calls the File constructor with the web root and path:  File f = new File( &#8220;/www/hosts/mydomain.org/docs&#8221;, PATH );</li>
<li>Simply opens the file and returns it to the requester as an HTTP response.</li>
</ol>
<p>Perhaps the assumption is that somehow the File constructor filters out path meta-characters such as &#8220;../&#8221;, which it doesn&#8217;t.  Some developers assume that the first argument to the file constructor will somehow act like a chroot and prevent &#8220;../&#8221; in the second argument from traversing to a higher directory.  This is not the case, as both arguments are simply appended and treated as one big path string.</p>
<p>Whatever the developer assumptions, this error appears in different variations across a surprisingly large percentage of Java code.</p>
<p>This category of errors comes from the fact that Java can&#8217;t interact with the file system directly &#8211; it has to pass path information through to the operating system.  In fact, the specific path meta-characters that can lead to injection will vary from platform to platform &#8211; even though Java tries to be &#8220;platform independent&#8221;!  An obvious example:  &#8220;../&#8221; on a Linux system is the same as &#8220;..\&#8221; on Windows.</p>
<p>To find these errors, simply search for places where user-controlled input is passed directly in to the File class constructor, without any additional logic to remove path meta-characters such as &#8220;../&#8221; or &#8220;..\&#8221;.</p>
<p><!--more--></p>
<p>Our next example of a &#8220;pass-through&#8221; bug is in the use of a common Java logging library:</p>
<p><strong>Log4J Javascript Injection</strong></p>
<p>The most commonly used Java logging library is Log4J from Apache.  Log4J provides a number of different methods that write data to a log file,  for example:<br />
<code><br />
Logger log = Logger.getLogger("mylogger");<br />
log.error("This is an error message");<br />
log.warn("This is a warning message");<br />
log.debug("This is a debug message");</code></p>
<p>Log4J does not do any sanitization of strings passed in to it by the various logging methods, it simply takes the string it is given and writes this directly to the log file.</p>
<p>Most web applications that use Log4J will commonly include user-supplied values in at least some of their logging messages, for example:</p>
<p><code><br />
protected void doGet(HttpServletRequest request, HttpServletResponse response)<br />
throws ServletException, IOException<br />
{<br />
// do stuff, then on error something like:<br />
Logger logger = Logger.getLogger("GetLogger");<br />
logger.error( "Invalid value for parameter fnord: "+ request.getParameter("fnord"));<br />
}</code></p>
<p>This makes some kind of sense &#8211; an error condition has been caused by invalid input, so the developer wants to see what the bad input was.</p>
<p>Web developers are also in the habit of viewing their web application log files directly from the web server, sometimes they even include HTML formatting tags in with their calls to Log4J methods so that the logs will be formatted nicely in the browser.</p>
<p>Imagine the following common scenario:</p>
<ul>
<li>The production web server is on the domain <strong>http://somesite.com</strong> and the QA server is on <strong>http://qa.somesite.com</strong>.</li>
<li>Developers working on the QA server routinely view the Log4J logs through the browser by visiting <strong>http://qa.somesite.com/logs/mylog</strong>.</li>
<li>The subdomain <strong>www.somesite.com</strong> redirects to <strong>somesite.com</strong>, so all of the regular sites domain cookies are for <strong>somesite.com</strong>.</li>
</ul>
<p>Now we construct a standard Cross-Site Scripting cookie-stealing attack by injecting some Javascript into the &#8220;fnord&#8221; parameter mentioned above.  The program will then save this Javascript into the Log4J logs.</p>
<p>When the developer opens these logs in the browser, the Javascript will execute, and have access to the cookies for the domain <strong>qa.somesite.com</strong>.</p>
<p>However, the situation is much worse than this.  There is a <a href="https://developer.mozilla.org/En/Same_origin_policy_for_JavaScript">single exception</a> to the Same Origin Policy which happens to apply to this situation.</p>
<p>A Javascript can set its effective domain by manipulating the &#8220;document.domain&#8221; variable.  The exception to the Same Origin Policy says that a script can only set its domain to a suffix of its current domain.</p>
<p>This means that an attack script that runs from <strong>qa.somesite.com </strong>can reset its domain to <strong>somesite.com</strong>, and then access all of <strong>somesite.com</strong>&#8216;s cookies!</p>
<p>A successful log-file script injection on a QA, development, or staging server which is a subdomain can result in stealing saved credentials from developers for the main domain!</p>
<p>This category of attacks passes directly through Java into a log file, which is then loaded by a browser.</p>
<p>To find these types of errors, look for calls to Log4J or similar logging functions which include HTML formatting tags and/or unsanitized user input.</p>
<p><!--more--><strong></strong></p>
<p><strong>Stay tuned</strong> for the second exciting installment of &#8220;How to Win at Java Code Audit&#8221;, including LDAP injection, Null Byte Injection, and ORM injection!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.awgh.org/archives/4/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dehydra-GCC: Static Analysis for Poor People</title>
		<link>http://www.awgh.org/archives/73</link>
		<comments>http://www.awgh.org/archives/73#comments</comments>
		<pubDate>Thu, 25 Dec 2008 06:15:39 +0000</pubDate>
		<dc:creator>awgh</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[code audit]]></category>
		<category><![CDATA[computer security]]></category>
		<category><![CDATA[exploit]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[infosec]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[pen test]]></category>

		<guid isPermaLink="false">http://www.awgh.org/?p=73</guid>
		<description><![CDATA[Over the past few months, I&#8217;ve been playing with a new static analysis tool from Mozilla called Dehydra. Dehydra is a GCC plugin that allows you to write Javascript that can perform queries on the Abstract Syntax Tree (AST) that GCC generates from source files.  This lets you write a script that can notify you [...]]]></description>
			<content:encoded><![CDATA[<p>Over the past few months, I&#8217;ve been playing with a new static analysis tool from Mozilla called <a href="https://developer.mozilla.org/En/Dehydra_GCC">Dehydra</a>.</p>
<p>Dehydra is a GCC plugin that allows you to write Javascript that can perform queries on the Abstract Syntax Tree (AST) that GCC generates from source files.  This lets you write a script that can notify you when it sees any type of code construct that you can describe in script.</p>
<p>There are a number of code constructs that might be interesting to a code auditor, for example:</p>
<ul>
<li>Calls to asnprintf, malloc, or calloc with unchecked return values.</li>
<li>Assignment operations where the datatype of the Left Hand Side is signed and the Right Hand Side is unsigned, or vice versa.</li>
<li>Assignment operations where the datatypes of both sides have different bit-lengths.</li>
</ul>
<p>The possibilities are much greater than my short list of examples!</p>
<p>I will be the first to admit that static analysis has its faults.  For one thing, it has been proven that static analysis cannot discover all possible bugs in any given program.  Commercial static analysis tools, such as Coverity, are expensive and have not proven to be a particularly effective method of finding bugs by themselves.  I have heard many accounts of nasty bugs discovered by code auditors when looking through source code routinely scanned by Coverity.</p>
<p>That said, on Day One of a code audit, 4 out of 5 code auditors find themselves reaching for Grep.</p>
<p>Grep is great, it lets you search for regular expressions across many files very quickly, but Grep has no awareness of the syntax of the C++ programming language.  I&#8217;m really more interested in searching for specific code constructs and less interested in searching for substrings, which is Grep&#8217;s purpose.</p>
<p>When looking for vulnerabilities, I&#8217;m not interested in searching for the string &#8220;malloc&#8221;.  What I <em>really</em> want to know is more along the lines of &#8220;Where are all the calls to malloc where the return value is not checked&#8221;.  I don&#8217;t want to know all the locations of the string &#8220;int&#8221; as much as I want to know every location that a variable of type <em>int</em> is implicitly cast to an <em>unsigned int</em> when passed in as a function argument.</p>
<p>This is the great thing about Dehydra.  It lets you query the parsed syntax tree of C++ source code and ask the kinds of questions that can&#8217;t be easily answered by Grep.</p>
<p>Scripts for Dehydra are written in Javascript by way of the SpiderMonkey engine.  Javascript is a nice, small language that is good for operations on tree-like data structures.  In a browser, this would mean the DOM, but in GCC this means the AST!</p>
<p>Dehydra is still in development, but the developers have been extremely responsive to feature requests from security auditors ( well, mine anyway&#8230; *grin* ).</p>
<p>It would be great to see a bunch of people contribute scripts and build a big set of security scanning scripts to replace the venerable regular-expression-based <a href="http://www.dwheeler.com/flawfinder/">FlawFinder</a> as the king of no-budget security-oriented static analysis.</p>
<p>Try it out and get back to me.</p>
<p><a href="https://developer.mozilla.org/En/Dehydra_GCC">Setup and Installation Instructions for Dehydra on Linux or OSX</a></p>
<p>I&#8217;ve included a sample Dehydra script below that logs a message anytime it sees certain assignment operations.</p>
<p>The full sample script, along with a test file, is available <a href="http://awgh.org/files/dehydra-example.tgz">here</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;color: #FCFFBA;"><span style="color: #003366; font-weight: bold;color: #577A61;">function</span> assignVisitor<span style="color: #009900;color: #CCC;">&#40;</span>node<span style="color: #009900;color: #CCC;">&#41;</span> <span style="color: #009900;color: #CCC;">&#123;</span>
   <span style="color: #000066; font-weight: bold;color: #B83A24;">for</span><span style="color: #009900;color: #CCC;">&#40;</span><span style="color: #003366; font-weight: bold;color: #577A61;">var</span> i <span style="color: #000066; font-weight: bold;color: #B83A24;">in</span> node.<span style="color: #660066;">statements</span><span style="color: #009900;color: #CCC;">&#41;</span> <span style="color: #009900;color: #CCC;">&#123;</span>
      <span style="color: #003366; font-weight: bold;color: #577A61;">var</span> loc <span style="color: #339933;color: #CCC;">=</span> node.<span style="color: #660066;">loc</span>
      <span style="color: #003366; font-weight: bold;color: #577A61;">var</span> lhs <span style="color: #339933;color: #CCC;">=</span> node.<span style="color: #660066;">statements</span><span style="color: #009900;color: #CCC;">&#91;</span>i<span style="color: #009900;color: #CCC;">&#93;</span>.<span style="color: #660066;">type</span>
      <span style="color: #003366; font-weight: bold;color: #577A61;">var</span> rhs <span style="color: #339933;color: #CCC;">=</span> node.<span style="color: #660066;">statements</span><span style="color: #009900;color: #CCC;">&#91;</span>i<span style="color: #009900;color: #CCC;">&#93;</span>.<span style="color: #660066;">assign</span>
&nbsp;
      <span style="color: #000066; font-weight: bold;color: #B83A24;">if</span><span style="color: #009900;color: #CCC;">&#40;</span> rhs <span style="color: #339933;color: #CCC;">&amp;</span>amp<span style="color: #339933;color: #CCC;">;&amp;</span>amp<span style="color: #339933;color: #CCC;">;</span> lhs <span style="color: #009900;color: #CCC;">&#41;</span> <span style="color: #009900;color: #CCC;">&#123;</span>
         <span style="color: #000066; font-weight: bold;color: #B83A24;">if</span><span style="color: #009900;color: #CCC;">&#40;</span> lhs.<span style="color: #660066;">unsigned</span> <span style="color: #009900;color: #CCC;">&#41;</span> <span style="color: #009900;color: #CCC;">&#123;</span>
            <span style="color: #000066; font-weight: bold;color: #B83A24;">if</span><span style="color: #009900;color: #CCC;">&#40;</span>parseInt<span style="color: #009900;color: #CCC;">&#40;</span>rhs<span style="color: #009900;color: #CCC;">&#91;</span><span style="color: #CC0000;color: #DDD;">0</span><span style="color: #009900;color: #CCC;">&#93;</span>.<span style="color: #660066;">value</span><span style="color: #009900;color: #CCC;">&#41;</span> <span style="color: #339933;color: #CCC;">&amp;</span>gt<span style="color: #339933;color: #CCC;">;</span> <span style="color: #CC0000;color: #DDD;">0</span><span style="color: #009900;color: #CCC;">&#41;</span> <span style="color: #009900;color: #CCC;">&#123;</span>
               <span style="color: #000066;color: #8FB394;">print</span><span style="color: #009900;color: #CCC;">&#40;</span> <span style="color: #3366CC;color: #666666;">&quot;ASSIGN: negative to unsigned at:&quot;</span><span style="color: #339933;color: #CCC;">+</span>loc<span style="color: #339933;color: #CCC;">+</span><span style="color: #3366CC;color: #666666;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #009900;color: #CCC;">&#41;</span>
            <span style="color: #009900;color: #CCC;">&#125;</span>
            <span style="color: #000066; font-weight: bold;color: #B83A24;">else</span> <span style="color: #000066; font-weight: bold;color: #B83A24;">if</span><span style="color: #009900;color: #CCC;">&#40;</span>rhs<span style="color: #009900;color: #CCC;">&#91;</span><span style="color: #CC0000;color: #DDD;">0</span><span style="color: #009900;color: #CCC;">&#93;</span>.<span style="color: #660066;">type</span> <span style="color: #339933;color: #CCC;">&amp;</span>amp<span style="color: #339933;color: #CCC;">;&amp;</span>amp<span style="color: #339933;color: #CCC;">;</span> <span style="color: #339933;color: #CCC;">!</span>rhs<span style="color: #009900;color: #CCC;">&#91;</span><span style="color: #CC0000;color: #DDD;">0</span><span style="color: #009900;color: #CCC;">&#93;</span>.<span style="color: #660066;">type</span>.<span style="color: #660066;">unsigned</span><span style="color: #009900;color: #CCC;">&#41;</span> <span style="color: #009900;color: #CCC;">&#123;</span>
               <span style="color: #000066;color: #8FB394;">print</span><span style="color: #009900;color: #CCC;">&#40;</span> <span style="color: #3366CC;color: #666666;">&quot;ASSIGN: signed to unsigned at:&quot;</span><span style="color: #339933;color: #CCC;">+</span>loc<span style="color: #339933;color: #CCC;">+</span><span style="color: #3366CC;color: #666666;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #009900;color: #CCC;">&#41;</span>
            <span style="color: #009900;color: #CCC;">&#125;</span>
         <span style="color: #009900;color: #CCC;">&#125;</span>
         <span style="color: #000066; font-weight: bold;color: #B83A24;">else</span> <span style="color: #000066; font-weight: bold;color: #B83A24;">if</span><span style="color: #009900;color: #CCC;">&#40;</span>rhs<span style="color: #009900;color: #CCC;">&#91;</span><span style="color: #CC0000;color: #DDD;">0</span><span style="color: #009900;color: #CCC;">&#93;</span>.<span style="color: #660066;">type</span><span style="color: #009900;color: #CCC;">&#41;</span> <span style="color: #009900;color: #CCC;">&#123;</span><span style="color: #006600; font-style: italic;color: #CDC;">// lhs is signed</span>
            <span style="color: #000066; font-weight: bold;color: #B83A24;">if</span><span style="color: #009900;color: #CCC;">&#40;</span> rhs<span style="color: #009900;color: #CCC;">&#91;</span><span style="color: #CC0000;color: #DDD;">0</span><span style="color: #009900;color: #CCC;">&#93;</span>.<span style="color: #660066;">type</span>.<span style="color: #660066;">unsigned</span> <span style="color: #009900;color: #CCC;">&#41;</span> <span style="color: #009900;color: #CCC;">&#123;</span>
               <span style="color: #000066;color: #8FB394;">print</span><span style="color: #009900;color: #CCC;">&#40;</span> <span style="color: #3366CC;color: #666666;">&quot;ASSIGN: unsigned to signed at:&quot;</span><span style="color: #339933;color: #CCC;">+</span>loc<span style="color: #339933;color: #CCC;">+</span><span style="color: #3366CC;color: #666666;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #009900;color: #CCC;">&#41;</span><span style="color: #339933;color: #CCC;">;</span>
            <span style="color: #009900;color: #CCC;">&#125;</span>
         <span style="color: #009900;color: #CCC;">&#125;</span>
      <span style="color: #009900;color: #CCC;">&#125;</span>
   <span style="color: #009900;color: #CCC;">&#125;</span>
<span style="color: #009900;color: #CCC;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;color: #577A61;">function</span> process_function<span style="color: #009900;color: #CCC;">&#40;</span>decl<span style="color: #339933;color: #CCC;">,</span>body<span style="color: #009900;color: #CCC;">&#41;</span> <span style="color: #009900;color: #CCC;">&#123;</span>
   iter<span style="color: #009900;color: #CCC;">&#40;</span>assignVisitor<span style="color: #339933;color: #CCC;">,</span> body<span style="color: #009900;color: #CCC;">&#41;</span>
<span style="color: #009900;color: #CCC;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.awgh.org/archives/73/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Groo: Fully Automated WEP Cracking</title>
		<link>http://www.awgh.org/archives/76</link>
		<comments>http://www.awgh.org/archives/76#comments</comments>
		<pubDate>Wed, 24 Dec 2008 06:55:11 +0000</pubDate>
		<dc:creator>awgh</dc:creator>
				<category><![CDATA[Fun]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[802.11]]></category>
		<category><![CDATA[computer security]]></category>
		<category><![CDATA[cracking]]></category>
		<category><![CDATA[exploit]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[infosec]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[pen test]]></category>
		<category><![CDATA[wep]]></category>
		<category><![CDATA[wifi]]></category>
		<category><![CDATA[wireless]]></category>

		<guid isPermaLink="false">http://www.awgh.org/?p=76</guid>
		<description><![CDATA[Updates Below! I don&#8217;t know about the rest of you, but I have an entire room of my house which is simply a huge pile of electronics scrap.  A hacked Tivo, some chipped XBoxes, an old VCR, a pile of PCI video cards, a full shoebox of 64MB Compact Flash cards&#8230;  You get the idea. [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Updates Below!</strong></p>
<p>I don&#8217;t know about the rest of you, but I have an entire room of my house which is simply a huge pile of electronics scrap.  A hacked Tivo, some chipped XBoxes, an old VCR, a pile of PCI video cards, a full shoebox of 64MB Compact Flash cards&#8230;  You get the idea.</p>
<p>One day, I decided to put some of this junk to good use and I wandered into the scrap heap looking for inspiration.</p>
<p>Inspiration came in the form of an Atheros wireless card and an old ITX barebones system that had been picked up from a junk table at DefCon for $60 the year before.  The ITX box has a single PCI slot, perfect for a decent Atheros wireless card with an external SMC antenna connector.  It also runs on 12V DC power, so I can run it off the car battery.</p>
<p>Over the next few weeks, I built a small embedded Linux system for the sole purpose of cracking WEP keys.</p>
<p>First, I added a USB wireless network card to use as a control interface that I could access from my iPhone.</p>
<p>I also built a small web service that completely automates the process using the Python web framework <a href="http://turbogears.org/">TurboGears</a>, <a href="http://www.aircrack-ng.org/">aircrack-ng</a>, and screen.</p>
<p>The web interface is incredibly simple &#8211; it uses only a single combo box.  This makes it ideal for using from the iPhone.</p>
<p>Now, instead of being the sketchy guy sitting in my car with a laptop, I&#8217;m just another Seattle-ite staring into my iPhone while the computer doing the WEP cracking is running off my car battery halfway down the block.</p>
<p>Everything in the web interface is fire-and-forget.  You can view a list of available networks, select one for cracking, and it will automatically:</p>
<ol>
<li>Reconfigure the wireless interface to the correct channel</li>
<li>Begin dumping packets with airodump-ng in a screen session</li>
<li>Begin an ARP replay attack with aireplay-ng in a screen session</li>
<li>Automatically kick off the actual WEP cracking by starting aircrack-ng in a screen session</li>
<li>Once the crack has succeeded, save the ESSID, BSSID, and cracked WEP key in a SQLite database</li>
</ol>
<p>Since each of the aircrack-ng tools are running in a separate screen session, you can disconnect from the control interface as soon as the crack starts.  You can also reconnect at any time during the crack and view each screen session separately.</p>
<p>When close enough to a target for the ARP replay attack to work, this script averages only <strong>3 minutes</strong> to crack a WEP key.  This is on an ITX box with a wimpy Cyrix C3 processor with only 256MB of RAM!</p>
<p>My scripts and installation instructions available <a href="http://www.awgh.org/files/groo-0.1.tgz">here</a>.</p>
<p><strong>Update:</strong></p>
<p>I have ported these scripts to the EEE pc (I use Ubuntu Netbook Remix on a 900A), available <a href="http://awgh.org/files/groo-eeepc-0.2.tgz">here</a>.</p>
<p>However, I can&#8217;t get airodump-ng to actually capture any packets!  I believe this is a problem with my madwifi driver, but I haven&#8217;t sorted it out yet.  Hopefully, if I post the scripts one of you can help me out <img src='http://www.awgh.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Another Update (October 2010):</strong></p>
<p>Hello Hackaday!  Since writing this initial version, I&#8217;ve since  learned a lot about Python job control.  Check out the Jabbercracky  project, also on this site.  I&#8217;m planning on a much-improved version of  Groo, using what I&#8217;ve learned from Jabbercracky, which will also add  some new tricks, including some available WPA cracks.  I&#8217;d also like to  improve the installer, and to also provide builds for Ubiquiti networks  hardware.  If anyone is interested in helping out, please email me at  awgh at awgh dot org.</p>
<p>Stay tuned&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.awgh.org/archives/76/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>XSS Vulnerability in Internet Explorer HTML Attachment Download</title>
		<link>http://www.awgh.org/archives/57</link>
		<comments>http://www.awgh.org/archives/57#comments</comments>
		<pubDate>Wed, 24 Dec 2008 02:47:20 +0000</pubDate>
		<dc:creator>awgh</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[attachment]]></category>
		<category><![CDATA[Content-Disposition]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[ie7]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[microsoft security]]></category>
		<category><![CDATA[noopen]]></category>
		<category><![CDATA[pen test]]></category>
		<category><![CDATA[web application security]]></category>
		<category><![CDATA[Web Security]]></category>
		<category><![CDATA[X-Download-Options]]></category>
		<category><![CDATA[xss]]></category>

		<guid isPermaLink="false">http://www.awgh.org/?p=57</guid>
		<description><![CDATA[Update: MS fixed this issue in the IE8 6/9/09 security update.  Now IE8 behaves like Firefox (unclear on whether &#8216;X-Download-Options: noopen&#8217; still exists at all). I have noticed a Cross-Site Scripting vulnerability in the way Internet Explorer handles the downloading and opening of HTML files when they are downloaded as an attachment, rather than opened [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update: </strong>MS fixed this issue in the IE8 6/9/09 security update.  Now IE8 behaves like Firefox (unclear on whether &#8216;X-Download-Options: noopen&#8217; still exists at all).</p>
<p>I have noticed a Cross-Site Scripting vulnerability in the way Internet Explorer handles the downloading and opening of HTML files when they are downloaded as an attachment, rather than opened normally.  This vulnerability exists in all versions of Internet Explorer, including the latest patch level of IE7 as of 12/23/08.</p>
<p>This vulnerability related to sites serving user-submitted HTML files with &#8220;Content-Disposition: attachment&#8221;.</p>
<p>When directly opening a downloaded HTML file, Internet Explorer violates the Same Origin Policy by allowing any script inside the downloaded file to access the cookies of the site the file was downloaded from.  This script should be restricted to running in a local context, not a domain context.</p>
<p>Firefox exhibits better behavior by first downloading the HTML attachment and then opening it with a file:// URL.  When scripts in the downloaded HTML file are executed, they are treated as if run from a local file, not as if run from the domain the file was downloaded from, and they cannot access the source domain&#8217;s cookies.</p>
<p>This vulnerability would allow an attacker to execute a Cross-Site Scripting attack on a site that allowed uploading file attachments.  An HTML file could be uploaded containing malicious script that could steal user credentials or forge user actions on the site (if downloaded and opened by an IE user).</p>
<p>I have created a screencast reproducing the incorrect behavior in Internet Explorer as well as the correct behavior in Firefox.  Additionally, I&#8217;ve set up a downloadable HTML file that you can use to reproduce the issue yourself!</p>
<p>The screencast and example are available at: <a href="http://www.awgh.org/iebug">http://www.awgh.org/iebug</a></p>
<p>Microsoft has addressed this issue in IE8, but their solution leaves me with some questions.  The write-up in their development blog is <a href="http://blogs.msdn.com/ie/archive/2008/07/02/ie8-security-part-v-comprehensive-protection.aspx">here</a>, skip down to the section titled &#8220;MIME-Handling: Force Save&#8221;.  This section acknowledges that this is a potential vector for script injection in IE and describes the solution as implemented in IE8.</p>
<p>The solution in IE8:</p>
<p>The web server can set the response header &#8220;X-Download-Options&#8221; to the value &#8220;noopen&#8221;.  This will tell Internet Explorer to only offer the option to save the file or cancel.  It simply removes the &#8220;Open&#8221; option when this option is set.</p>
<p>I see two problems with this solution.  First, call me a pessimist, but I can see someone actually disabling &#8220;noopen&#8221; simply to bring back the &#8220;Open&#8221; dialog option.</p>
<p>Second, I doubt that most web server admins are going to be worried enough about this issue to remember to set this header, or even know they should do it.  It&#8217;s a bit of an esoteric bug &#8211; it only affects sites that serve untrusted HTML with &#8220;Content-Disposition: attachment&#8221;.  Even if Microsoft web servers set &#8220;noopen&#8221; by default, I doubt that most LAMP admins will bother adding this to their server options.</p>
<p>Why force the server to fix this problem?  Why not treat the &#8220;Open&#8221; option the same way Firefox does, by first downloading the file, then opening it with only a local script context?</p>
<p>This method of script injection will continue to work in Internet Explorer 8, as long as the site has not set the &#8220;X-Download-Options&#8221; header to &#8220;noopen&#8221;.</p>
<p>So the moral of the story:  If you are the admin of a site that serves untrusted HTML files with &#8220;Content-Disposition: attachment&#8221; set, please make sure the &#8220;X-Download-Options&#8221; header is set to &#8220;noopen&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.awgh.org/archives/57/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Weaponizing Mailinator</title>
		<link>http://www.awgh.org/archives/43</link>
		<comments>http://www.awgh.org/archives/43#comments</comments>
		<pubDate>Wed, 17 Dec 2008 23:26:55 +0000</pubDate>
		<dc:creator>awgh</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[brute force]]></category>
		<category><![CDATA[brute forcing]]></category>
		<category><![CDATA[dictionary]]></category>
		<category><![CDATA[dictionary attack]]></category>
		<category><![CDATA[forgot password]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[infosec]]></category>
		<category><![CDATA[mailinator]]></category>
		<category><![CDATA[Mailinator-nator]]></category>
		<category><![CDATA[Mailinatornator]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[pen test]]></category>
		<category><![CDATA[web application security]]></category>
		<category><![CDATA[Web Security]]></category>

		<guid isPermaLink="false">http://www.awgh.org/?p=43</guid>
		<description><![CDATA[There has always been something deeply unsettling to me about the &#8216;Forgot Password&#8217; functionality on many web sites. The &#8216;Forgot Password&#8217; page exists solely to help unauthenticated users bypass the usual means of authentication. For whatever reason, many developers overlook the importance of locking this down, even after the issue of too-easily-guessable questions in Yahoo&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>There has always been something deeply unsettling to me about the &#8216;Forgot Password&#8217; functionality on many web sites.</p>
<p>The &#8216;Forgot Password&#8217; page exists solely to help unauthenticated users bypass the usual means of authentication.</p>
<p>For whatever reason, many developers overlook the importance of locking this down, even after the issue of too-easily-guessable questions in Yahoo&#8217;s &#8216;Forgot Password&#8217; procedure got a lot of media attention during the US presidential campaign after Gov. Palin&#8217;s webmail was hacked.</p>
<p>Even if the questions were based on specific preferences and more difficult to guess, very few sites will check for brute-force attempts on the &#8216;Forgot Password&#8217; page, even though protections against brute-forcing have often been implemented in the more prestigious login page.</p>
<p>One other recommendation I usually make is the banning of email addresses from Mailinator, Slopsbox, and similar anonymous email services in registration.</p>
<p>If you&#8217;re not familiar with Mailinator, it&#8217;s an email server which displays ALL received emails to anyone who visits their web site.  Say you were registering for some web site and they asked for an address to send the validation email to.  You can just enter any email address at Mailinator, for example asdf@mailinator.com, and then go to www.mailinator.com and read the response.  This is great for not having to give out your real email.</p>
<p>What this means, however, is that I can simply go to the &#8216;Forgot Password&#8217; page, which usually requires only an email address, enter asdf@mailinator.com, and a password reset email will be sent to Mailinator where I can collect it anonymously.  Any user account on any web service which was registered to a Mailinator email address can be compromised simply by guessing the email address.</p>
<p>Here&#8217;s where the brute-forcing comes in.  Since most sites let you make as many guesses on the &#8216;Forgot Password&#8217; page as you&#8217;d like, there is nothing stopping an attacker from simply guessing email addresses at full tilt.</p>
<p>To demonstrate the effectiveness of this technique, I&#8217;ve written two example scripts, called the <strong>Mailinator-nator</strong>, which are available <a href="http://www.awgh.org/files/natornator.tgz">here</a>.</p>
<p>The first script is called <strong>forgot-pwd-force.py</strong>, this script does the following:<br />
1) Brute forces ‘Forgot Password’ forms that only require email addresses on a hardcoded list of sites, using a wordlist of usernames.<br />
2) For each username, tries each of the Mailinator domain aliases (Mailinator has a number of different domain names that point to the same place).</p>
<p>The second script is called <strong>mailinator-scan.py</strong>, this script does the following:<br />
1) Reads a wordlist of usernames from a file.<br />
2) For each username, connects to Mailinator and logs all emails to that user which contain the word ‘password’.</p>
<p>To use these two together, first add your target sites to <strong>forgot-pwd-force.py</strong>.  You can use one of my included wordlists or make your own, just be sure to use the same wordlist for both scripts.</p>
<p>Next, run the first script to force the target site to generate password reset emails to Mailinator addresses.</p>
<p>Wait a few minutes, and then run the second script to collect all of the return emails from the Mailinator server.</p>
<p>The second script can also be run as a cron job, which lets you troll Mailinator for password reset emails that you did not trigger yourself!  Mailinator deletes all received emails within an hour or two, so you may have to tinker with it to find a good interval.</p>
<p>I love Mailinator, so I checked and this doesn&#8217;t seem to violate their terms of service.  Looking at their site, they don&#8217;t seem to have terms of service!  This makes some kind of sense, since all users to the site are anonymous.  That said, actually logging in to a web site with a password recovered in this way is probably illegal in most jurisdictions so <strong>don&#8217;t do it</strong>.</p>
<p>As a site developer, what can you do to prevent these kinds of problems?</p>
<p>1) Ban registration emails to Mailinator and all of its domain aliases.</p>
<p>2) After 10 or so failed attempts to guess an answer on the &#8216;Forgot Password&#8217; page, ban the IP for 5-15 minutes.</p>
<p>3) Require more than just the email address to send a password reset email.  Consider at least two factors: email address AND one security question.</p>
<p>These three measures will protect your &#8216;Forgot Password&#8217; page from brute-forcing and dictionary attacks, as well as protecting your users from having their accounts stolen.</p>
<p>As a user of Mailinator, you can reduce your exposure to this risk by making use of the &#8216;Delete This Email&#8217; feature of Mailinator and by using a long, difficult to guess user name.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.awgh.org/archives/43/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>EFI and Evil</title>
		<link>http://www.awgh.org/archives/27</link>
		<comments>http://www.awgh.org/archives/27#comments</comments>
		<pubDate>Tue, 16 Dec 2008 04:21:52 +0000</pubDate>
		<dc:creator>awgh</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[bios]]></category>
		<category><![CDATA[bios rootkit]]></category>
		<category><![CDATA[computer security]]></category>
		<category><![CDATA[efi]]></category>
		<category><![CDATA[exploit]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[infosec]]></category>
		<category><![CDATA[keyboard]]></category>
		<category><![CDATA[ps2]]></category>
		<category><![CDATA[rootkit]]></category>

		<guid isPermaLink="false">http://www.awgh.org/?p=27</guid>
		<description><![CDATA[There is a legend you may have heard of a lowly system administrator who notices a bunch of extra network traffic coming from one of his workstations.  It appears that every packet sent from the workstation is copied and forwarded to an IP address in a country with no extradition treaty.  The admin figures that [...]]]></description>
			<content:encoded><![CDATA[<p>There is a legend you may have heard of a lowly system administrator who notices a bunch of extra network traffic coming from one of his workstations.  It appears that every packet sent from the workstation is copied and forwarded to an IP address in a country with no extradition treaty.  The admin figures that some kind of rootkit is installed, so he completely reformats the hard drive and re-installs everything.  Fires the thing up anew, and sure enough all packets are still being forwarded overseas!  He can&#8217;t wrap his brain around that, so he tries completely removing the hard drive and starting with a new one.  When he gets through the second re-install, all sent packets are STILL being sent overseas.</p>
<p>The admin in this story made the same mistake that many people do when thinking about their computer &#8211; he assumed that all user-modifiable executable code is only stored on the hard drive.</p>
<p>This story is at least 10 years old, and I&#8217;ve heard it in various different forms, but the technological culprit was certainly a BIOS-based rootkit.  A BIOS-based rootkit can hide in one of two places: either embedded in the BIOS itself or in a PCI Option ROM.  As part of BIOS start-up, it will load executable code from a special ROM chip on each PCI device and execute this code with Ring 0 privileges, meaning the code can control absolutely anything the computer can do.  PCI Option ROMs are intended to let peripheral developers include some driver code that it wants to be run at BIOS execution time.  This code needs Ring 0 access, because it might need to interact directly with the ICs on the PCI device itself.  This is a feature, not a bug.</p>
<p>Delivering a BIOS-based rootkit is a bit more complicated than a traditional rootkit.  There are two methods for this.  The first involves gaining root privileges on the target machine by some means and flashing a new BIOS using SPI or tools provided by the motherboard manufacturer.  If your rootkit goes on a PCI Option ROM, you can also flash those with root access.  Many devices can also be reflashed over the network via PXE.  Most PCI cards have read-only Option ROMs, so this will only work for high-end network cards, video cards, or any other kind of PCI device that touts upgradeable firmware.</p>
<p>The second method is more interesting, and involves physically accessing the hardware, installing the rootkit, and then selling or giving the modified hardware to the intended victim.  A variation on this would be perhaps simply leaving a stack of shrink-wrapped network cards in the hallway outside a system administrators office with a Post-It saying &#8220;For IT&#8221;.  An advantage of this method is that you can flash the Option ROMs using a proper EEPROM programmer, so you can alter PCI cards that could not be altered using a software tool.  There can be several different Option ROM data segments on one physical chip, so you don&#8217;t necessarily have to stomp the existing driver code &#8211; you can just add another segment.</p>
<p>In the old BIOS standard, now referred to as Legacy BIOS, doing anything useful in a BIOS-based rootkit took an insane amount of time and skill.  Since BIOS runs before the operating system comes up, a rootkit developer would have no access to system libraries, filesystem drivers, or a network stack.  If the rootkit needed any of these features, the developer would have to write everything from scratch and interact with all of the involved chips at the lowest level (try to do TCP with only peeks and pokes using numbers gleaned from blueprints of chips, in short: HARD-FREAKING-CORE).</p>
<p>That was the past.</p>
<p>In 2009, AMD will start shipping <a href="http://en.wikipedia.org/wiki/Extensible_Firmware_Interface">EFI</a>-compatable chipsets by default.  Intel, the main proponent of EFI, has been using it in the Itanium series, but will be using it in just about everything by the end of 2009.  Apple has already been using EFI in all of their Intel Macs since 2006.</p>
<p>This will spell the end of Legacy BIOS.  Most will say good riddance.</p>
<p>EFI has a couple of shiny new advantages.  The main reason that EFI was developed in the first place was to overcome several limitations of Legacy BIOS, including the use of 16-bit processor mode and having only one megabyte of addressable space.</p>
<p>As EFI has been developed over the years, it&#8217;s turned into something slightly different.  Intel has open-sourced almost all of a firmware development kit called the EFI Developer Kit or EDK, available <a href="https://edk.tianocore.org/">here</a>.</p>
<p>The EDK includes a large amount of sample code as well as a large set of utility libraries, all written in straight C.  The utility libraries include a variety of networking functions, including an optional full TCP/IP stack, as well as filesystem access libraries for FAT and NTFS.</p>
<p>Although the EDK doesn&#8217;t come with everything required to build a complete firmware, it does come with enough to build the two items of interest to an attacker: PCI Option ROMs and EFI Modules.  EFI Modules are distinct modules of firmware code that can be easily combined with each other to produce a firmware.  If you&#8217;ve ever installed the rEFIt boot menu for Intel Macs, you&#8217;ve flashed an EFI module into your BIOS.</p>
<p>All of these new features are designed to make life easier for firmware developers, and they do.  They also make life easier for attackers who wish to use EFI for evil.  Now, you can write a rootkit in C instead of assembler, and you can make use of pre-made network and file system libraries.</p>
<p>The only trick remaining is how to keep your rootkit running once BIOS execution has ended and the operating system is running.  There are a few methods available.  The easiest, and lamest, method is to simply write rootkit code out to the hard drive at every boot.  Cooler than that is using Intel&#8217;s System Management Mode (SMM) or ACPI event handlers to stash code to log keystrokes and then send it out on the network.  I have yet to see a working demo of this, and I&#8217;m told that a successful implementation requires specific knowledge of the Southbridge chip on a specifically targeted motherboard.</p>
<p>Update:  From talking to people at 25c3, I&#8217;ve learned that setting up a keystroke logger for just PS2 keyboards is pretty easy.  According to Peter Stuge of <a href="http://www.coreboot.org">coreboot</a>, to capture PS2 keystrokes you can use SMM to trap reads from io port 60, which is guaranteed to be the same on all platforms.  When the SMM trap triggers, it can run code you set up from, say, an Option ROM earlier.  There are examples of the use of SMM in the coreboot source!</p>
<p>There is also a common misconception that TPMs somehow prevent malicious PCI Option ROMs, but this isn&#8217;t so.</p>
<p>Apparently capturing USB keyboard keystrokes would be quite a bit more difficult.  Once I get PS2 working maybe&#8230; <img src='http://www.awgh.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.awgh.org/archives/27/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Replace Your Face Just Like The Laughing Man</title>
		<link>http://www.awgh.org/archives/21</link>
		<comments>http://www.awgh.org/archives/21#comments</comments>
		<pubDate>Tue, 16 Dec 2008 02:47:25 +0000</pubDate>
		<dc:creator>awgh</dc:creator>
				<category><![CDATA[Fun]]></category>
		<category><![CDATA[computer vision]]></category>
		<category><![CDATA[facial recognition]]></category>
		<category><![CDATA[ghost in the shell]]></category>
		<category><![CDATA[gits]]></category>
		<category><![CDATA[gits:sac]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[laughing man]]></category>
		<category><![CDATA[opencv]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[standalone complex]]></category>

		<guid isPermaLink="false">http://www.awgh.org/?p=21</guid>
		<description><![CDATA[Updates below! I&#8217;d like to share two things with all of you.  The first is a dark, personal secret.  The second is a toy I made. The secret is that for the past few months I have been harboring an unhealthy obsession with the Japanese television series &#8216;Ghost in the Shell: Standalone Complex.&#8217; What I [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Updates below!</strong></p>
<p>I&#8217;d like to share two things with all of you.  The first is a dark, personal secret.  The second is a toy I made.</p>
<p>The secret is that for the past few months I have been harboring an unhealthy obsession with the Japanese television series &#8216;Ghost in the Shell: Standalone Complex.&#8217;</p>
<p>What I love about this show the most is one of the recurring bad guys, an impossibly-skilled hacker called the Laughing Man who exhibits a number of extremely bad-ass qualities.</p>
<p>First and foremost, he can hack in to people&#8217;s minds and control them.  In the show, he uses this to carry out a series of political assassinations.</p>
<p>During these attacks, he also simultaneously hacks in to all security cameras and news feeds in the surrounding area, and blocks out the face of the person he&#8217;s currently controlling with a custom graphic.</p>
<p>This graphic is a smiley face with a baseball cap and a quote from Catcher in the Rye: &#8220;I thought what I&#8217;d do was, I&#8217;d pretend I was one of those deaf-mutes&#8230;&#8221;</p>
<p>Watching this show the other day, I suddenly realized that I could write a program that did face detection and substitution quite easily.  Once I realized I <em>could</em> do it, I <em>had</em> to.</p>
<p>So I quickly whipped up a program in <a href="http://www.processing.org/">Processing</a> that does the following:</p>
<p>1)  Opens up a video camera (for example, the web cam in your MacBook).</p>
<p>2) Finds all faces in the frame using the OpenCV library for Processing (installation instructions <a href="http://ubaa.net/shared/processing/opencv/">here</a>).</p>
<p>3) Replaces all faces with the Laughing Man graphic, borrowed from elmex over at <a href="http://www.ta-sa.org/projects/laughing_man_logo.html">ta-sa.org.</a></p>
<p>Try it out yourself!  It&#8217;s minutes of fun for the whole family.  Also, it could be useful in case you ever find yourself in control of some kind of video feed.</p>
<p>The hack-in-to-your-mind thing will have to wait for the time being&#8230;</p>
<p>Once you&#8217;ve got Processing and OpenCV for Processing installed, download <a href="http://www.awgh.org/files/laugh-0.2.tgz">laugh-0.2.tgz</a>.</p>
<p><strong>Update:</strong> I&#8217;ve merged in changes from the comments!  Text now rotates and the image scales!  Thanks to Josh, Brett, and Deltadesu!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.awgh.org/archives/21/feed</wfw:commentRss>
		<slash:comments>52</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: basic
Database Caching using disk: basic
Object Caching 825/911 objects using disk: basic

Served from: www.awgh.org @ 2012-02-05 19:19:42 -->
