Image
 
linkedin_logo.png rss_logo.jpg
twitter_logo.png youtube_logo.jpg
Latest Additions
 
EH-Net Login
Welcome Guest.






Lost Password?
No account yet? Register
Who's Online
We have 39 guests online
 
Free Business and Tech Magazines and eBooks

You are here: Home arrow Ethical Hacking Discussions and Related Certificationsarrow Network Pen Testingarrow Planning a NMAP Scan
EH-Net
May 21, 2013, 05:11:09 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Go back to The Ethical Hacker Network Online Magazine Home Page
 
   Home   Help Calendar Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Planning a NMAP Scan  (Read 5969 times)
0 Members and 1 Guest are viewing this topic.
blueaxis
Newbie
*
Offline Offline

Posts: 44


View Profile
« on: October 26, 2011, 09:47:14 PM »

Hey All - Looks like I need some inputs in planning my nmap scan. Say I have 100 hosts to scan, what's the best way to go about it. I mean I would like to comprehensively scan for all 65000 odd ports both TCP and UDP. Appreciate any tips, tricks, suggestions...
Logged
Grendel
Full Member
***
Offline Offline

Posts: 242


View Profile WWW
« Reply #1 on: October 26, 2011, 11:27:40 PM »

Out of curiosity, why do you want to scan all the ports? I understand trying to be thorough, but there are only so many exploits out there, and when you boil it down, there aren't that many "interesting" ports. Chances are, you'll hit a vulnerability on the well known ports long before you find some hidden application running on some high-end port... plus you might get false positives anyway as different apps use different high numbered ports for dedicated communication.
Logged

- Thomas Wilhelm, MSCS MSM
ISSMP CISSP SCSECA SCNA IEM

Web Site:
Author:
  • Professional Penetration Testing
  • Ninja Hacking
  • Penetration Tester's Open Source Toolkit
  • Metasploit Toolkit for Penetration Testing
  • Netcat Power Tools
hell_razor
Jr. Member
**
Offline Offline

Posts: 90


View Profile
« Reply #2 on: October 27, 2011, 08:20:04 AM »

Hey may be trying to establish a baseline or inventory scan rather than building a list of vulnerabilities.  That being said, if it is the case, it may be better to run netstat, mbsa, etc. instead, using psexec if needed.

If you are seriously going to try to scan 65k UDP ports, that scan is gonna take a good while.
Logged

A+, Network+, Server+, CISSP, GSEC, GCIH, GPEN, GCIA, GISP, GCFW
cd1zz
Hero Member
*****
Offline Offline

Posts: 561


View Profile WWW
« Reply #3 on: October 27, 2011, 08:43:40 AM »

It's not uncommon for people to run network services on non-standard ports. People still practice security by obscurity so scanning the full range is fine.

Look at the timing and perf options for nmap and let that sucker run all night. If you're trying to evade an IDS, go on a vacation while you wait!
http://nmap.org/book/man-performance.html

Logged

blueaxis
Newbie
*
Offline Offline

Posts: 44


View Profile
« Reply #4 on: October 27, 2011, 10:01:05 AM »

Thanks members! Guess will have to do some reading on nmap performance.

Would you prefer to do the scans in little pieces and store the output in database? OR would you prefer greppable output format in text files like say per IP or something...
« Last Edit: October 27, 2011, 12:06:13 PM by blueaxis » Logged
MaXe
Hero Member
*****
Offline Offline

Posts: 669


I've just upgraded myself to a cyborg muahahaa!!1


View Profile WWW
« Reply #5 on: October 27, 2011, 03:35:44 PM »

Hey All - Looks like I need some inputs in planning my nmap scan. Say I have 100 hosts to scan, what's the best way to go about it. I mean I would like to comprehensively scan for all 65000 odd ports both TCP and UDP. Appreciate any tips, tricks, suggestions...

If you're going to do a scan like this, you HAVE to use Linux due to you can use true raw sockets on this. You can even set some custom firewall rules (if possible at the target host) to speed up the scanning process, and if you use the throttling flag, your scans will be even faster.

