<?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>Kyle Anderson &#187; programming</title>
	<atom:link href="http://xkyle.com/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://xkyle.com</link>
	<description></description>
	<lastBuildDate>Thu, 22 Jul 2010 04:54:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Discrete Wavelets Final Project &#8211; Decaptcha,</title>
		<link>http://xkyle.com/2009/05/01/discrete-wavelets-final-project-decaptcha/</link>
		<comments>http://xkyle.com/2009/05/01/discrete-wavelets-final-project-decaptcha/#comments</comments>
		<pubDate>Fri, 01 May 2009 17:17:02 +0000</pubDate>
		<dc:creator>Kyle Anderson</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[School]]></category>
		<category><![CDATA[captcha]]></category>
		<category><![CDATA[mathematica]]></category>
		<category><![CDATA[nclug]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://xkyle.com/?p=301</guid>
		<description><![CDATA[This semester I took a class on Discrete Wavelets. It was awesome. The coolest part was our group final project. My group had the best topic by far: Decoding a Captcha! (Click on any of the following images to view them full size) We&#8217;ve all seen Captchas before. They are used on websites to make [...]]]></description>
			<content:encoded><![CDATA[<p>This semester I took a class on <a href="http://en.wikipedia.org/wiki/Discrete_wavelet_transform">Discrete Wavelets</a>. It was awesome. The coolest part was our group final project. My group had the best topic by far: Decoding a Captcha! (Click on any of the following images to view them full size)</p>
<p><a href="http://xkyle.com/wp-content/uploads/file_captcha.jpg"></a><a href="http://xkyle.com/wp-content/uploads/captcha.jpg"><img class="alignnone size-full wp-image-305" title="captcha" src="http://xkyle.com/wp-content/uploads/captcha.jpg" alt="captcha" width="290" height="80" /></a></p>
<p>We&#8217;ve all seen Captchas before. They are used on websites to make sure that the person on the website is a real human, not a computer program. Why do we want to break them? The same reason we want to climb Mount Everest, it&#8217;s There!</p>
<p><a href="http://xkyle.com/wp-content/uploads/input_captcha.jpg"><img class="alignnone size-medium wp-image-306" title="input_captcha" src="http://xkyle.com/wp-content/uploads/input_captcha-300x108.jpg" alt="input_captcha" width="300" height="108" /></a></p>
<p>The above is the captcha we intended to solve. Its not particularly difficult, but this class is an introduction to wavelets and requires no previous experience with the language we had to use: Mathematica. Our real task was to implement the algorithm in <a href="http://faculty.gvsu.edu/aboufade/web/cmj101-108.pdf">this paper</a>.</p>
<p>So how do we do it? First we need to isolate the image without the background.</p>
<p><a href="http://xkyle.com/wp-content/uploads/captchab.jpg"><img class="alignnone size-medium wp-image-307" title="captchab" src="http://xkyle.com/wp-content/uploads/captchab-300x108.jpg" alt="captchab" width="300" height="108" /></a></p>
<p>No problem. The color of the text is different from the background so it is easy to isolate. Next we need to take those pieces of the matrix and turn them into a list of coordinate pairs. Then we can apply a rotation matrix transform to undo the angle. What angle? Well I don&#8217;t know. How can we figure out how much it was rotate? Of course! Linear regression from Statistics!</p>
<p><a href="http://xkyle.com/wp-content/uploads/regression.jpg"><img class="alignnone size-medium wp-image-308" title="regression" src="http://xkyle.com/wp-content/uploads/regression-300x239.jpg" alt="regression" width="300" height="239" /></a></p>
<p>Fortunately Mathematica has a function for this. This is the easy part. Now we need to take these rotated vectors and &#8220;Unrotate&#8221; them, then put them back into a matrix:</p>
<p><a href="http://xkyle.com/wp-content/uploads/alligned.jpg"><img class="alignnone size-full wp-image-309" title="alligned" src="http://xkyle.com/wp-content/uploads/alligned.jpg" alt="alligned" width="240" height="62" /></a></p>
<p>No problem! Well actually this isn&#8217;t as easy as it sounds. Arbitrary image rotation is non trivial. But let us press on. Now we must Cut the image into its component letters. This is easy, the columns of the matrix that are all white are the demarcation points.</p>
<p><a href="http://xkyle.com/wp-content/uploads/segmented.jpg"><img class="alignnone size-full wp-image-310" title="segmented" src="http://xkyle.com/wp-content/uploads/segmented.jpg" alt="segmented" width="199" height="62" /></a></p>
<p>Ok now what? Well we have an individual matrix for each unknown letter. Let us resize it to a standard square size (pad it), say 80&#215;80. Oh I forgot to mention, before we stared on this we made a &#8220;<a href="http://www.merriam-webster.com/dictionary/canon">Canon</a>&#8221; of letters from A-Z0-9 with the same font into 80&#215;80 squares too. At this point we could compare each letters &#8220;difference&#8221; and see which has the least difference. Let me show you:</p>
<p><a href="http://xkyle.com/wp-content/uploads/subtract.jpg"><img class="alignnone size-full wp-image-311" title="subtract" src="http://xkyle.com/wp-content/uploads/subtract.jpg" alt="subtract" width="278" height="88" /></a></p>
<p>Eh so that is a crappy example. When you take two letters and subtract them, you get all black where they are the same, and some white or gray where the &#8220;differences&#8221; are (Math terms=2 dimensional norm). The letter with the least difference is most likely to be the original letter.</p>
<p>So all we have to do is iterate through each canonical letter until we get the least difference. Do that for each letter and we can decode (you can see the unknown on the left, and the matching canon on the right):</p>
<p><a href="http://xkyle.com/wp-content/uploads/compare.jpg"><img class="alignnone size-medium wp-image-312" title="compare" src="http://xkyle.com/wp-content/uploads/compare-116x300.jpg" alt="compare" width="116" height="300" /></a></p>
<p>Seems pretty good. But it gets better with some Discrete Wavelet Magic! Our comparison can get even better if we ignore the errors and wavey crap that was introduced in the align section. The way we do this is with the <a href="http://en.wikipedia.org/wiki/Haar_wavelet">Haar Wavelet Transform</a>. Don&#8217;t mind the math, we are basically blurring the image:</p>
<p><a href="http://xkyle.com/wp-content/uploads/haar.jpg"><img class="alignnone size-medium wp-image-313" title="haar" src="http://xkyle.com/wp-content/uploads/haar-300x157.jpg" alt="haar" width="300" height="157" /></a></p>
<p>The part we want is in the upper most left hand corner, the &#8220;blur&#8221;. It turns out that 3 iterations of the HWT gives the best results. By doing this we were able to decode our CAPTCHAs 75% of the time. In the end the major flaws take place in the linear regression and the align function. If we used Mathematica 7 instead of 6 we could have used its built in image processing functions to take the error out of our sloppy rounding.</p>
<p>But of course, the proof is in the code, I mean, the pudding. Here is our notebook:</p>
<p><a href="http://xkyle.com/wp-content/uploads/final3.nb">Mathematica Notebook</a><br />
To use this you need the <a href="http://cam.mathlab.stthomas.edu/wavelets/packagesmathematica.php">Discrete Wavelets Package</a>. Mathematica 7 comes with a function but this is written for 6.</p>
<p><a href="http://xkyle.com/wp-content/uploads/final3.nbp">Notebook for Mathematica Player</a><br />
Not everyone has Mathematica, but their <a href="http://www.wolfram.com/products/player/download.cgi">player</a> is cross platform and free as in beer.</p>
<p><a href="http://xkyle.com/wp-content/uploads/captcha.ppt">Our Powerpoint Presentation</a><br />
Blarg&#8230; If someone can convert this to pdf I will change this.</p>
]]></content:encoded>
			<wfw:commentRss>http://xkyle.com/2009/05/01/discrete-wavelets-final-project-decaptcha/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PAP Solutions Hack</title>
		<link>http://xkyle.com/2008/09/29/pap-solutions-hack/</link>
		<comments>http://xkyle.com/2008/09/29/pap-solutions-hack/#comments</comments>
		<pubDate>Mon, 29 Sep 2008 17:19:35 +0000</pubDate>
		<dc:creator>Kyle Anderson</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[cody]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nclug]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://xkyle.com/?p=125</guid>
		<description><![CDATA[My girlfirend likes to do these puzzles called Pic-A-Pix from ConceptisPuzzles. They use a matrix of numbers to hint the puzzler to to filling in pixels to create pixel art. Sometimes there is color. Every week four new PAP&#8217;s are pushed out, and I&#8217;ve been told that the answers are somewhere on the website&#8230;. but [...]]]></description>
			<content:encoded><![CDATA[<p>My girlfirend likes to do these puzzles called <a href="http://www.conceptispuzzles.com/index.aspx?uri=puzzle/pic-a-pix">Pic-A-Pix</a> from <a href="http://www.conceptispuzzles.com/">ConceptisPuzzles</a>.<br />
They use a matrix of numbers to hint the puzzler to to filling in pixels to create pixel art. Sometimes there is color. Every week four new PAP&#8217;s are pushed out, and I&#8217;ve been told that the answers are somewhere on the website&#8230;. but that would be cheating. <img src='http://xkyle.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So I wrote my own program to decode these and make images using html tables. I have it in my crontab.weekly and I have it set to email them to my girlfriend to annoy her.</p>
<p>Here is the link:<br />
<a href="http://xkyle.com/other/pap/output.html">http://kyle.com/other/pap/output.html</a></p>
<p>And the mixed reactions from Cenceptis:<br />
<a href="http://www.conceptispuzzles.com/forum/fb.aspx?m=28503">http://www.conceptispuzzles.com/forum/fb.aspx?m=28503</a></p>
<p><a href="http://xkyle.com/wp-content/uploads/pap.jpg"><img class="aligncenter size-full wp-image-126" title="pap" src="http://xkyle.com/wp-content/uploads/pap.jpg" alt="" width="500" height="156" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://xkyle.com/2008/09/29/pap-solutions-hack/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Arp Alerts II!</title>
		<link>http://xkyle.com/2008/08/21/custom-arp-alerts-ii/</link>
		<comments>http://xkyle.com/2008/08/21/custom-arp-alerts-ii/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 11:59:57 +0000</pubDate>
		<dc:creator>Kyle Anderson</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[sago]]></category>
		<category><![CDATA[nclug]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://xkyle.com/?p=112</guid>
		<description><![CDATA[So I&#8217;ve found a better way to do what I did in the previous post. Instead of running a separate script to parse the arp alert logs, I have arp alert itself send the alerts! The key is this line in the arpalert.conf action on detect = &#8220;/etc/scripts/arp-alert&#8221; Its so simple, it just runs that [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">So I&#8217;ve found a better way to do what I did in the previous post. Instead of running a separate script to parse the arp alert logs, I have arp alert itself send the alerts! The key is this line in the arpalert.conf</p>
<blockquote style="text-align: center;">
<p style="text-align: left;">action on detect = &#8220;/etc/scripts/arp-alert&#8221;</p>
</blockquote>
<p style="text-align: left;">Its so simple, it just runs that script sending the information about the alert as certain arguments. With this I have more control over the formatting of arpalert messages:</p>
<p style="text-align: center;"><a href="http://xkyle.com/wp-content/uploads/screenshot2.png"><img class="size-full wp-image-114 aligncenter" title="screenshot2" src="http://xkyle.com/wp-content/uploads/screenshot2.png" alt="" width="422" height="145" /></a></p>
<p style="text-align: left;">In order to do this, I had to write that script, and make it executable of course. Also I had to change the running user of arpalert to root, because the &#8220;arpalert&#8221; user didn&#8217;t have permission to notify my user &#8220;kyle&#8221;. This is a much more clean solution, allowing me to make different types of alerts look different, having different timeouts and such. If you want my /etc/scripts/arp-alert you can download what I have so far <a href="http://xkyle.com/other/arp-alert">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://xkyle.com/2008/08/21/custom-arp-alerts-ii/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Custom Arp-Alerts</title>
		<link>http://xkyle.com/2008/08/20/custom-arp-alerts/</link>
		<comments>http://xkyle.com/2008/08/20/custom-arp-alerts/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 23:17:05 +0000</pubDate>
		<dc:creator>Kyle Anderson</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[sago]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://xkyle.com/?p=101</guid>
		<description><![CDATA[So I was looking around, and I wanted some sort of tool to allow me to be more aware about what was happening in the lower &#8220;bowels&#8221; of the network that I&#8217;m on with my laptop. So what is it that I want&#8230; What I really want is some sort of mac-address based buddy list. [...]]]></description>
			<content:encoded><![CDATA[<p>So I was looking around, and I wanted some sort of tool to allow me to be more aware about what was happening in the lower &#8220;bowels&#8221; of the network that I&#8217;m on with my laptop. So what is it that I want&#8230;</p>
<p>What I really want is some sort of mac-address based buddy list. One that would show my a list of the mac addresses talking on my network, and allow me to alias them. That would be cool.</p>
<p>I couldn&#8217;t find such program, but I found something kinda close, its called arpalert. If you are using ubuntu you can simply run &#8220;apt-get install arpalert&#8221; (I love ubuntu!)</p>
<blockquote><p>kyle@kyle-laptop:~$ apt-cache search arpalert<br />
arpalert &#8211; Monitor ARP changes in ethernet networks</p></blockquote>
<p>You should edit the config file to your liking, but the main thing is the log file in /var/log/arpalert.log. I have it logging every interesting arp thing, because I find them interesting! You need to read up on it if you want to fully understand arpalert: <a href="http://www.arpalert.org/">http://www.arpalert.org/</a></p>
<p>So that is the first part. The second part is the piece that notifies you of something suspicious. Who wants to tail a log file all the time? For this I use something called &#8220;notify-send&#8221;. Try running it. If you don&#8217;t have it and you are running Ubuntu it will tell you that its part of the &#8221;</p>
<p>So I was looking around, and I wanted some sort of tool to allow me to be more aware about what was happening in the lower &#8220;bowels&#8221; of the network that I&#8217;m on with my laptop. So what is it that I want&#8230;</p>
<p>What I really want is some sort of mac-address based buddy list. One that would show my a list of the mac addresses talking on my network, and allow me to alias them. That would be cool.</p>
<p>I couldn&#8217;t find such program, but I found something kinda close, its called arpalert. If you are using ubuntu you can simply run &#8220;apt-get install arpalert&#8221; (I love ubuntu!)</p>
<blockquote><p>kyle@kyle-laptop:~$ apt-cache search arpalert<br />
arpalert &#8211; Monitor ARP changes in ethernet networks</p></blockquote>
<p>You should edit the config file to your liking, but the main thing is the log file in /var/log/arpalert.log. I have it logging every interesting arp thing, because I find them interesting! You need to read up on it if you want to fully understand arpalert: <a href="http://www.arpalert.org/">http://www.arpalert.org/</a></p>
<p style="text-align: center;"><a href="http://xkyle.com/wp-content/uploads/tailarps.png"><img title="tailarps" src="http://xkyle.com/wp-content/uploads/tailarps.png" alt="" /></a></p>
<p>So that is the first part. The second part is the piece that notifies you of something suspicious. Who wants to tail a log file all the time? For this I use something called &#8220;notify-send&#8221;. Try running it. If you don&#8217;t have it and you are running Ubuntu it will tell you that its part of the &#8220;libnotify-bin&#8221; package. So you will need to run:</p>
<blockquote><p>$ sudo apt-get install libnotify-bin</p></blockquote>
<p>Try it! run &#8220;notify test&#8221;. A popup should show up! Simple! Now, we need a small program to put the pieces together and glue it. I want my popup when odd things happen. Here is the glue I wrote, modify at will:</p>
<blockquote><p>tail -n 0  -F /var/log/arpalert.log | awk -W interactive &#8216;{print $8, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12}&#8217; |<br />
while read heading message<br />
do  notify-send -t 3000 &#8212; &#8220;Arp Alert&#8221; &#8220;${heading} ${message}&#8221;<br />
done</p></blockquote>
<p>I don&#8217;t think I&#8217;m done with it yet. (I want to make it give different time outs for different types of messages, and I want it to change the heading to something dynamic instead of the Arp Alert, but yea) So put that in a .sh and run it! Nothing may pop up! Try putting something new on the network and seeing if something shows up in the log. Its pretty easy to troubleshoot and modify to your liking.</p>
<p style="text-align: center;"><a href="http://xkyle.com/wp-content/uploads/screenshot1.png"><img title="arpalert-screenshot" src="http://xkyle.com/wp-content/uploads/screenshot1.png" alt="" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://xkyle.com/2008/08/20/custom-arp-alerts/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>DNS Cache Poisoning</title>
		<link>http://xkyle.com/2008/07/31/dns-cache-poisoning/</link>
		<comments>http://xkyle.com/2008/07/31/dns-cache-poisoning/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 12:00:10 +0000</pubDate>
		<dc:creator>Kyle Anderson</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[sago]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://xkyle.com/?p=96</guid>
		<description><![CDATA[Recently a DNS expert found a flaw in the way that DNS servers talk to other DNS servers to get records that allows interested parties (hackers) to insert their own records. If you need a primer: the Wikipedia link. Well&#8230; a DNS flaw is no fun without a tool to use it. So this guy [...]]]></description>
			<content:encoded><![CDATA[<p>Recently a DNS expert found a flaw in the way that DNS servers talk to other DNS servers to get records that allows interested parties (hackers) to insert their own records. If you need a primer: the <a href="http://en.wikipedia.org/wiki/DNS_cache_poisoning">Wikipedia link</a>.</p>
<p>Well&#8230; a DNS flaw is no fun without a tool to use it. So this guy &#8220;HD Moore&#8221; wrote a program (script) that takes advantage of this and makes it relatively easy for someone to use something called <a href="http://www.metasploit.com/framework/">Metasploit</a> to tinker with it. Cool!</p>
<p>Turns out that it works, and people are fixing their DNS servers so that this can&#8217;t happen. (I fixed mine as soon as the fix was out.) But not everyone can fix their own, often they are at the mercy of their ISP&#8217;s. (Have you ever called up your ISP&#8217;s help desk and told them they need to upgrade their DNS servers to protect them against cache poisoning? Heheheh.. right)</p>
<p>So one day, Mr. Moore goes to google.com on his computer at work, and guess what, its not the real google.com&#8230;</p>
<p><a href="http://www.networkworld.com/news/2008/073008-dns-attack-writer-a-victim.html">The news article</a></p>
<p>Well played sir. Well played.</p>
]]></content:encoded>
			<wfw:commentRss>http://xkyle.com/2008/07/31/dns-cache-poisoning/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)
Database Caching 14/20 queries in 0.238 seconds using disk

Served from: xkyle.com @ 2010-07-31 23:46:04 -->