{"id":952,"date":"2009-12-01T21:38:55","date_gmt":"2009-12-02T02:38:55","guid":{"rendered":"http:\/\/mikeconley.ca\/blog\/?p=952"},"modified":"2023-12-20T16:25:18","modified_gmt":"2023-12-20T21:25:18","slug":"fiddling-around-with-skyp","status":"publish","type":"post","link":"https:\/\/mikeconley.ca\/blog\/2009\/12\/01\/fiddling-around-with-skyp\/","title":{"rendered":"Fiddling Around with Skype"},"content":{"rendered":"<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>\n<p>The idea:\u00a0 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.\u00a0 <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>\n<p><a href=\"http:\/\/www.skype.com\/\">Skype<\/a> clients, on the other hand, act a little more strangely.\u00a0 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.\u00a0 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>\n<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.\u00a0 Cool.<\/p>\n<h3>Fact 1:\u00a0 Skype pretends to be an HTTP server<\/h3>\n<p>I&#8217;m serious, it does.\u00a0 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.\u00a0 Pretty funny behavior&#8230;so, we took a closer look.\u00a0 And this is what we found.\u00a0 Pop open your Skype client, connect to the network, then use nmap to find the ports that Skype is using:<\/p>\n<p><code><br \/>\n$&gt;nmap localhost -p10000-50000<\/code><\/p>\n<p>Starting Nmap 5.00 ( http:\/\/nmap.org ) at 2009-12-01 20:33 EST<br \/>\nInteresting ports on localhost (127.0.0.1):<br \/>\nNot shown: 39999 closed ports<br \/>\nPORT\u00a0\u00a0\u00a0\u00a0\u00a0 STATE SERVICE<br \/>\n48915\/tcp open\u00a0 unknown<\/p>\n<p>Ok, cool &#8211; there&#8217;s something at 48915, and it looks like it accepts TCP connections.\u00a0 Pop open Telnet, connect to it, and feed it an HTTP request:<\/p>\n<p><code><br \/>\n$&gt;telnet localhost 48915<br \/>\nTrying 127.0.0.1...<br \/>\nConnected to localhost.<br \/>\nEscape character is '^]'.<br \/>\nGET \/ HTTP\/1.1<br \/>\nHTTP\/1.0 404 Not Found<br \/>\nConnection closed by foreign host.<br \/>\n<\/code><br \/>\nOk, we got an HTTP response &#8211; looks like there&#8217;s an HTTP server back there, right?<\/p>\n<p>Wrong.\u00a0 Reconnect, and send it some garbage:<\/p>\n<p><code><br \/>\n$&gt;telnet localhost 48915<br \/>\nTrying 127.0.0.1...<br \/>\nConnected to localhost.<br \/>\nEscape character is '^]'.<br \/>\nthisissomegarbagetextthatisnotanHTTPrequest<br \/>\n\ufffd\ufffdNun\u0006\ufffd\ufffd2\ufffd=\ufffd\ufffd\ufffd1\ufffd\ufffdN$O\/(\ufffd\ufffd\ufffd\ufffd<br \/>\n\ufffd\ufffd\ufffdu.)(\u0006yy\ufffd\u001bg\ufffd\ufffd$<br \/>\n\u0219\ufffdoT\ufffdb\ub811\ufffd-z#x\ufffd&amp;\ufffd\u0004\ufffd\ufffd[P\ufffd\ufffd\ufffd\\\u001d\ufffd\ufffd(yVO\ufffd\ufffd\ufffd<br \/>\n<\/code><\/p>\n<p>See all of those funny characters down at the bottom?\u00a0 That&#8217;s what I got back.\u00a0 In the words of Obi-Wan Kenobi&#8230;that&#8217;s no HTTP server&#8230;it&#8217;s a space station (Skype node).<\/p>\n<p>So we&#8217;ve learned something here &#8211; Skype opens a port, and &#8220;spoofs&#8221; an HTTP server.\u00a0 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>\n<p>It&#8217;s so easy, <em>that someone else has already done it<\/em>.\u00a0 Remember that nmap tool we used earlier?\u00a0 <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.\u00a0 Don&#8217;t believe me?\u00a0 <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 \/>\nAnd sure enough:<br \/>\n<code><br \/>\n$&gt;nmap localhost -p48915 --script skype.nse<br \/>\nStarting Nmap 5.00 ( http:\/\/nmap.org ) at 2009-12-01 20:45 EST<br \/>\nInteresting ports on localhost (127.0.0.1):<br \/>\nPORT\u00a0\u00a0\u00a0\u00a0\u00a0 STATE SERVICE<br \/>\n48915\/tcp open\u00a0 skype2<\/code><\/p>\n<p>Nmap done: 1 IP address (1 host up) scanned in 0.14 seconds<\/p>\n<p>Hmph.\u00a0 So much for cutting edge, never-been-done research.\u00a0 Go figure.<\/p>\n<h3>Fact 2:\u00a0 Given some UDP packets, Skype echos back a predictable pattern<\/h3>\n<p>For this part, we&#8217;re pretty sure no one else has tried this.<\/p>\n<p>While connected to Skype, we recorded some packets with tcpdump.\u00a0 We wrote a script that loaded up those packets, and could &#8220;replay&#8221; the packet payloads to an arbitrary IP and port.<\/p>\n<p>So, we played some packets against an IP\/port with Skype behind it.\u00a0 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;).\u00a0 But wayyyy down in the middle, there was a section of UDP packets that actually got a response:<\/p>\n<table style=\"width: auto;\" border=\"0\">\n<tbody>\n<tr>\n<td><a href=\"http:\/\/picasaweb.google.com\/lh\/photo\/Fs73oxvTCSJ--ZWG0blasw?feat=embedwebsite\"><img decoding=\"async\" src=\"http:\/\/lh6.ggpht.com\/_Kib24bTtAAU\/SxXKinoyE5I\/AAAAAAAAA9Q\/yd_K9mD355I\/s144\/Repeated%20UDPs.png\" alt=\"\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<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\" rel=\"noopener\">Misc Blog Images<\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<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?\u00a0 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>\n<p>So, is there a pattern in all of this?\u00a0 Actually yes.\u00a0 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>\n<p>The pattern:\u00a0 <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>\n<p>So, for example,\u00a0 one UDP payload we sent looked like this:<br \/>\n<code><br \/>\n92 40 02 a1 66 65 ea 0d 8c 82 c3 0c 27 cd c5 e7<br \/>\n4e 78 fe a1 50 a6<br \/>\n<\/code><br \/>\nAnd we got back:<br \/>\n<code><br \/>\n92 40 17 c0 a8 00 13 74 a0 41 f0<br \/>\n<\/code><br \/>\nSee that common 92 40?\u00a0 Bingo.\u00a0 \ud83d\ude09<\/p>\n<p>And it&#8217;s <em>pretty consistent<\/em> &#8211; if we repeat the same UDP packet, we get (almost) the same response.<\/p>\n<p><code><br \/>\n<strong>92 40<\/strong> 67 <strong>c0 a8<\/strong> <strong>00<\/strong> <strong>13<\/strong> 11 00 10 4f<br \/>\n<\/code><\/p>\n<p>And if we repeat again&#8230;<\/p>\n<p><code><br \/>\n<strong>92 40<\/strong> 37 <strong>c0 a8 00 13<\/strong> 68 08 43 3a<br \/>\n<\/code><\/p>\n<p>92, 40, and c0, a8, 00, 13.  Nice!\u00a0 Looks like a fingerprint to me!<\/p>\n<h3>Except&#8230;<\/h3>\n<p>Except, remember, we already found a way of determining whether or not Skype was running behind a given IP\/port.\u00a0 This last finding was just bonus.\u00a0 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.\u00a0 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.\u00a0 Push come to shove, we could always try to fingerprint a different protocol&#8230;maybe BitTorrent clients.<\/p>\n<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>\n<ul>\n<li><a href=\"http:\/\/nmap.org\/\">nmap:<\/a> port scanner that can also do service\/os fingerprinting<\/li>\n<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!\u00a0 We used Scapy as a library while writing our scripts.\u00a0 Lots of potential with this tool.\u00a0 Feel like poisoning an ARP cache?\u00a0 Scapy is for you!<\/li>\n<li><a href=\"http:\/\/www.wireshark.org\/\">Wireshark:<\/a> a network student&#8217;s best friend.<\/li>\n<\/ul>\n<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>\n","protected":false},"excerpt":{"rendered":"<p>As I said last week, I&#8217;ve been working with a partner (Mohammad Jalali) on a project for our networks course. The idea:\u00a0 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 [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[5,44,51],"tags":[577,574,564,568,571,576,578,569,1211,567,575,565,573,572,570],"class_list":["post-952","post","type-post","status-publish","format-standard","hentry","category-computer-science","category-internet","category-security","tag-fingerprint","tag-http","tag-networks","tag-nmap","tag-packets","tag-port-scanning","tag-protocol","tag-scapy","tag-security","tag-skype","tag-spoof","tag-tcp","tag-telnet","tag-udp","tag-wireshark"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/prmTy-fm","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/mikeconley.ca\/blog\/wp-json\/wp\/v2\/posts\/952","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mikeconley.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mikeconley.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mikeconley.ca\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/mikeconley.ca\/blog\/wp-json\/wp\/v2\/comments?post=952"}],"version-history":[{"count":18,"href":"https:\/\/mikeconley.ca\/blog\/wp-json\/wp\/v2\/posts\/952\/revisions"}],"predecessor-version":[{"id":3205,"href":"https:\/\/mikeconley.ca\/blog\/wp-json\/wp\/v2\/posts\/952\/revisions\/3205"}],"wp:attachment":[{"href":"https:\/\/mikeconley.ca\/blog\/wp-json\/wp\/v2\/media?parent=952"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mikeconley.ca\/blog\/wp-json\/wp\/v2\/categories?post=952"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mikeconley.ca\/blog\/wp-json\/wp\/v2\/tags?post=952"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}