Hardware Reference
In-Depth Information
Now that you have built nmap's dependencies, it's time to retrieve nmap and build it. Open your web browser
and go to the nmap download page at
http://nmap.org/dist/
. For this example, please use the 6.01 version of nmap
(
nmap-6.01.tar.bz2)
, because the current version at the time of writing has issues building without
liblua
. Save the
nmap-6.01.tar.bz2
file into the build directory. Next extract the files into this directory.
Now change into the nmap source directory and create an
rpi-build
directory again. The configure stage for
nmap is a little more complicated. For a start, I don't want to build certain parts of nmap. For example, I do not want
the zenmap front end nor do I want to compile in netcat, for example. You now also need to tell nmap's configure
tool where to find
libpcap
's ARM install; this is why having a decent build directory layout will save you a lot of pain.
Here is the full command to run the configuration for nmap:
# CC=arm-unknown-linux-gnueabi-gcc ./configure --host=arm-unknown-linux-gnueabi --without-ndiff
--without-zenmap --without-liblua --without-ncat --with-pcap=linux --with-libpcap=/working/book-
work/ch7/build/libpcap-1.3.0/rpi-build -prefix=/'pwd'/rpi-build
There are a lot of new options, though a lot of them are just disabling parts I do not want. They are
--without-ndiff
,
--without-zenmap
,
--without-liblua
, and
--without-ncat
; these lines just disable parts
of nmap. The only other new option is the
--with-libpcap
option, which tells nmap where to find
libpcap
.
Don't try to be clever by using a relative path; it will cause you untold pain. Always use the full path, as make
won't care what your relative path is.
reLatIVe path VerSUS FULL path
a relative path is a path on your system that won't take its parent path into consideration. For example, if you
wanted to make an empty file in the directory
/home/brendan
, you could
cd
into the
/home/brendan
directory
and then create the empty file like this:
touch empty-file
the file named
empty-file
is relative to your current location in the filesystem. this is called using the relative
path. if you wanted to create the empty file using a full path you would need to use the following command:
touch /home/brendan/empty-file
This is the full system path to the
empty
file.
Configuring nmap takes a little longer than
libpcap
but you get a cool fire-breathing dragon at the end so it must
be worth it. Once you're done with the configure stage and the dragon, it's time to move on to the
make
stages. This
time I am going to add an extra parameter for
make
. This parameter is called
static
; by using this option you will
create a binary that will not depend on shared libraries.
What are shared libraries, I hear you ask? A shared library is a shared group of functions that any program on
your system can use. This saves having many copies of the same library on your system. For example, the
tcpdump
application and Wireshark both use the shared
pcap
library files. When you statically link all the libraries at build time,
your application won't depend on any shared libraries on the system. This can be good and bad.
•
It's bad because the size of your application on disk and in memory will increase.
•
It's good when you need an application working at a very early stage in your boot process.
Early in the boot process, the system's shared libraries may not be available yet. Another good
use for static libraries is if you have an application that depends on some old version of a
library. You can statically link the application to the old library and your system will still use
the newer shared libraries.