Installing Nmap - Nmap 6 Cookbook: The Fat Free Guide to Network Security Scanning (2015)

Nmap 6 Cookbook: The Fat Free Guide to Network Security Scanning (2015)

Section 1: Installing Nmap

Overview

Installing Nmap is a simple process similar to installing just about any other software package. Nmap has its roots in the Linux world, but Windows and Mac OS X versions are also available for easy installation. Additionally, Nmap can run on many Unix platforms like Solaris or BSD.

While great care is taken to make Nmap a universal experience on every platform, the reality is that you may experience "issues" when using Nmap on Windows, Unix, or Mac OS X. This is primarily because these platforms have various idiosyncrasies that are not present on a typical Linux system.

Linux is the ideal platform for running Nmap because of its robust networking stack. Recent releases of Nmap, however, have greatly improved compatibility on alternative operating systems like Windows and Mac OS X. Running Nmap version 5 or newer on these systems is much more reliable compared to older releases. Nmap 6 continues this trend of making Windows and Mac OS X "first class citizens" by continuing to resolve platform specific problems.

Topics covered in this Section:

- Installing Nmap on Windows
- Installing Nmap on Linux
- Installing Nmap from source (Unix and Linux)
- Installing Nmap on Mac OS X

Installing Nmap on Windows

Step 1

Download the Windows version of Nmap from nmap.org.

Step 2

Launch the Nmap setup program. Select the default installation (recommended), which will install the entire Nmap suite of utilities.

Nmap for Windows installer

Step 3

During installation, a helper program called WinPcap will also be installed. WinPcap is required for Nmap to function properly on the Windows platform so do not skip this step.

WinPcap for Windows installer

Step 4

After the WinPcap installation has completed, you are given the option to configure its service settings. The default options will enable the WinPcap service to start when Windows boots. This is recommended as Nmap will not function correctly when the WinPcap service is not running.

WinPcap options

Step 5

Once Nmap has been successfully installed you can verify it is working correctly by executing nmap scanme.nmap.org on the command line (located in Start > Programs > Accessories > Command Prompt).

C:\> nmap scanme.nmap.org