If you're doing a scan over the Internet, use a -T4 setting but if you're on an internal lan, you can actually set it to -T5 if you don't have to be stealthy at all.

Besides that, use the Syn Scan (-sS), NOT the OS Connect() (3-way handshake scan), and if you're scanning UDP ports, I suggest you do that in a separate scan as scanning UDP ports can often take a longer time, especially if packets are dropped. (Timeout is 1 second I think.)

Scanning a host that sends RST packets when you're doing a Syn Scan, instead of just dropping the packets will increase the scanning speed drastically. (This has to be configured on the remote hosts of course.)

Almost the same with UDP, except that it's not RST packets being sent back.

So, how can you speed up your scan too? By using a scanner that has separate sending and receiving modules. Randscan has this feature, which makes it a very fast port scanner, faster than nmap.

When you're doing large scans like this, I also suggest you keep usage of flags to a minimum, so avoid using -A, and perhaps -O as the last is just guessing / probability. You can use -sV, but this will take A LOT more time to complete, so I'd rather suggest you only use it on hosts that some interesting ports open that might be exploitable.


However before you continue with nmap, test out randscan. There's some info about how it works here including how to detect it: http://www.sans.org/security-resources/idfaq/scanrand.php
Logged

I'm an InterN0T'er
blueaxis
Newbie
*
Offline Offline

Posts: 44


View Profile
« Reply #6 on: October 27, 2011, 03:56:55 PM »

MeXe - Thank you very much for your inputs. So it appears the following strategy would be a good start.

1. Pick a host, scan for all TCP ports. Of course with timing options enabled.
2. Repeat step 1 for all the remaining hosts.
3. Pick a host, scan for all UDP ports.
4. Repeat step 3 for all the remaining hosts.
5. Selectively run -sV after analyzing results from step 1 through 4.

Does that sound correct?

Hmm...as I am writing this a question pops.

How do I manage the output? database? text file? greppable format?

Thanks in advance!

Logged
MaXe
Hero Member
*****
Offline Offline

Posts: 669


I've just upgraded myself to a cyborg muahahaa!!1


View Profile WWW
« Reply #7 on: October 27, 2011, 04:12:18 PM »

Update: I was going through some notes for a certification I once took, and just remembered that a NMAP UDP scan, is limited to sending 1 packet per second on Linux, which is also why you should separate your TCP and UDP on large networks.

If you configure the firewall on the target device to send ICMP Port Unreachable the UDP scan will of course be faster.

If you can use fewer ports to scan, it's a good idea too, and if possible, use several scanning machines. If you're on a wireless network, move closer to the router as this will also increase the scanning speed. (On a wired network, be close to the high-bandwidth backbone.)


That's pretty much some of the best advice I can give at the moment  Smiley

MeXe - Thank you very much for your inputs. So it appears the following strategy would be a good start.

1. Pick a host, scan for all TCP ports. Of course with timing options enabled.
2. Repeat step 1 for all the remaining hosts.
3. Pick a host, scan for all UDP ports.
4. Repeat step 3 for all the remaining hosts.
5. Selectively run -sV after analyzing results from step 1 through 4.

Does that sound correct?

Hmm...as I am writing this a question pops.

How do I manage the output? database? text file? greppable format?

Thanks in advance!



No problem, however, you do NOT use step 1 and 3, because different computers, has different ports open. So either you scan for the most commonly used ports or services you want to find, such as telnet, snmp, etc., or you scan all ports on all hosts.

Scanning one host and then applying this to all other hosts, will not give you a realistic picture, as a Windows machine may have port 135, and 445 open, while Linux will not unless Samba is installed. On a lot of linux equipment on the other hand, you may find port 22 and 80 open, while on Windows equipment, often but not always 3389 (RDP). Therefore you cannot just scan one host and repeat the same process for all hosts  Wink

