<?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>tactical-it</title>
	<atom:link href="http://tactical-it.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://tactical-it.com</link>
	<description>code execution is inevitable.</description>
	<lastBuildDate>Fri, 13 Feb 2009 03:40:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>dns part ii: visualization</title>
		<link>http://tactical-it.com/2009/02/dns-part-ii/</link>
		<comments>http://tactical-it.com/2009/02/dns-part-ii/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 03:31:45 +0000</pubDate>
		<dc:creator>tranq</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tactical-it.com/?p=332</guid>
		<description><![CDATA[“The commonality between science and art is in trying to see profoundly &#8211; to develop strategies of seeing and showing.” &#8212; Edward Tufte
Shortcut:  check out the normal demo, the demo with DNS tunnel traffic, or just download the code and run it with your own captures.
As I wrote in a study of DNS, current tools [...]]]></description>
			<content:encoded><![CDATA[<p><span class="sqq"><a href="http://tactical-it.com/wp-content/uploads/2009/02/picture-1.png"><img class="alignleft size-full wp-image-355" style="padding-right: 5px;" title="dns-typical-view" src="http://tactical-it.com/wp-content/uploads/2009/02/picture-1.png" alt="dns-typical-view" width="175" /></a>“<em>The commonality between science and art is in trying to see profoundly &#8211; to develop strategies of seeing and showing.</em>” &#8212; <a href="http://www.edwardtufte.com">Edward Tufte</a></span></p>
<p><em><strong>Shortcut</strong></em>:  check out the normal <a href="http://tactical-it.com/static/DNSViz/typical/" target="_blank">demo</a>, the <a href="http://tactical-it.com/static/DNSViz/tunnel/" target="_blank">demo with DNS tunnel traffic</a>, or just download the <a href="http://tactical-it.com/code/dns-visualization/">code</a> and run it with your own captures.</p>
<p><span class="sqq">As I wrote in <a href="http://tactical-it.com/2009/01/a-study-of-dns/">a study of DNS</a>, current tools don&#8217;t detect DNS tunnels.  After opening the post ranting about static signatures, I recommended alerting on any hostname request longer than 52 characters or with more than 27 characters. <em>(ahem) </em>It&#8217;s fair to call my recommendation a signature.</span></p>
<p><span class="sqq">Static signatures are great at identifying an already-known attack.   A signature allows you to search immense data for specific details, but the precision provides little </span><span class="sqq"> awareness of your network traffic in general.  By the measure of the tools they&#8217;ve provided, few in industry appreciate the value of context for decision making. </span></p>
<p><span class="sqq">After completing the DNS traffic analysis, I was still unsatisified.  I studied the statistical outliers, but it was too hard to understand the nuances, too hard to put those outliers in context with the normal traffic.  My eyes were crossing studying lines of text, endlessly cut-ing, grep-ing, sort-ing and uniq-ing to manipulate the text.   meh.<br />
</span></p>
<h3>Visualization</h3>
<p><span class="sqq">Using <a href="http://processing.org">processing</a>, I graphed 4 characteristics of each request and displayed them in a 2d x-y grid in real-time.<br />
</span></p>
<ul>
<li><span class="sqq">x-axis: destination IP</span></li>
<li><span class="sqq">y-axis: character count</span></li>
<li><span class="sqq">radius: hostname length</span></li>
<li><span class="sqq">colour: request type</span></li>
</ul>
<p><span class="sqq">Areas with multiple requests increase in intensity and become white-hot as new types appear, so rate indirectly becomes a 5th characteristic.<br />
</span></p>
<p style="text-align: center;"><a href="http://tactical-it.com/wp-content/uploads/2009/02/picture-1.png"><img class="aligncenter size-full wp-image-355" title="dns-typical-view" src="http://tactical-it.com/wp-content/uploads/2009/02/picture-1.png" alt="dns-typical-view" width="300" /><br />
</a>[<a href="http://tactical-it.com/wp-content/uploads/2009/02/picture-1.png">image - typical</a>] [<a href="http://tactical-it.com/static/DNSViz/typical/" target="_blank">applet - typical</a>]<a href="http://tactical-it.com/wp-content/uploads/2009/02/picture-1.png"></a></p>
<p><span class="sqq">Pictures are a poor representation of the live animation.  You should <a href="http://tactical-it.com/static/DNSViz/typical/" target="_blank">run the demo yourself</a>. </span><span class="sqq">(The base32&#8242;ed TXT record request you&#8217;ll see was in the real capture.) </span><span class="sqq">The data is a sanitized sample of 1800 requests from the same dataset <a href="http://tactical-it.com/2009/01/a-study-of-dns/">discussed before.</a> While my data is academically interesting, I recommend analyzing your own.  <a href="http://tactical-it.com/code/dns-visualization/">Download the code</a> and use your own captures. </span></p>
<p><span class="sqq">I started analysis focused on DNS tunnel detection, so the demonstration is not complete until we see DNS tunnel traffic.  Using <a href="http://www.hsc.fr/ressources/outils/dns2tcp/index.html.en">dns2tcp</a>, I setup the DNS client/server, ssh&#8217;ed into my own machine over DNS and captured the result.<br />
</span></p>
<div id="code">
<pre style="text-align: left;">tranq:~ tranq$ ssh -p 2200 tranq@127.0.0.1
Password:
Last login: Sat Feb  7 12:53:01 2009 from localhost
tranq:~ tranq$ ls -laRtp
...^C</pre>
</div>
<p>For a realistic view, I put the DNS tunnel traffic in context with the sample data from the applet above.  This is real DNS tunnel traffic in context with DNS traffic from a real network perimeter.</p>
<p style="text-align: center;"><span class="sqq"><a href="http://tactical-it.com/wp-content/uploads/2009/02/picture-3.png"><img class="aligncenter size-full wp-image-396" title="picture-3" src="http://tactical-it.com/wp-content/uploads/2009/02/picture-3.png" alt="picture-3" width="300" /></a><br />
</span>[<a href="http://tactical-it.com/wp-content/uploads/2009/02/picture-3.png">image - tunnel</a>] [<a href="http://tactical-it.com/static/DNSViz/tunnel/" target="_blank">applet - tunnel</a>]<a href="http://tactical-it.com/wp-content/uploads/2009/02/picture-3.png"></a></p>
<h3><span class="sqq">Thoughts&#8230;</span></h3>
<p><span class="sqq">I studied the same 97,000 requests for several weeks before graphing the results.  Even after weeks of study, I learned even more about the dataset in just a few minutes<em>.</em></span></p>
<p><span class="sqq">My graph layout went through several iterations.  Some good things about where I ended up:<br />
</span></p>
<ul>
<li><span class="sqq"><em>DNS request anomalies: </em>Abnormal traffic stands out naturally, without any threshold or static values.   The DNS tunnel traffic is startlingly </span><span class="sqq">abnormal.  The base32&#8242;d TXT record requests to smupdate.net and the TXT record requests to mac.com are less so, but still stand out as unusual. Neither are suspicious,  but both are likely indications of a security policy violation.</span></li>
<li><span class="sqq"><em>SRV records: </em>The SRV records you see are not for the organization.  Those were answered by the internal DNS server and did not get forwarded.  Every SRV record collected is a laptop from another company&#8217;s domain.  Attaching a non-company laptop is aganist the company security policy, but it&#8217;s obviously happening.  In the course of the hour-long capture, there were SRV record requests for </span><span class="sqq">4 </span><span class="sqq">other domains.<br />
</span></li>
<li><span class="sqq"><em>Rate consolidation: </em>If you refer to the hostname distribution analysis in <a href="http://tactical-it.com/2009/01/a-study-of-dns/">a study of DNS</a>, you will see the  huge spike of 5,000ish requests for myspace records on <a href="http://www.limelightnetworks.com/">Limelight Network&#8217;s</a> CDN.  Where they overwhelmed the distribution chart, they have been nicely consolidated in the graph around (65, 20) into a single bright greeen area.  If you hover over the point, you&#8217;ll see the hostnames under your cursor shoot off the screen.  I stripped out the sorbs and PTR lookups; they were equally nominal when put in context.<br />
</span></li>
<li><span class="sqq"><em>Destination context: </em>The heavily-populated strips coincide with servers located in North America, consistent with the organization&#8217;s clients.  While we have significant data occlusion in these areas, any activity in the the lesser-tracked corners of the Internet naturally stands out more.<br />
</span></li>
</ul>
<p><span class="sqq">The data representation is not perfect:</span></p>
<ul>
<li><span class="sqq"><em>Rate:</em> The rate representation does not have much fidelity.  Two is distinguishable from one and ten is distinguishable from two, but two hundred is not distinguishable from ten.  In the case of the myspace/llwnd anomaly, this is perfect. But even though we&#8217;ve significantly lowered the noise floor, an attacker could still hide in the noise at the cost of exfil bandwidth.   This is mitigated by &#8220;flashing&#8221; new requests, but that technique only applies to real-time analysis. <em><br />
</em></span></li>
<li><span class="sqq"><em>Window of analysis</em>: In it&#8217;s current form, an analyst must watch the console at all times.  If the request data was maintained in persistent storage instead of temporarily stored in memory, someone could view arbitrary time windows.  The same visualization scales to represent thousands of requests without much visual clutter.<br />
</span></li>
<li><span class="sqq"><em>Presumption of capture location</em>:  by giving the destination IP such predominance, I&#8217;ve limited the location your collector can sit to outside your external DNS server.<br />
</span></li>
</ul>
<p>If I were responsible for managing a network perimeter day-to-day, I would want something like this to monitor my DNS traffic.  Unfortunately, industry has shipped very few tools to get this kind of insight.  <em><strong>Admins</strong></em>:  ask industry for better traffic monitoring tools.  Be smart enough to use them and give good feedback. <strong><em>Vendors</em></strong>:  ignore the media-generated fear of day from the latest malware author to grab headlines and study the adversary.  Network security is not a boring support function, but a tactical engagement.   The ramifications of a tactical mindset are immense, and we need the industrial base to adopt it.</p>
<p>I appreciate criticisms, suggestions or screenshots of your own network traffic!</p>
]]></content:encoded>
			<wfw:commentRss>http://tactical-it.com/2009/02/dns-part-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>a study of DNS</title>
		<link>http://tactical-it.com/2009/01/a-study-of-dns/</link>
		<comments>http://tactical-it.com/2009/01/a-study-of-dns/#comments</comments>
		<pubDate>Fri, 30 Jan 2009 19:56:51 +0000</pubDate>
		<dc:creator>tranq</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tactical-it.com/?p=18</guid>
		<description><![CDATA[&#8220;I assume you all know the benefits of using a bastion host and filtering all other hosts out so people don&#8217;t tunnel data in UDP packets.  Well, it&#8217;s not enough anymore.&#8221;
Oskar Pearson, 1998 on Bugtraq
[announcement]
That was ten years ago.  Since then:

Frodo &#38; Sky, NSTX &#8220;Name Server Transport&#8221;, 2000: [docs] [earliest ref]
Kaminsky, BlackHat 2004 [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>&#8220;I assume you all know the benefits of using a bastion host and filtering all other hosts out so people don&#8217;t tunnel data in UDP packets.  Well, it&#8217;s not enough anymore.&#8221;<br />
<em>Oskar Pearson, 1998 on Bugtraq</em><br />
[<a href="http://groups.google.com/group/muc.lists.bugtraq/msg/c8ed462bac818e40">announcement</a>]</p></blockquote>
<p>That was ten years ago.  Since then:</p>
<ul>
<li><strong>Frodo &amp; Sky</strong>, NSTX &#8220;Name Server Transport&#8221;, 2000: [<a href="http://thomer.com/howtos/nstx.html">docs</a>] [<a href="http://slashdot.org/articles/00/09/10/2230242.shtml">earliest ref</a>]</li>
<li><strong>Kaminsky,</strong> BlackHat 2004 on DNS tunnelling. [<a href="http://www.blackhat.com/presentations/bh-usa-04/bh-us-04-kaminsky/bh-us-04-kaminsky.ppt">ppt slides</a>] [<a href="http://www.doxpara.com/ozymandns_src_0.1.tgz">source</a>]</li>
<li><strong>Split DNS</strong>: <a href="http://monkey-house-org.blogspot.com/2006/08/top-10-dns-infrastructure-best.html">Consistently</a> <a href="http://www.cs.miami.edu/~burt/local/cs-arch-2002/split-dns.html">referenced</a> as the <a href="http://blogs.isaserver.org/shinder/2006/10/19/dns-best-practices"></a>best <a href="http://austinissa.org/public_files/presentations/200308%20Active%20Directory%20Security.ppt">practice</a> for enterprise DNS deployment.</li>
<li><strong><a href="http://www.google.com/search?q=software+to+detect+dns+tunnels">Google</a> for help finding DNS tunnels</strong> &#8211; Hit two: <em>Software which has functionality to detect this is unfortunately in scarce supply.</em> [<a href="http://www.daemon.be/maarten/dnstunnel.html">ref</a>]</li>
</ul>
<h3>The frustrating world of an enterprise network administrator</h3>
<p>You have configured your network with split DNS.  You have implemented &#8220;block all, allow by exception&#8221; at the firewall and have documented every exception.  You use an authenticated web proxy and require authentication for each new HTTP session. Yet with no prior knowledge of your network and little complexity, an attacker can still tunnel arbitrary traffic through your perimeter when he gains execution.  (<em>And we know </em><a href="http://tactical-it.com/2009/01/intrusion-exercise/"><em>arbitrary code execution is inevitable</em></a><em>.</em>)</p>
<p>Even with awesome funding and a rockstar team, there is little you can do short of blocking all external DNS for internal hosts.  Neither industry nor academia has shipped the right tools to detect DNS protocol abuses.  The only two reasonable recommendations are <a href="http://www.daemon.be/maarten/dnstunnel.html#detect">static signatures</a> to detect public tunnel implementations or <a href="http://blog.vorant.com/2006/05/traffic-analysis-approach-to-detecting.html">traffic analysis with Sguil</a> to detectunusual transfer rates.</p>
<p><strong>Analysis of Current Recommendations</strong></p>
<p>Static signatures are necessary but insufficient.  At the static signatures link above, the first recommended signature alerts on 20 TXT records requests within 60 seconds. The second recommended signature alerts on the unique value NSTX puts in the DNS header. Unfortunately, DNS tunnels do not have to use TXT records &#8211; and  if they do use TXT records, they are certainly not required to make 20 TXT requests within 60 seconds. (<em>with the implementations below, 19 requests/second would get about 2kBytes/second exfil and 9.5kBytes/second infil</em>) Finally, they don&#8217;t have to include NSTX&#8217;s hardcoded value. Static signatures highlight gross offenses, but do not assume they make your network secure.</p>
<p>The Sguil analysis is better than static signatures, but is easily circumvented.  Bianco looks for &#8220;lopsided transfers,&#8221;  when the gross transfer rate (src_bytes / dst_bytes) is greater than a hardcoded ratio (2x, in his case) and the client-server pair has transferred at least 50k bytes in the previous 24 hours.  While the methodology does not limit analysis to TXT records,  there are still problems:</p>
<ul>
<li>It only examines a single client-server IP pair. DNS&#8217;s intrinsic redundancy/forwarding/recursion make IPs less important.  Regardless of where your IDS sits in the network hierarchy, two consecutive requests from the same client to the same domain name may not have the same source &amp; destination IPs.</li>
<li>The ratio is crucial to detection.  As Bianco notes, he looks only for DNS infil or DNS exfil.  If the amount of data transferred is roughly balanced between client and server, the ratio won&#8217;t break the threshold.  (i.e., if the attacker downloads 10 MB, he needs to upload between 5 and 20 MB to keep the ratio below the threshold)</li>
<li>The ratio is too simple a measure for small transfers, so Bianco needed a safety net:  only client-server pairs with at least 50k transferred in the previous 24 hours.</li>
</ul>
<p>It&#8217;s less brittle than a signature, but it still requires static thresholds.   Like the snort signatures, anything below the threshold is off your radar.</p>
<p>One final consideration:</p>
<blockquote><p>&#8220;Writing signatures is kinda rookie&#8221;<br />
<em>Joanna Rutkowska, BlackHat 2006 <span style="font-style: normal; "><br />
[<a href="http://www.blackhat.com/presentations/bh-usa-06/BH-US-06-Rutkowska.pdf">pdf slides</a>] [<a href="http://theinvisiblethings.blogspot.com/2006/06/introducing-blue-pill.html">writeup</a>]</span></em></p></blockquote>
<p>Joanna was talking about rootkit detection, but the idea is the same.</p>
<h3>DNS tunnels in practice</h3>
<p>DNS revolves around reliability and <em>forwarding.</em> If a DNS server cannot answer a question, it asks the authoritative server.  When an attacker controls both the client asking the question and the server providing the response he can transfer arbitrary data, but only <em> within the bounds of the protocol specification.</em></p>
<p>As Bianco noted, DNS tunnel traffic can flow in three ways: data infil only, data exfil only, or full two-way communication.  The DNS server cannot initiate communication, it can only respond to requests from the client.  The response from a DNS server can be any one of a dozen different types (A, CNAME, TXT, MX, etc) and each of these is formatted differently.   But for all the diversity in the server&#8217;s response format, each response must correspond to a request and the requests can only be one format:  a hostname and the desired record type.</p>
<p>From <a href="http://www.ietf.org/rfc/rfc1035.txt">RFC 1035</a>, hostnames must meet the folllowing criteria:</p>
<ul>
<li>Allowed characters a-z, 0-9 and &#8211; (dash); this means a total of 26 + 10 + 1 or 37 characters</li>
<li>Labels (<em>between the .&#8217;s</em>) of 63 characters or less</li>
<li>Total size 255 characters (including &#8216;.&#8217; label delimiters) or fewer</li>
</ul>
<p>Data exfil and full comms require the client to encode outbound data in questions.  We can identify those abuses by <em>analyzing only outbound hostname requests.</em> This simplifies analysis significantly and leaves the uninspected space at data infil only.  While data infil over DNS has potential benefits for an attacker, (<em>refer to Blackhat 2008 talk on DNS Shellcode [</em><a href="http://www.blackhat.com/presentations/bh-usa-08/Miller/BH_US_08_Ty_Miller_Reverse_DNS_Tunneling_Shellcode.pdf"><em>pdf slides</em></a><em>]</em>) the danger relative to data exfil or two-way communications is significantly reduced.</p>
<h3><strong>Real-world DNS hostname request analysis</strong></h3>
<p>The folllowing analysis was completed on a packet capture from a <em>small-ish corporate network perimeter</em> with split DNS and 100s of hosts.  In total, about <em>97,000 outbound DNS requests</em> over an hour.</p>
<p>Based on the rationale above, I selected 3 characteristics of the hostname requests to analyze.</p>
<ul>
<li>Length of hostname</li>
<li>Count of unique characters <em>(suspecting base32&#8242;d text has a higher count than &#8220;normal&#8221; text)</em></li>
<li>Request type <em>(Allows 1-255; dozens of defined types, about ten &#8216;typical&#8217; types)</em></li>
</ul>
<div id="attachment_123" class="wp-caption aligncenter" style="width: 410px"><a href="http://tactical-it.com/wp-content/uploads/2009/01/count-by-length.png"><img class="size-full wp-image-123" title="dns-count-by-length" src="http://tactical-it.com/wp-content/uploads/2009/01/count-by-length.png" alt="Count of requests by length" width="400" /></a><p class="wp-caption-text">Count of requests by length</p></div>
<p>The chart above shows the distribution of hostname lengths for all 97,000 recorded requests.  The x-axis only extends to 76, because that was the absolute maximum recorded value, despite the DNS RFC&#8217;s maximum of 255.  The spike between 31 and 39 results from traffic from the internal SMTP server:  for every SMTP session it uses the <a href="http://www.au.sorbs.net/">SORBS real-time blackhole list</a>.  Each connection causes a request such as:</p>
<div id="code">
<pre>44.33.22.11.spam.dnsbl.sorbs.net.</pre>
</div>
<p>The height of the spike is relative to the number of connections to the mail server during the capture; the width is due to IP address length variations.</p>
<p>The spike clustered around 26 are outgoing reverse lookups, of the format:</p>
<div id="code">
<pre>44.33.22.11.in-addr.arpa.</pre>
</div>
<p>Again, the width of the spike is related to IP length variability.</p>
<p>The final spike around 25 is from 5,000 myspace.com A record requests of the form:</p>
<div id="code">
<pre>myspace-690.vo.llnwd.net.</pre>
</div>
<p>During the capture, one or more hosts queried nearly every record from myspace-000 to myspace-999 and each request was sent to four nameservers.  I do not have an explanation for this anomaly; perhaps it&#8217;s a bug in some two-bit multimedia app streaming videos from <a href="http://www.llnwd.net">Limelight Networks</a>.</p>
<p>If we break out the RBL and reverse lookups, the resulting chart of hostname lengths is more reasonable.  Removing the 3 known oddities, hostname request lengths are roughly normally distributed around 18 characters.</p>
<div id="attachment_170" class="wp-caption aligncenter" style="width: 410px"><a href="http://tactical-it.com/wp-content/uploads/2009/01/picture-2.png"><img class="size-full wp-image-170" title="dns-request-by-type" src="http://tactical-it.com/wp-content/uploads/2009/01/picture-2.png" alt="Count of requests by major sub-type" width="400" /></a><p class="wp-caption-text">Count of requests by major sub-type</p></div>
<p>The next chart is the count of characters per hostname request.  Any request exfil&#8217;ing arbitrary data must encode it into the 37 characters allowed by DNS.   Any encoding method will increase the entropy of a hostname request over normal lookups, unless the attacker sacrifices his encoding efficiency and thus his bandwidth.</p>
<div id="attachment_136" class="wp-caption aligncenter" style="width: 410px"><a href="http://tactical-it.com/wp-content/uploads/2009/01/char-count-total.png"><img class="size-full wp-image-136" title="char-count-total" src="http://tactical-it.com/wp-content/uploads/2009/01/char-count-total.png" alt="Count of requests with given character count" width="400" /></a><p class="wp-caption-text">Count of requests with given character count</p></div>
<p>The absolute maximum value recorded was 29, but counts taper off dramatically in the low 20s. The spike around 19 is also due to the SORBS RBL requests.</p>
<p><a href="http://en.wikipedia.org/wiki/Internationalized_domain_name">Internationalized Domain Names</a>, the scheme to support unicode DNS names, will increase the character count and average lengths.  Relative to DNS tunnel implementations, the differences are minor.</p>
<p><strong>Stats summary</strong></p>
<table class="pretty-table" border="0">
<caption>Summary of length measurements</caption>
<tbody>
<tr>
<th scope="col">Type</th>
<th scope="col">percent</th>
<th scope="col">max</th>
<th scope="col">min</th>
<th scope="col">mode</th>
</tr>
<tr>
<th scope="row">A</th>
<td>97%</td>
<td>65</td>
<td>6</td>
<td>35</td>
</tr>
<tr>
<th scope="row">MX</th>
<td>1.5%</td>
<td>38</td>
<td>7</td>
<td>13</td>
</tr>
<tr>
<th scope="row">SRV</th>
<td>0.15%</td>
<td>76</td>
<td>22</td>
<td>22</td>
</tr>
<tr>
<th scope="row">TXT</th>
<td>0.1%</td>
<td>21</td>
<td>10</td>
<td>21</td>
</tr>
<tr>
<th scope="row">SOA</th>
<td>0.06%</td>
<td>33</td>
<td>7</td>
<td>23</td>
</tr>
<tr>
<th scope="row">Total</th>
<td>100%</td>
<td>76</td>
<td>6</td>
<td>35</td>
</tr>
</tbody>
</table>
<ul>
<li><em>Length:</em> overall average: 28.0 std dev: 7.9</li>
<li><em>Character:</em> overall average: 15.6 std dev: 3.6</li>
</ul>
<p>Without the 3 oddities, lengths and character counts are roughly normally distributed.   Statisticians will tell you to ignore the oddities and roll, quoting the <a href="http://en.wikipedia.org/wiki/Central_limit_theorem">Central Limit Theorem</a> and <a href="http://en.wikipedia.org/wiki/Chebyshev%27s_inequality">Chebyshev&#8217;s Inequality</a> as support.  With those considerations, we calculate the following upper thresholds:</p>
<ul>
<li><em>Length</em>: 99.75% less than 28 + 3(7.9) = 52 characters</li>
<li><em>Character count</em>: 99.75% less than 15.6 + 3(3.6) = 27 characters</li>
</ul>
<h3>Real-world analysis of DNS tunnel traffic</h3>
<p>The real question: how do the thresholds compare to the available DNS tunnels?  There are only three publicly-available DNS tunnel implementations: <a href="http://www.google.com/search?q=download+nstx">NSTX</a>, <a href="http://www.doxpara.com/ozymandns_src_0.1.tgz">OzymanDNS</a> and <a href="http://www.hsc.fr/ressources/outils/dns2tcp/index.html.en">dns2tcp</a>. (I can&#8217;t find source for Pearson&#8217;s implementation.  If you can put your hands on it, <a href="mailto:tranquilo@tactical-it.com">mail me</a>.)</p>
<p><strong>Ozyman</strong></p>
<p>Kaminsky&#8217;s Ozyman implementation uses hostname requests for the outbound, and TXT records on the return. The format of the outbound requests is:</p>
<pre>(data).(nonce)-(checksum).id-(sessid).up.(domain.com)</pre>
<ul>
<li><strong>data</strong> &#8211; base32&#8242;d data, up to 110 bytes before encoding, 176 after encoding.</li>
<li><strong>nonce</strong> &#8211; a safety check for DNS servers that do not respect TTLs</li>
<li><strong>checksum</strong> &#8211; checksum of the data blob; actually ununsed.  Always zero.</li>
<li><strong>sessid</strong> &#8211; a session id for the server to keep track of clients.</li>
</ul>
<p>To transfer the Ozyman DNS source tarball to the server at domain.com:</p>
<div id="code">
<pre>tranq$ cat ozymandns_src_0.1.tar.gz | ./droute.pl domain.com</pre>
</div>
<p>Yields a request similar to:</p>
<div id="code">
<pre>mfzwwyjoobwaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaagaytambxgayaambq.
59534-0.id-40145.up.domain.com.</pre>
</div>
<p><strong>Length:</strong> 209<br />
<strong>Char count:</strong> 27</p>
<p>176 bytes of base32 encoded data in the first three labels, 17 bytes of housekeeping, a 9 byte domain name and 7 label separators.  This is a simplified description of his transport, but you get the idea.</p>
<p><strong>NSTX</strong></p>
<p>NSTX uses the same techniques.  A review of the source details 3&#215;63 byte labels max on hostname requests and TXT records on the return . Hostname lengths will be greater than 189 bytes under full load. NSTX uses a case-sensitive encoding, if the character count is case sensitive, they will greatly surpass DNS&#8217;s 37 case-insensitive character max.</p>
<p><strong>dns2tcp</strong></p>
<p><strong>UPDATE: </strong>A reader brought my attention to <a href="http://www.hsc.fr/ressources/outils/dns2tcp/index.html.en">dns2tcp</a>, a third public DNS tunnel implementation by the (<a href="http://www.hsc.fr/ressources/articles/win_net_srv/index.html"><em>awesome</em></a>) <a href="http://hsc.fr">hsc.fr</a> guys.  dns2tcp also uses base64, so character counts will be huge if your character counts are case-sensitive.   Hostname requests lengths are about 190 under full load, with TXT records on the return.</p>
<h3>Conclusions</h3>
<p>The two public DNS tunnel implementations destroy the length and character count thresholds.  Even simpler than <a href="http://blog.vorant.com/2006/05/traffic-analysis-approach-to-detecting.html">Bianco&#8217;s src_bytes / dst_bytes ratio</a>, analyzing only hostname requests is enough to detect NSTX and Ozyman DNS tunnel implementations.  While false positives will appear, visual inspection will immediately recognize encoded data.  The thresholds could be improved even further by a high-level categorization of request type.  In this case, we could have created 3 thresholds:</p>
<ul>
<li>Requests to the SORBS RBL</li>
<li>Requests for reverse lookups</li>
<li>All other requests</li>
</ul>
<p>&#8220;All other requests&#8221; has significantly lower thresholds than the combination of all three categories.</p>
<p>Alternatively, thresholds could be set arbitrarily high. It is obscured by the volume, but there are hundreds of requests with lengths greater than 52 characters.  The false positive rate will be too high for many organizations.  There were no requests with length greater than 76 characters, but both DNS tunnel implementations have significantly higher request lengths.  A &#8220;sanity check&#8221; length threshold around 75 would provide some peace of mind.</p>
<p>The largest problem with outgoing hostname analysis is the toolchain.  The analysis requires an IDS parsing application-level data.  Some commercial IDSes parse application-level traffic and have alerts in place, but none of the IDSes I&#8217;m familiar with abstract it into a generic application-level signature engine.  A commercial vendor with an application-level-aware IDS could wrap request analysis into a built-in signature, but the thresholds will vary for each organization.  The arbitrary threshold a vendor configures will be the lowest common denominator of all organizations.   I want the ability to write a signature such as:</p>
<div id="code">
<pre>length(dns.request.hostname) &gt; 52 and
(not "sorbs" in dns.request.hostname) and
(not "in-addr.arpa" in dns.request.hostname)</pre>
</div>
<p>..and apply it to all DNS traffic, then tweak the logic as I more deeply understand my perimeter&#8217;s traffic.  Alas, all I usually get is a clumsy web GUI and a few checkboxes.</p>
<p><strong>Vendors</strong>: make your products flexible and smarter than your average customer.  Those with the desire and capability will pay whatever you ask.</p>
<p><strong>Colleagues</strong>: how universal are these thresholds?  I have code to parse pcaps and output these statistics.  <a href="mailto:tranquilo@tactical-it.com">Email me</a> and I&#8217;ll send them to you.  Send me your statistics and I&#8217;ll post them all in a single place.  Post it on your own blog and I&#8217;ll link to it.</p>
<p><em>It is ironic I start this post ranting against static thresholds and then end it by suggesting one.  Stay tuned; I have an answer to this disparity in development!<br />
&#8211; tranq</em></p>
]]></content:encoded>
			<wfw:commentRss>http://tactical-it.com/2009/01/a-study-of-dns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>an exercise in network intrusions</title>
		<link>http://tactical-it.com/2009/01/intrusion-exercise/</link>
		<comments>http://tactical-it.com/2009/01/intrusion-exercise/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 11:43:12 +0000</pubDate>
		<dc:creator>tranq</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://tactical-it.com/?p=63</guid>
		<description><![CDATA[Penetration Testing: Dead in 2009
Bill Brenner, paraphrasing Brian Chess, CSO Online, 8 Dec 08
Brian Chess stirred things up last month by declaring pen testing dead in 2009.  Ivan Acre wrote a response, also for CSO Online: &#8220;Twelve Reasons Pen Testing Won&#8217;t Die.&#8221;   Matasano declared the statement irrelevant: &#8220;[pen testing] is synonymous with security assessments&#8230;most of [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Penetration Testing: Dead in 2009<br />
<em>Bill Brenner, paraphrasing Brian Chess, <a href="Penetration Testing: Dead in 2009">CSO Online, 8 Dec 08</a></em></p></blockquote>
<p>Brian Chess stirred things up last month by declaring pen testing dead in 2009.  Ivan Acre wrote a response, also for CSO Online: &#8220;<a href="http://www.csoonline.com/article/470584/Twelve_Reasons_Pen_Testing_Won_t_Die">Twelve Reasons Pen Testing Won&#8217;t Die.</a>&#8221;   Matasano <a href="http://www.matasano.com/log/1331/penetration-testing-dead-not-dead/">declared the statement irrelevant</a>: &#8220;[pen testing] is synonymous with security assessments&#8230;most of my customers use these words interchangeably, and they are some of the most sophisticated purchasers of security.&#8221;  Eduardo <a href="http://camargoneves.com/2008/12/18/penetration-test-sempre-questionado/">dicho la misma</a>.   </p>
<p>The whole affair is silly.  Everyone is using the same words, but not talking about the same thing.  It highlights the immaturity of our industry:  we don&#8217;t have consistent terminology, much less a common  framework to clarify issues.</p>
<h3>Inconsistent terminology makes drama</h3>
<p>Each of these posts used &#8220;penetration test&#8221; differently:</p>
<ul>
<li><em>network vulnerability assessment</em> &#8211; a comprehensive network scan to identify vulnerabilities in all network-facing applications</li>
<li><em>application penetration test </em>- a comprehensive application review to identify vulnerabilities in one network-facing application</li>
<li><em>network penetration test </em>- an attempt to exploit vulnerabilities to gain illegitimate access</li>
</ul>
<p>As the folks over at SecurityCurve <a href="http://www.securitycurve.com/blog/archives/000539.html">note</a>, the Payment Card Industry <a href="https://www.pcisecuritystandards.org/security_standards/pci_dss_download.html">Data Security Standard&#8217;s</a> requirement 11.3 dictates both a network pen test and an application pen test each year.   Requirement 11.2 dictates a network vulnerability assessment.  SecurityCurve uses the standards to support their position pen testing isn&#8217;t going anywhere soon; I&#8217;ll use it to reinforce the terminology distinction.</p>
<p>An application penetration test is part of <em>software development</em>.  The release schedule should provide ample time for review after code freeze.  The process should be an orderly progression of iteratively fewer changes.  Network vulnerability assessments and network penetration tests are part of <em>network operations</em>.  The only place the pieces come together is on the live network.  Smart admins and good configuration control make the process as orderly as possible, but network disorder increases with the number of network clients.</p>
<p>Brenner&#8217;s article was sloppy.  He characterized Chess&#8217;s definition of penetration testing as &#8220;<em>the art of probing company networks in search of exploitable security holes that can then be fixed.</em>&#8221;    This clearly refers to network penetration testing, but the rest of the article mixed quotes about network penetration tests (Jabbusch) and application penetration tests (Caceres, Riggins).  It&#8217;s pretty easy to fabricate drama when you&#8217;re asking your sources two different questions.  Did I mention our community needs an common framework?</p>
<p>Chess intended to discuss application penetration testing, obvious since Chess runs a company <a href="http://www.fortify.com/products/">specializing in source code analysis</a>.  For software development, Microsoft&#8217;s <a href="http://msdn.microsoft.com/en-us/security/cc448177.aspx">SDL</a> is arguably the industry&#8217;s exemplar &#8212; including <a href="http://msdn.microsoft.com/en-us/library/cc307418.aspx#ECAA">application pen testing</a> immediately prior to release.  There&#8217;s no real contender for the industry&#8217;s network operations equivalent.  I can&#8217;t fill that role, but I&#8217;ll continue this pen testing conversation.</p>
<h3>Network penetration testing:  please die in 2009</h3>
<p>I&#8217;ll be as clear as I can be:  network penetration testing needs to die in 2009.</p>
<p>Four days before Chess&#8217;s &#8220;Pen testing will die,&#8221; Jack at Uncommon Sense Security wrote:</p>
<blockquote><p>Come on, there are really only two possible outcomes to a penetration test:<br />
ONE: You confirm something you already know, that you are vulnerable to a sufficiently skilled and determined attacker.<br />
TWO: The Penetration Tester you hired isn&#8217;t good enough.<br />
Uncommon Sense Security, <a href="http://blog.uncommonsensesecurity.com/2008/12/fallacy-of-penetration-testing.html">The Fallacy of Penetration Testing, 4 Dec 08</a></p></blockquote>
<p>A network pen test typically asks one question:  can someone get in?  I&#8217;ll save you the cost of those consultants and answer: <strong> yes</strong>.   If you&#8217;re looking for a binary answer and pay <em>anything</em> to get it, it is too much.   Here&#8217;s one crucial point:  in the real world, the bad guy comes after your network at the <em>time and place of his choosing.</em><strong> </strong>It&#8217;s an easy equation:  <strong>(1)</strong> he documents your network-facing services, <strong>(2) </strong>waits until a matching vulnerability is published, <strong>(3) </strong>exploits it before you patch it.  As soon as you limit pen testers to an artificial time window, you remove a crucial attacker advantage.</p>
<p>Attacker advantages don&#8217;t stop at time.  Even if you minimize risk to patch cycle exploitation, there&#8217;s still inadvertent user actions on your network: through <a href="http://www.microsoft.com/protect/yourself/phishing/spear.mspx">email,</a> <a href="http://blog.trendmicro.com/another-malware-pulls-an-italian-job/">web</a>, <a href="http://www.symantec.com/business/resources/articles/article.jsp?aid=20070924_network_access_control_to_the_rescue">returning laptops</a> or even <a href="http://www.wired.com/entertainment/music/magazine/16-01/ff_args">USB drives in the bathroom</a>.  Even if your user training is top-notch, there&#8217;s still physical access: through <a href="http://www.informationweek.com/news/mobility/showArticle.jhtml?articleID=199500385">wireless</a>, <a href="http://www.juniper.net/solutions/enterprise/retail/index.html">network endpoints in a retail store</a>, etc.   As the value of your data increases, the likelihood of a trusted user being <a href="http://www.cert.org/insider_threat/">coerced to assist</a> also increases.  The attack vectors are too numerous; networks do not have nicely fenced perimeters with a single exit gate at the firewall.   As long as your threat models assume so, you&#8217;re no better off than the French and their ill-fated <a href="http://en.wikipedia.org/wiki/Maginot_Line">Maginot Line</a>.  The constancy of ankle-biter malware on your network should be evidence enough.  Arbitrary code execution is inevitable.</p>
<p>You do not need a pen test to test the effectiveness of your network protection measures, you need a pen test to exercise your detection and response measures.</p>
<p>Network security is equal parts protection, detection and response.  Protection is the first line of defense, but when protections are insufficient, you must be able to detect the attacker and initiate appropriate response actions.   Protection is critical, but <em>you can not stop a patient and resourceful attacker.</em><strong> </strong>When he lands inside your network, what&#8217;s your level of confidence your systems will detect his presence?  Sure, if he uses a cleartext command shell, Snort will trigger.  Sure, if the same code/servers/domains are used in 10 bajillion other places, your enterprise antivirus will quarantine the binaries.    But if his network traffic is SSL and his binaries use a <a href="http://securitylabs.websense.com/content/Blogs/3239.aspx">custom packer </a>to evade AV signature?</p>
<p>I&#8217;ll save you cost of the consultants again:  you won&#8217;t detect him.</p>
<h3>Pen testing: a detection and response exercise</h3>
<p>Admittedly, the realities are more complicated.  Your tools are more diverse and attackers are sloppy, leaving ample traces to detect.  Here&#8217;s the $64,000 question:  when your security guy sits at his console Monday morning &#8212; cup of coffee in hand, slightly hungover from watching rugby at the pub the night before &#8212; will he recognize the signs?  Or will he just scowl, grumble and move on?   <strong>Pen testing should be a detection and response exercise. </strong> Not only do we have real technical problems in our detection tools, but your admins have to be constantly alert for any evidence of unusual activity.  It&#8217;s <em>hard.  (</em>That&#8217;s why the US military uses <a href="http://en.wikipedia.org/wiki/FPCON">FPCONs</a> &#8211; and recently added <a href="http://en.wikipedia.org/wiki/INFOCON">INFOCONs</a>)</p>
<p>Ask this of a pen testing consultant and he will pander to you. (<em>&#8220;yep, we&#8217;ll do that!&#8221;) </em>Then most will turn and run nessus or some other automated vulnerability scanner.   They&#8217;re cheating you and your admins of a real threat emulation.  You&#8217;re left with no idea how your organization will detect or respond in a realistic scenario.   And it pisses your admins off, because when the pen testers can&#8217;t find some low-hanging-fruit-stupid-mistake on your perimeter, they &#8220;assume access&#8221; and proceed to pillage your internal network.  The whole affair becomes counterproductive.</p>
<p>We can&#8217;t just retrofit typical pen tests, as the ninnys are sure to suggest.   It&#8217;s evident in the terminology itself.  The connotations are entirely misplaced:  a pass/fail attempt (test) to gain unauthorized access (penetration).  The term is adversarial, and not in a good way.   Calling it something more like an <em>intrusion detection exercise</em> will more closely align connotations with the need.   An exercise is still adversarial, but in a better way.</p>
<p>Continuing to test our protections and hope for 100% is futile.  By doing so we sacrifice resources we should be devoting to detection and response.   Don&#8217;t try so hard to stop attackers, but expect and plan for  a certain amount to succeed.  Use the resources you save to make sure you know they&#8217;re there.</p>
]]></content:encoded>
			<wfw:commentRss>http://tactical-it.com/2009/01/intrusion-exercise/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
