<?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: Tag performance</title>
    <link>http://blog.clearnetsec.com/articles/tag/performance</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>maximizing nmap scans for accuracy</title>
      <description>&lt;p&gt;There have been some recent newsgroup postings about consistency problems with nmap results (especially when scanning over the internet).  In my experience, if you want the best chance of obtaining accurate nmap scan results, you need to:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;check the latency to your targets (ping some device on the target net block for awhile, what is the average rtt value?)
    &lt;ul&gt;
      &lt;li&gt;use the average to configure the --max_rtt_timeout nmap option (e.g. if your ping time is 300ms, you obviously want to set this option to more than 300ms to prevent nmap for missing an open port if/when a probe takes longer than 300ms. Maybe set it to 500ms or even higher. Speed suffers, but we're chasing accuracy) &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;if you can, check the available bandwidth limit for you and the target net (e.g. T3:45mbps, T1:1.544mbps, DSL, etc.)
    &lt;ul&gt;
      &lt;li&gt;use this to configure the --min-hostgroup and --max-hostgroup nmap options and the --min-parallelism and --max-parallelism options (i.e. the more bandwidth each side has available, the more hosts and ports you can scan in parallel). This can significantly reduce overall scan time while keeping accuracy as the highest priority. I typically use IPTraf to watch pps (packets per second) to guage my bandwidth usage. If my options are too aggressive (i.e. consuming too much bandwidth), I'll kill the current scan and start over with different tuning values. The objective here is to set --min-hostgroup and min-parallelism to something that both sides can handle without sacrificing accuracy. If bandwidth permits, I like to set min_parallelism to 100 (number of parallel SYN requests or whatever scan type you're doing). I've gone up to 300 for --min-hostgroup (had lots of bandwidth and plenty of server horsepower). You don't want to cause your scan server, the target, or any device the probes traverse to drop packets, so the more information you have about all the components involved the better you'll be able to tune these values. &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;if you can, verify there are no 'smart' devices impeding scans (e.g. IPS, rate limiting device, etc.) &lt;/li&gt;
  &lt;li&gt;run multiple nmap scans of the same target, preferably at different times of the day and different days of the week (e.g. nightly backups can saturate certain hosts/links which causes nmap to fail to discover open ports). I like to run multiple services scans (~1600 ports) and do one or two 65k scans depending on circumstances. If time permits, the confidence boost you get knowing you've maximized accuracy by running repeated scans is satisfying. It also shows your assiduity; you can tell your customer you fired off 5 scans at different times to obtain your final list of exposed services. If you missed something after repeated scans (assuming you used safe tuning values), something is likely wrong.&lt;/li&gt;
  &lt;li&gt;set --host_timeout to something you are comfortable with.
    &lt;ul&gt;
      &lt;li&gt;if you determine a scan may take 20 hours to perform a 65k port scan of the target device, then set this option accordingly. Note: you can use 's', 'm', or 'h' to specify seconds, minutes, or hours. &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;set --max-scan-delay to something low if nothing is impeding scans
    &lt;ul&gt;
      &lt;li&gt;I typically set this option to 0 because I'm confident in my other tuning values (no delay between probes, just fire them off)&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;While tuning nmap options can do lots of good things it is still important to verify your scan server can keep up. We've knocked down 8-way Opteron systems w/16GB of RAM, so optimal nmap options may not be realistic for your hardware. &lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;&amp;nbsp; &lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&amp;nbsp; &lt;/p&gt;

</description>
      <pubDate>Wed, 03 May 2006 01:05:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:0f284715-f876-43ac-933c-561b64142161</guid>
      <author>tate@ClearNetSec.com (Tate Hansen)</author>
      <link>http://blog.clearnetsec.com/articles/2006/05/03/maximizing-nmap-scans-for-accuracy</link>
      <category>nmap</category>
      <category>tuning</category>
      <category>performance</category>
      <category>ClearNet Security</category>
      <category>Tate Hansen</category>
      <category>accuracy</category>
    </item>
  </channel>
</rss>
