Compiling nmap 5.00 on MacOSX and keeping it as a Disk Image

I have been quite busy the last few weeks, so it is time for some new stuff :)
This time I will show how to build nmap and how to keep it seperate from your system.

At first, create a RamDisk
The RamDisk is called nmap-5.00, the reason for this will be obvious later.

$ DISK_ID=$(hdid -nomount ram://26214400)
$ newfs_hfs -v nmap-5.00 ${DISK_ID}
$ diskutil mount ${DISK_ID}

As we have a fast RamDisk, we can use it to compile faster.

$ mkdir /Volumes/nmap-5.00/compile
$ cd /Volumes/nmap-5.00/compile/

Obtain and unpack nmap

$ curl -O http://nmap.ucsd.edu/dist/nmap-5.00.tar.bz2
$ tar xjpf nmap-5.00.tar.bz2

The GUI needs python and some libraries, I chose not to compile with a GUI

$ cd nmap-5.00
$ ./configure --prefix=/Volumes/nmap-5.00/ --without-zenmap
$ make -j 4
$ make install

Do not forget to remove the build directory

$ cd /Volumes/nmap-5.00
$ rm -rf compile

Build a Disk Image

$ cd /Volumes
$ hdiutil create -volname nmap-5.00 -srcfolder /Volumes/nmap-5.00 /tmp/nmap-5.00.tmp
$ hdiutil convert /tmp/nmap-5.00.tmp.dmg -format UDBZ -o $HOME/Desktop/nmap-5.00.dmg

Unmount the RamDisk

$ hdiutil detach /Volumes/nmap-5.00

Now you have a nmap disk ready available to use

You can set your PATH and MANPATH prior to using the mounted disk image:

$ export PATH=/Volumes/nmap-5.00/bin:$PATH
$ export MANPATH=/Volumes/nmap-5.00/share/man

Having nmap in its own disk image may seem a little overkill, but you could add Metasploit and Wireshark to add additional features of your portable :) network debugging disk image.

Advertisement