<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>ClearNet Security: D&#233;j&#224; vu with big time port scanning</title>
    <link>http://blog.clearnetsec.com/articles/2006/08/22/d%C3%A9j%C3%A0-vu-with-big-time-port-scanning</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>D&#233;j&#224; vu with big time port scanning</title>
      <description>&lt;p&gt;We have a potential pen. test &amp;nbsp;project coming up with crazy numbers: &amp;nbsp;260,000+ range of publicly addressable IPs (spread  over several non-contiguous blocks).&amp;nbsp; &lt;a href="http://blog.clearnetsec.com/articles/2005/12/27/70-000-worth-of-new-opteron-servers-for-nmap-scanning-and-they-suck"&gt;Our  previous experience&lt;/a&gt; with scanning large blocks aggressively via the internet has  made us, well, super sensitive.&amp;nbsp; It&amp;rsquo;s freakin&amp;rsquo;  hard.&amp;nbsp; &lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;260,000 x 65535 TCP ports x 2 (number of port query attempts)  = 34,078,200,000 TCP SYN packets (nmap, default).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;That is ~4x larger compared to our last &amp;quot;large&amp;quot; effort  (~70,000 IPs).&lt;/p&gt;
&lt;p&gt;No info yet on the bandwidth available per block, latency  conditions, or other factors, but let&amp;rsquo;s run some numbers to see how this would  work.&lt;/p&gt;
&lt;p&gt;From recall, the Sun v40z&amp;rsquo;s were averaging ~3500pps (packets per  second) outbound per server.&amp;nbsp; I didn&amp;rsquo;t use packets  per second to estimate previous effort, I created a quick excel chart similar to below to get a ballpark number (updated using 260,000 for the total number of IP addresses to scan):&lt;/p&gt;
&lt;table border="1" cellpadding="0" cellspacing="0"&gt;
  &lt;col width="364" /&gt;
  &lt;col width="136" /&gt;
  &lt;col width="330" /&gt;
  &lt;tr height="17"&gt;
    &lt;td width="364" height="17"&gt;approx.    number of IP addresses to scan&lt;/td&gt;
    &lt;td width="136"&gt;&lt;div align="right"&gt;260,000 &lt;/div&gt;&lt;/td&gt;
    &lt;td width="367"&gt;&amp;nbsp;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr height="17"&gt;
    &lt;td height="17"&gt;number of TCP    ports to query &lt;em&gt;&lt;strong&gt;per&lt;/strong&gt;&lt;/em&gt; IP address&lt;/td&gt;
    &lt;td&gt; &lt;div align="right"&gt;65,535 &lt;/div&gt;&lt;/td&gt;
    &lt;td&gt;&amp;nbsp;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr height="17"&gt;
    &lt;td height="17"&gt;&lt;div align="right"&gt;total # of    TCP ports to query &lt;/div&gt;&lt;/td&gt;
    &lt;td&gt;&lt;div align="right"&gt;17,039,100,000 &lt;/div&gt;&lt;/td&gt;
    &lt;td&gt;&amp;nbsp;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr height="17"&gt;
    &lt;td height="17" bgcolor="#CCCCCC"&gt;&amp;nbsp;&lt;/td&gt;
    &lt;td bgcolor="#CCCCCC"&gt;&amp;nbsp;&lt;/td&gt;
    &lt;td bgcolor="#CCCCCC"&gt;&amp;nbsp;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr height="17"&gt;
    &lt;td height="17"&gt;time-out setting per    port query&amp;nbsp;&lt;/td&gt;
    &lt;td&gt;&lt;div align="right"&gt;1.25 &lt;/div&gt;&lt;/td&gt;
    &lt;td&gt; seconds (allow 1.25 seconds for query response)&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr height="17"&gt;
    &lt;td height="17"&gt;number of query attempts per    port&amp;nbsp;&lt;/td&gt;
    &lt;td&gt;&lt;div align="right"&gt;2 &lt;/div&gt;&lt;/td&gt;
    &lt;td&gt;which implies we need    34,078,200,000 SYN requests  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr height="17"&gt;
    &lt;td height="17"&gt;&lt;div align="right"&gt;total seconds    per port query&lt;/div&gt;&lt;/td&gt;
    &lt;td&gt;&lt;div align="right"&gt;2.50 &lt;/div&gt;&lt;/td&gt;
    &lt;td&gt;seconds&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr height="17"&gt;
    &lt;td height="17" bgcolor="#CCCCCC"&gt;&amp;nbsp;&lt;/td&gt;
    &lt;td bgcolor="#CCCCCC"&gt;&amp;nbsp;&lt;/td&gt;
    &lt;td bgcolor="#CCCCCC"&gt;&amp;nbsp;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr height="17"&gt;
    &lt;td height="17"&gt;number of    parallel &lt;em&gt;&lt;strong&gt;port &lt;/strong&gt;&lt;/em&gt;queries&lt;/td&gt;
    &lt;td&gt;&lt;div align="right"&gt;2 &lt;/div&gt;&lt;/td&gt;
    &lt;td&gt;(we set it to 100, but empirical evidence shows this to be ~2)&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr height="17"&gt;
    &lt;td height="17"&gt;total # of    hours to complete single IP port scan&lt;/td&gt;
    &lt;td&gt;&lt;div align="right"&gt;22.76 &lt;/div&gt;&lt;/td&gt;
    &lt;td&gt;&amp;nbsp;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr height="17"&gt;
    &lt;td height="17"&gt;&amp;nbsp;&lt;/td&gt;
    &lt;td&gt;&amp;nbsp;&lt;/td&gt;
    &lt;td&gt;&amp;nbsp;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr height="17"&gt;
    &lt;td height="17"&gt;total number of seconds    to perform scan (if sequential)&lt;/td&gt;
    &lt;td&gt;&lt;div align="right"&gt;21,298,875,000 &lt;/div&gt;&lt;/td&gt;
    &lt;td&gt;&amp;nbsp;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr height="17"&gt;
    &lt;td height="17"&gt;total number    of hours to perform scan (if sequential)&lt;/td&gt;
    &lt;td&gt;&lt;div align="right"&gt;5,916,354 &lt;/div&gt;&lt;/td&gt;
    &lt;td&gt;&amp;nbsp;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr height="17"&gt;
    &lt;td height="17" bgcolor="#CCCCCC"&gt;&amp;nbsp;&lt;/td&gt;
    &lt;td bgcolor="#CCCCCC"&gt;&amp;nbsp;&lt;/td&gt;
    &lt;td bgcolor="#CCCCCC"&gt;&amp;nbsp;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr height="17"&gt;
    &lt;td height="17"&gt;number of    scans in parallel&lt;/td&gt;
    &lt;td&gt;&lt;div align="right"&gt;1,600&lt;/div&gt;&lt;/td&gt;
    &lt;td&gt;(2 servers, each running 8 unique nmap processes with min_hostgroup set to 100) &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr height="17"&gt;
    &lt;td height="17"&gt;number of    hours to complete scan&lt;/td&gt;
    &lt;td&gt;&lt;div align="right"&gt;3,698&lt;/div&gt;&lt;/td&gt;
    &lt;td&gt;&amp;nbsp;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr height="17"&gt;
    &lt;td height="17"&gt;number of    days to complete scan&lt;/td&gt;
    &lt;td&gt; &lt;div align="right"&gt;&lt;strong&gt;154 &lt;/strong&gt;&lt;/div&gt;&lt;/td&gt;
    &lt;td&gt;&amp;nbsp;&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;