You can run -sV selectively, for example on targets that appears to be servers as they're often more critical to the business than clients containing no valuable data, e.g. they may not pose a huge risk compared to a full database full of classified information stored on a server. During each pentest, you should always try to identify where the highest risk is for the company, and attack that. If you were the company, would you loose money if one regular and low privileged client is compromised, compared to a highly-privileged client or a server?  Smiley Therefore you must prioritize if you're doing this all by yourself and you don't have infinite time.

If you're just doing an assessment and you're not going to exploit  any services (aka pentest the network), then you should scan all hosts to identify the blacksheeps. The scanning will of course take a lot longer time, but since your goal is not to get 100 shells most likely, then you'll be fine. However, wherever you're planning this scan, find out whether you're going to break into the services, or just map the network and its services for e.g. a vulnerability assessment.

You can output it into various formats, including grepable format, xml format, normal output and even a few more. There are a few tools that will create reports for you as well, that you may feel trying out.

If you're going to scan the open services later on, find out which formats e.g. Nessus or Nexpose supports, so you can export the results from NMAP into that, and import it directly into those vulnerability scanners.

You can also go through it manually, which I've done on networks between ~30-60 hosts. The more hosts, the longer time, even though you'll quickly be able to spot anomalies that shouldn't be there, but if you're good with regex and grep, use that  Grin
« Last Edit: October 27, 2011, 04:17:55 PM by MaXe » Logged

I'm an InterN0T'er
T_Bone
Full Member
***
Offline Offline

Posts: 199


View Profile
« Reply #8 on: October 27, 2011, 04:17:04 PM »

Dependant upon whether you need to know the DNS name for each host, I would also use the -n flag which performs the scan without resolving the IP address to hostname. This can often speed up a scanning Smiley
Logged
MaXe
Hero Member
*****
Offline Offline

Posts: 669


I've just upgraded myself to a cyborg muahahaa!!1


View Profile WWW
« Reply #9 on: October 27, 2011, 04:19:34 PM »

Dependant upon whether you need to know the DNS name for each host, I would also use the -n flag which performs the scan without resolving the IP address to hostname. This can often speed up a scanning Smiley

Valuable addition  Grin I didn't think about that immediately, but you're right, a non- or slow responsive nameserver will definitely slow most scans down if you're doing reverse IP lookups. (Which you can afterward anyway.) Thanks for reminding me  Grin
Logged

I'm an InterN0T'er
ev0wpnz
Newbie
*
Offline Offline

Posts: 5


View Profile
« Reply #10 on: November 08, 2011, 08:55:41 PM »

Just a couple more tidbits of information here.

Scanning all 65k ports on 100 hosts is likely to cause some network congestion. Make sure this is not something you do during peak hours.

Although the timing options for nmap are very configurable at the end of the day it's not a fast scanner. (Not saying it's a slow scanner) Make sure you are specific about what you want.

Something like this would work

#nmap -sS -T4 -n 192.168.10-20.0-254 -oA NetworkAudit.

-sS = Syn-Scan
-T4 = Template of timing options (I don't like -T5 as you have a good chance of missing something)
-n = no name resolution. (Important)
-oA = Save in all formats.

I would look into FastNMAP is this is supposed to be good for large scans. (Never personally used it)

http://sourceforge.net/projects/npwn/

Also scanrand might be a good options.

I think there is a lot of good advice here and you should defiantly be able to run this scan effectively. 

Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
Joomla Bridge by JoomlaHacks.com
Valid XHTML 1.0! Valid CSS!
Page created in 0.079 seconds with 23 queries.
 
Exclusive Deal

sansfire13_245x90_cw90.jpg
SANSFIRE 2013
June 15 - 22

5% Off w/ Code: EHN_5

SANS Deals 4 EH-Netters
5% OFF Any SANS Course in Any Format!
Coupon Code: EHN_5 Including SANS Rocky Mountain 2013 & SANS Boston 2013
Polls
Compared to this year, 2013 will be:
 
Recent Forum Topics
EH-Net News Feeds
Latest Additions
 
         
Advertisement

© 2013 The Ethical Hacker Network
Joomla! is Free Software released under the GNU/GPL License.