Starting Nmap 6.47 ( http://nmap.org ) at 2015-01-16 08:09 CST

Nmap scan report for scanme.nmap.org (74.207.244.221)

Host is up (0.058s latency).

Not shown: 997 closed ports

PORT STATE SERVICE

22/tcp open ssh

80/tcp open http

9929/tcp open nping-echo

Nmap done: 1 IP address (1 host up) scanned in 1.16 seconds

Nmap test scan on Microsoft Windows

If the results of your scan are similar to the results above, then you have successfully installed Nmap. If you receive an error, refer to Section 10 of this book for troubleshooting and debugging information.

Tip: Consider using the Power Shell for Windows to run Nmap. It allows for flexible windows resizing to better accommodate Nmap’s output. This can be found in Start > Programs > Accessories > Windows PowerShell > PowerShell on Windows 7 based systems.

Installing Nmap on Linux systems

Most popular Linux distributions provide binary Nmap packages, which allows for simple installation. Installation on Unix systems typically requires compiling Nmap from source code (as described next in this section).

Note: The sudo command is used to elevate privileges on Linux systems. This is the default behavior for most modern systems. If you are logged in as the root user you can omit the sudo command.

Installing Precompiled Packages for Linux

For Debian and Ubuntu based systems:

$ sudo apt-get install nmap

For Red Hat and Fedora based systems:

$ sudo yum install nmap

The version of Nmap found in the software repositories for your Linux distribution may not be the most recent version available. You can check to see which version of Nmap you have installed by executing nmap -V (capital V) as demonstrated below.

$ nmap -V

Nmap version 6.47 ( http://nmap.org )

Platform: x86_64-pc-linux-gnu

Compiled with: liblua-5.2.3 openssl-1.0.1f libpcre-8.31 libpcap-1.5.3 nmap-libdnet-1.12 ipv6

Compiled without:

Available nsock engines: epoll poll select

Nmap version output

Compare the version that is installed with the most recent version available on the nmap.org website. If the release is too far out of date, you may want to consider downloading the source code for Nmap and compiling a newer version for your system. Instructions for doing this are discussed next.

Compiling Nmap from Source for Unix and Linux

Another method for installing Nmap is to download and compile the source code from the nmap.org website. Building Nmap from source takes a little extra work, but is well worth the effort to get the new features and fixes in Nmap’s latest releases. The following five steps detail the procedure for installing Nmap from source.

Step 1

Download the Nmap 6 source from nmap.org/download.html. This can be done via a standard web browser or from the command line using the wget command found on most Unix/Linux based systems.

$ wget http://nmap.org/dist/nmap-6.47.tgz

--2015-01-13 19:00:02-- http://nmap.org/dist/nmap-6.47.tgz

Resolving nmap.org (nmap.org)... 173.255.243.189, 2600:3c01::f03c:91ff:fe70:d085

Connecting to nmap.org (nmap.org)|173.255.243.189|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 9796783 (9.3M) [application/x-tar]

Saving to: ‘nmap-6.47.tgz’

100%[===============>] 9,796,783 1.99MB/s in 4.5s

2015-01-13 19:00:07 (2.06 MB/s) - ‘nmap-6.47.tgz’ saved [9796783/9796783]

Downloading Nmap on Unix and Linux systems via the command line

Step 2

Extract the contents of the Nmap package by executing the tar command.

$ tar -xvf nmap-6.47.tgz
[...]

Extracting Nmap source code

Step 3

Configure and build the Nmap source code by changing to the source directory and then executing ./configure && make on the command line.

$ cd nmap-6.47/
$ ./configure && make
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
[...]

Compiling Nmap source code

Step 4

Install the compiled code by typing sudo make install on the command line.

Note: This step will require root privileges. You must login as the root user or use the sudo command to complete this step.

$ sudo make install
Password: ********
/usr/bin/install -c -d /usr/local/bin /usr/local/share/man/man1
/usr/local/share/nmap
/usr/bin/install -c -c -m 755 nmap /usr/local/bin/nmap
/usr/bin/strip -x /usr/local/bin/nmap
/usr/bin/install -c -c -m 644 docs/nmap.1 /usr/local/share/man/man1/
/usr/bin/install -c -c -m 644 docs/nmap.xsl /usr/local/share/nmap/
[...]

NMAP SUCCESSFULLY INSTALLED

Installing Nmap from source code

Step 5

Once Nmap has been successfully installed, you can verify it is working correctly by executing nmap scanme.nmap.org on the command line.

$ nmap scanme.nmap.org

Starting Nmap 6.47 ( http://nmap.org ) at 2015-01-16 08:20 CST

Nmap scan report for scanme.nmap.org (74.207.244.221)

Host is up (0.059s latency).

Not shown: 997 closed ports

PORT STATE SERVICE

22/tcp open ssh

80/tcp open http

9929/tcp open nping-echo

Nmap done: 1 IP address (1 host up) scanned in 2.62 seconds

Nmap test scan on Unix/Linux

If the results of your scan are similar to the results above, then you have successfully installed Nmap. If you receive an error, refer to Section 10 of this book for troubleshooting and debugging information.

Installing Nmap on Mac OS X

Step 1

Download the Mac OS X version of Nmap from nmap.org.

Note: Nmap 5 is the last release to support running on PowerPC based systems. Version 6 and newer runs exclusively on Mac systems with Intel processors.

Step 2

Launch the Nmap setup program and click continue. Then, accept the license terms of the Nmap program.

Nmap for Mac OS X installer

Step 3

When prompted for the installation options, leave the default selections checked (recommended) and click continue to begin the install process. This will install the entire Nmap suite of utilities.

Default installation settings

Step 4

Follow the prompts and enter your administrative password if required. When the installation is complete you can close the Nmap installer.

Successful installation of Nmap on Mac OS X

Step 5

Once Nmap has been successfully installed, you can verify it is working correctly by executing nmap scanme.nmap.org in the Mac OS X Terminal application (located in Applications > Utilities > Terminal).

$ nmap scanme.nmap.org

Starting Nmap 6.47 ( http://nmap.org ) at 2015-01-15 20:05 CST

Nmap scan report for scanme.nmap.org (74.207.244.221)

Host is up (0.082s latency).

Not shown: 997 closed ports

PORT STATE SERVICE

22/tcp open ssh

80/tcp open http

9929/tcp open nping-echo

Nmap done: 1 IP address (1 host up) scanned in 2.43 seconds

Nmap test scan on Mac OS X

If the results of your scan are similar to the results above, then you have successfully installed Nmap. If you receive an error, refer to Section 10 of this book for troubleshooting and debugging information.