<?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; attachment</title>
	<atom:link href="http://www.awgh.org/archives/tag/attachment/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>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>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>
	</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 1/18 queries in 0.187 seconds using disk: basic
Object Caching 389/423 objects using disk: basic

Served from: www.awgh.org @ 2012-02-05 19:26:40 -->
