Thanks to several people graciously donating shell accounts on
their Mac OS X boxes, Nmap usually compiles on that platform without
problems. Because not everyone has the development tools necessary to
compile from source, there is an executable installer as well. Nmap
is also available through systems such as MacPorts and Fink which
package Unix software for Mac OS X.
The easiest way to install Nmap and Zenmap on Mac OS X is to use
our installer. The
Mac OS X section of
the Nmap download page provides a file named
nmap-<version>.dmg, where
<version> is the version number of the most
recent release. The
.dmg
file is known as a
“disk image”. Installation instructions follow:
Download the file
nmap-<version>.dmg.
Double-click the icon to open it. (Depending on how you downloaded the
file, it may be opened automatically.)
The contents of the disk image will be displayed. One of
the files will be a Mac meta-package file named
nmap-<version>.mpkg.
Double-click it to start the installer.
Follow the instructions in the
installer. You will be asked for your password since Nmap installs in a system directory.
Once the installer is finished, eject the disk image by
control-clicking on its icon and selecting
“Eject”. The disk image may now be placed in
the trash.
See the instructions in the section called “Executing Nmap on Mac OS X” for
help on running Nmap and Zenmap after they are installed.
The programs installed by the installer are universal binaries
that will run on Mac OS X 10.4 (Tiger) or later. Users of earlier versions will
have to compile from source or use a third-party package.
Compiling Nmap from source on Mac OS X is no more difficult than
on other platforms once a proper build environment is in place.
Compile Nmap from source code
Compiling Nmap on Mac OS X requires
Xcode,
Apple's developer tools that include GCC and the rest of the usual build
system. Xcode is not installed by default, but is available as an
optional install on the Mac OS X installation discs. If you do not have
the installation discs or if you want a newer version, you can download
Xcode free of charge by following these steps.
Apple restricts downloads of Xcode to members of the
Apple Developer Connection.
Browse to
http://connect.apple.com and fill out some forms to
create an account. Skip to the next step if you already have an
account.
Return to http://connect.apple.com and
log in with your account credentials.
Hit the Download link and then choose
Developer Tools.
Download and install the most recent
Xcode.
These exact steps may change, but it is hoped that this general
approach will continue to work.
Once you have installed Xcode, follow the compilation instructions found in the section called “Unix Compilation and Installation from Source Code”. Note that on some older versions of Mac OS X, you may have to replace the command ./configure with ./configure CPP=/usr/bin/cpp.
Compile Zenmap from source code
Zenmap depends on some external libraries that do not come with
Mac OS X, including GTK+ and PyGTK. These libraries have many dependencies
of their own. A convenient way to install all of them is to use a
third-party packaging system as described in
Section . Once the dependencies are
installed, follow the instructions in the section called “Unix Compilation and Installation from Source Code” to
install Zenmap as usual.
Another option for installing Nmap is to use a system
which packages Unix software for Mac OS X. The two discussed here are
Fink and
MacPorts. See the
respective projects' web sites for how to install the package
managers.
To install using Fink, run the command fink install
nmap. Nmap will be installed as
/sw/bin/nmap. To uninstall use the command
fink remove nmap.
To install using MacPorts, run sudo port
install nmap. Nmap will be installed as
/opt/local/bin/nmap. To uninstall, run
sudo port uninstall nmap.
These systems install the nmap
executable outside the global PATH. To enable Zenmap to
find it, set the nmap_command_path variable in
zenmap.conf to /sw/bin/nmap or
/opt/local/bin/nmap as described in
the section called “The nmap Executable”.
Executing Nmap on Mac OS X
The terminal emulator in Mac OS X is called
Terminal, and is located in the directory
/Applications/Utilities. Open it and a
terminal window appears. This is where you will type your commands.
By default the root user is disabled on Mac OS X. To run a scan with
root privileges prefix the command name with
sudo,
as
in sudo nmap -sS <target>.
You will be asked for a password, which is just your normal login
password. Only users with administrator privileges can do this.
Zenmap requires the X11 application to
be installed. If it was not installed by default it may be available as
an optional install on the Mac OS X installation discs.
When Zenmap is started, a dialog is displayed requesting that you
type your password. Users with
administrator privileges
may enter their
password to allow Zenmap to run as the root user and run more advanced
scans. To run Zenmap in unprivileged mode, select the
“Cancel” button on this authentication dialog.