&lt;p /&gt;
&lt;p&gt;Now I realize pps is an important factor.&amp;nbsp; Remember these are still pretty fast servers:  quad dual core opterons with 16 GB RAM. Doing a sanity check with our previous results of obtaining ~3500 pps per server goes as follows: &amp;nbsp;&lt;/p&gt;
&lt;table cellspacing="0" cellpadding="0" border="1"&gt;
  &lt;col width="364" /&gt;
  &lt;col width="136" /&gt;
  &lt;tr height="17"&gt;
    &lt;td height="17" width="364"&gt;total #    of SYN requests&lt;/td&gt;
    &lt;td width="136"&gt;&lt;div align="right"&gt;34,078,200,000 &lt;/div&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr height="17"&gt;
    &lt;td height="17"&gt;average outbound packets per second / per server&lt;/td&gt;
    &lt;td&gt;&lt;div align="right"&gt;3500&lt;/div&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr height="17"&gt;
    &lt;td height="17"&gt;number of dedicated servers&lt;/td&gt;
    &lt;td&gt;&lt;div align="right"&gt;2 &lt;/div&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr height="17"&gt;
    &lt;td height="17"&gt;total number of seconds to complete scan&lt;/td&gt;
    &lt;td&gt;&lt;table cellspacing="0" cellpadding="0"&gt;
      &lt;tr&gt;
        &lt;td height="17" width="136"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4,868,314.29&lt;/td&gt;
      &lt;/tr&gt;
    &lt;/table&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr height="17"&gt;
    &lt;td height="17"&gt; number of hours to complete scan&lt;/td&gt;
    &lt;td&gt;&lt;div align="right"&gt;
      &lt;table cellspacing="0" cellpadding="0"&gt;
        &lt;tr&gt;
          &lt;td height="17" width="136"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;    1,352.31 &lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/div&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr height="17"&gt;
    &lt;td height="17"&gt; number of days to complete scan&lt;/td&gt;
    &lt;td&gt;&lt;div align="right"&gt;&lt;strong&gt;56&lt;/strong&gt;&lt;/div&gt;&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;
