<?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>Mike Conley&#039;s Blog &#187; protocol</title>
	<atom:link href="http://mikeconley.ca/blog/tag/protocol/feed/" rel="self" type="application/rss+xml" />
	<link>http://mikeconley.ca/blog</link>
	<description>The personal blog of a Toronto based software developer, musician, sound designer, and theatre enthusiast.</description>
	<lastBuildDate>Fri, 11 May 2012 15:23:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Fiddling Around with Skype</title>
		<link>http://mikeconley.ca/blog/2009/12/01/fiddling-around-with-skyp/</link>
		<comments>http://mikeconley.ca/blog/2009/12/01/fiddling-around-with-skyp/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 02:38:55 +0000</pubDate>
		<dc:creator>Mike</dc:creator>
				<category><![CDATA[Computer Science]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[fingerprint]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[networks]]></category>
		<category><![CDATA[nmap]]></category>
		<category><![CDATA[packets]]></category>
		<category><![CDATA[port scanning]]></category>
		<category><![CDATA[protocol]]></category>
		<category><![CDATA[scapy]]></category>
		<category><![CDATA[skype]]></category>
		<category><![CDATA[spoof]]></category>
		<category><![CDATA[tcp]]></category>
		<category><![CDATA[telnet]]></category>
		<category><![CDATA[udp]]></category>
		<category><![CDATA[wireshark]]></category>

		<guid isPermaLink="false">http://mikeconley.ca/blog/?p=952</guid>
		<description><![CDATA[As I said last week, I&#8217;ve been working with a partner (Mohammad Jalali) on a project for our networks course. The idea:  given an arbitrary IP and port number, we want to find a way of determining whether or not there is an FTP server, an HTTP server, or a Skype node on the other [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://mikeconley.ca/blog/2009/11/24/playing-around-with-ftp/">As I said last week</a>, I&#8217;ve been working with a partner (<a href="http://www.mjalali.com/blog/">Mohammad Jalali</a>) on a project for our networks course.</p>
<p>The idea:  given an arbitrary IP and port number, we want to find a way of determining whether or not there is an FTP server, an HTTP server, or a Skype node on the other side.  <a href="http://mikeconley.ca/blog/2009/11/24/playing-around-with-ftp/">FTP</a> and HTTP are trivial &#8211; those protocols essentially announce themselves to the world.</p>
<p><a href="http://www.skype.com/">Skype</a> clients, on the other hand, act a little more strangely.  Skype goes out of its way to hide its traffic &#8211; from straight-up encryption, down to making their client executable really hard to reverse engineer.  Because of this, <a href="http://www.blackhat.com/presentations/bh-europe-06/bh-eu-06-biondi/bh-eu-06-biondi-up.pdf">Skype has been an interesting challenge to the hacker community.</a></p>
<p>Anyhow, my partner and I have learned a few interesting things about Skype &#8211; and in particular, we&#8217;ve found a reliable way to determine whether or not Skype is running behind an arbitrary IP and port.  Cool.</p>
<h3>Fact 1:  Skype pretends to be an HTTP server</h3>
<p>I&#8217;m serious, it does.  Using <a href="http://www.wireshark.org/">Wireshark</a>, we noticed that both UDP <em>and</em> TCP packets were being sent to one particular port.  Pretty funny behavior&#8230;so, we took a closer look.  And this is what we found.  Pop open your Skype client, connect to the network, then use nmap to find the ports that Skype is using:</p>
<p><code><br />
$&gt;nmap localhost -p10000-50000</code></p>
<p>Starting Nmap 5.00 ( http://nmap.org ) at 2009-12-01 20:33 EST<br />
Interesting ports on localhost (127.0.0.1):<br />
Not shown: 39999 closed ports<br />
PORT      STATE SERVICE<br />
48915/tcp open  unknown</p>
<p>Ok, cool &#8211; there&#8217;s something at 48915, and it looks like it accepts TCP connections.  Pop open Telnet, connect to it, and feed it an HTTP request:</p>
<p><code><br />
$&gt;telnet localhost 48915<br />
Trying 127.0.0.1...<br />
Connected to localhost.<br />
Escape character is '^]'.<br />
GET / HTTP/1.1<br />
HTTP/1.0 404 Not Found<br />
Connection closed by foreign host.<br />
</code><br />
Ok, we got an HTTP response &#8211; looks like there&#8217;s an HTTP server back there, right?</p>
<p>Wrong.  Reconnect, and send it some garbage:</p>
<p><code><br />
$&gt;telnet localhost 48915<br />
Trying 127.0.0.1...<br />
Connected to localhost.<br />
Escape character is '^]'.<br />
thisissomegarbagetextthatisnotanHTTPrequest<br />
��Nun��2�=���1��N$O/(����<br />
���u.)(yy�g��$<br />
ș�oT�b렑�-z#x�&amp;���[P���\��(yVO���<br />
</code></p>
<p>See all of those funny characters down at the bottom?  That&#8217;s what I got back.  In the words of Obi-Wan Kenobi&#8230;that&#8217;s no HTTP server&#8230;it&#8217;s a space station (Skype node).</p>
<p>So we&#8217;ve learned something here &#8211; Skype opens a port, and &#8220;spoofs&#8221; an HTTP server.  We can easily check for this &#8211; just write a script that connects to a port, spews some garbage, and check to see if we got binary garbage back.</p>
<p>It&#8217;s so easy, <em>that someone else has already done it</em>.  Remember that nmap tool we used earlier?  <a href="http://nmap.org/nsedoc/scripts/skypev2-version.html">Somebody over in that camp wrote a script for the Nmap Scripting Engine</a> that runs this exact analysis on some ip/port.  Don&#8217;t believe me?  <a href="http://nmap.org/book/nse-vscan.html">Read the script yourself!</a> We stumbled upon that script while trying to figure out what Skype was doing with the spoofed HTTP server.<br />
And sure enough:<br />
<code><br />
$&gt;nmap localhost -p48915 --script skype.nse<br />
Starting Nmap 5.00 ( http://nmap.org ) at 2009-12-01 20:45 EST<br />
Interesting ports on localhost (127.0.0.1):<br />
PORT      STATE SERVICE<br />
48915/tcp open  skype2</code></p>
<p>Nmap done: 1 IP address (1 host up) scanned in 0.14 seconds</p>
<p>Hmph.  So much for cutting edge, never-been-done research.  Go figure.</p>
<h3>Fact 2:  Given some UDP packets, Skype echos back a predictable pattern</h3>
<p>For this part, we&#8217;re pretty sure no one else has tried this.</p>
<p>While connected to Skype, we recorded some packets with tcpdump.  We wrote a script that loaded up those packets, and could &#8220;replay&#8221; the packet payloads to an arbitrary IP and port.</p>
<p>So, we played some packets against an IP/port with Skype behind it.  Most of the time, we got TCP packets with RST flags (which is TCP&#8217;s way of telling us to &#8220;shut yer trap&#8221;).  But wayyyy down in the middle, there was a section of UDP packets that actually got a response:</p>
<table style="width: auto;" border="0">
<tbody>
<tr>
<td><a href="http://picasaweb.google.com/lh/photo/Fs73oxvTCSJ--ZWG0blasw?feat=embedwebsite"><img src="http://lh6.ggpht.com/_Kib24bTtAAU/SxXKinoyE5I/AAAAAAAAA9Q/yd_K9mD355I/s144/Repeated%20UDPs.png" alt="" /></a></td>
</tr>
<tr>
<td style="font-family: arial,sans-serif; font-size: 11px; text-align: right;">From <a href="http://picasaweb.google.com/mike.d.conley/MiscBlogImages?feat=embedwebsite" target="_blank">Misc Blog Images</a></td>
</tr>
</tbody>
</table>
<p>192.168.0.19 was the computer we were playing the packets from, and 192.168.0.14 was the computer with Skype running on it.  See those UDP packets that are getting echoed back?  That&#8217;s the interesting part&#8230;instead of just shutting us down with RST&#8217;s, Skype appears to be saying something back.</p>
<p>So, is there a pattern in all of this?  Actually yes.  We isolated 4 of those UDP packets, and repeatedly fired them at the same IP/Port on the computer running Skype, and we found a pattern.</p>
<p>The pattern:  <em>the first two bytes that are sent in our UDP packets are echo&#8217;d back to us in the first two bytes of the UDP packets that come back. </em></p>
<p>So, for example,  one UDP payload we sent looked like this:<br />
<code><br />
92 40 02 a1 66 65 ea 0d 8c 82 c3 0c 27 cd c5 e7<br />
4e 78 fe a1 50 a6<br />
</code><br />
And we got back:<br />
<code><br />
92 40 17 c0 a8 00 13 74 a0 41 f0<br />
</code><br />
See that common 92 40?  Bingo.  <img src='http://mikeconley.ca/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>And it&#8217;s <em>pretty consistent</em> &#8211; if we repeat the same UDP packet, we get (almost) the same response.</p>
<p><code><br />
<strong>92 40</strong> 67 <strong>c0 a8</strong> <strong>00</strong> <strong>13</strong> 11 00 10 4f<br />
</code></p>
<p>And if we repeat again&#8230;</p>
<p><code><br />
<strong>92 40</strong> 37 <strong>c0 a8 00 13</strong> 68 08 43 3a<br />
</code></p>
<p>92, 40, and c0, a8, 00, 13.  Nice!  Looks like a fingerprint to me!</p>
<h3>Except&#8230;</h3>
<p>Except, remember, we already found a way of determining whether or not Skype was running behind a given IP/port.  This last finding was just bonus.  My partner and I aren&#8217;t sure if our instructor is going to let us stay with this topic, seeing as how it&#8217;s pretty much been solved by other people before.  We&#8217;ve only got 2 weeks before this project is due, so&#8230;if we get another project, let&#8217;s hope it&#8217;s relatively simple.  Push come to shove, we could always try to fingerprint a different protocol&#8230;maybe BitTorrent clients.</p>
<p>Either way, working on this stuff has been pretty cool&#8230;and it let me try out some pretty neat tools that are usually reserved for the people <a href="http://en.wikipedia.org/wiki/Black_hat">with</a> <a href="http://en.wikipedia.org/wiki/Grey_hat">coloured</a> <a href="http://en.wikipedia.org/wiki/White_hat">hats</a> (and no, I didn&#8217;t mean Red Hat):</p>
<ul>
<li><a href="http://nmap.org/">nmap:</a> port scanner that can also do service/os fingerprinting</li>
<li><a href="http://www.secdev.org/projects/scapy/">Scapy:</a> sculpt, gut, spoof, manipulate, and send packets &#8211; the power of C, with the simplicity of Python!  We used Scapy as a library while writing our scripts.  Lots of potential with this tool.  Feel like poisoning an ARP cache?  Scapy is for you!</li>
<li><a href="http://www.wireshark.org/">Wireshark:</a> a network student&#8217;s best friend.</li>
</ul>
<p><a href="http://www.mjalali.com/blog/?p=102">Click here to check out Mohammad&#8217;s blog post about this project.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mikeconley.ca/blog/2009/12/01/fiddling-around-with-skyp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