&lt;p /&gt;
&lt;p&gt;So the numbers don't match. The first chart says it'll take ~154 days, the second says ~56 days. In the first chart I set &amp;quot;number of scans in parallel&amp;quot; to 1600. I got that by having 8 unique nmap processes each running with min_hostgroup of 100 (800 hosts being scanned simultaneously per server; we have two dedicated scanners, so the total is 1600 hosts). The number that is probably way off is the &amp;quot;number of parallel port queries&amp;quot; in the first chart. Although we had set the value to 100 (meaning scan 100 ports simultaneously on each host) it often seemed like we were only getting 2 or so in parallel (observed from watching tcpdump output). That was probably after running into the memory issues I reported with nmap (which &lt;a href="http://www.securityfocus.com/archive/101/418822/30/0/threaded"&gt;Fyodor subsequently reported to fix&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;I just ran a few quick checks on a Sun Fire x2100 we have (dual core opteron 175 / 4 GB of RAM) using a newer nmap version (4.11). Firing off a bunch of nmap scans on one server with parameters similar to below resulted in a sustained 9000+ pps (~4.5 Mbits/s).  &lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt; /usr/local/bin/nmap  -vv -sS -P0 -p 1-65535 -n --min_hostgroup 100    --max_rtt_timeout 1250 --min_parallelism 100  &amp;lt;a_/24_block&amp;gt; &lt;/p&gt;
&lt;p&gt;&lt;img src="http://blog.clearnetsec.com/files/2100zIPTraf.JPG" width="554" height="271" /&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I didn't let the test run for very long to see if issues arise like before. If  we could sustain 9000 pps per server and be allowed to push ~9Mbits/s, then the overall time is greatly reduced. It drops to ~22 days. I really doubt we'll be able to or allowed to push 9Mbits/s, but at least we now have ballpark figures to play with. 

&lt;p&gt;Who else has had this kind of crazy port scanning fun?&lt;/p&gt;

&lt;/p&gt;
&lt;p&gt;Related entry: &lt;a href="http://blog.clearnetsec.com/articles/2006/05/03/maximizing-nmap-scans-for-accuracy"&gt;maximizing nmap scans for accuracy&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;&amp;nbsp; &lt;/p&gt;

</description>
      <pubDate>Tue, 22 Aug 2006 23:13:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:cb71aba2-3e34-417e-8f9f-0b494fc6b3f4</guid>
      <author>tate@ClearNetSec.com (Tate Hansen)</author>
      <link>http://blog.clearnetsec.com/articles/2006/08/22/d%C3%A9j%C3%A0-vu-with-big-time-port-scanning</link>
      <category>nmap</category>
      <category>port  scanning</category>
      <category>performance</category>
      <category>ClearNet Security</category>
      <category>Tate Hansen</category>
    </item>
    <item>
      <title>"D&#233;j&#224; vu with big time port scanning" by S&#248;ren Maigaard</title>
      <description>&lt;p&gt;Even on internal networks, a port scan of 25,000 hosts on a Class A network takes a very long time. 
&lt;br&gt;&lt;br&gt;
We use nMap to do this (and sometimes FoundScan), but we also hit the limits of the L3 devices around the company. Also VPN devices connecting remote offices, firewalls etc. have limitations. &lt;br&gt;
What I really want is a &amp;#8220;tune tool&amp;#8221;. Send probe packets around the network, identify L3 devices (and know their default limitations) and configure the scan accordingly. &lt;br&gt;
How do other big companies do this? 
&lt;br&gt;&lt;br&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;s0ren&lt;/li&gt;
&lt;/ul&gt;</description>
      <pubDate>Thu, 21 Sep 2006 05:14:08 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:211875ba-993e-4a8a-be66-574645e586ba</guid>
      <link>http://blog.clearnetsec.com/articles/2006/08/22/d%C3%A9j%C3%A0-vu-with-big-time-port-scanning#comment-25</link>
    </item>
    <item>
      <title>"D&#233;j&#224; vu with big time port scanning" by Tate Hansen</title>
      <description>&lt;p&gt;I&#8217;ve played with scanrand and the unicorn scanner a couple times awhile back, but I didn&#8217;t use them enough to gain confidence they&#8217;ll work well.  I&#8217;m afraid of missing open services.  But you&#8217;re right, I think these tools are better (or better designed) for the job.  Time to play more.
&lt;p /&gt;&lt;br /&gt;
I&#8217;ve looked several times for a site that has a big chart of all the forwarding rates for the most common networking devices, but I&#8217;ve never found anything comprehensive.  It would also be nice to know how fast unacknowledged TCP SYN packets linger in connection tables (by default at least, I think most can be tuned).  &lt;/p&gt;</description>
      <pubDate>Wed, 23 Aug 2006 15:33:57 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:0cd46ba6-7c52-45e8-9a47-74c1fd0bbbef</guid>
      <link>http://blog.clearnetsec.com/articles/2006/08/22/d%C3%A9j%C3%A0-vu-with-big-time-port-scanning#comment-20</link>
    </item>
    <item>
      <title>"D&#233;j&#224; vu with big time port scanning" by Chris Byrd</title>
      <description>&lt;p&gt;For large scale TCP scanning, you might want to look at scanrand2, which is part of Dan Kaminsky&amp;#8217;s Paketto Keiretsu toolkit
&lt;a href="http://www.doxpara.com/read.php/code/paketto.html" rel="nofollow"&gt;http://www.doxpara.com/read.php/code/paketto.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It uses forged Stateless TCP SYN requests and a technique Dan calles &amp;#8216;inverse syn cookies&amp;#8217; to bypass kernel connection table limitations.  Keep a mind on watching limitations of any L3 devices between the scanner and target network.  I&amp;#8217;ve seen L3 connection tables filled up, DoSing these devices even with limited nmap scans.&lt;/p&gt;</description>
      <pubDate>Wed, 23 Aug 2006 08:04:15 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:21d4af1e-b822-420c-b688-0d6905b9d1a0</guid>
      <link>http://blog.clearnetsec.com/articles/2006/08/22/d%C3%A9j%C3%A0-vu-with-big-time-port-scanning#comment-18</link>
    </item>
  </channel>
</rss>
