February 18, 2009
This article was contributed by Nathan Willis
Gordon "Fyodor" Lyon is the principal author of the network scanner Nmap, and his new book Nmap Network Scanning is its
authoritative guide. Lyon has crafted a precise, readable resource that
will serve both newcomers and experienced Nmap users well. Equal parts
manual, network scanning textbook, history lesson, and field guide, the
book is a detailed reference to what Nmap can do, an explanation of how and
why it works, and instructions on how to best use it for maximum
result.
For those unfamiliar with the tool, Nmap is a network scanner. It can
detect and enumerate the active machines on a computer network -- local or
the Internet at large -- scan which TCP and UDP ports are open, and, in most
cases, determine what services are running on the open ports and what
operating system the host itself is running. It performs this service by
sending specially-tailored IP, ICMP, TCP, and other packets, then
interpreting the results. At its simplest, Nmap sends a SYN packet asking
to open a TCP connection addressed to a particular port. If something
responds, there is a service running on the port. But Nmap does far more
than that, utilizing nearly every flag ever defined in an RFC, and doing it
-- in parallel -- to potentially thousands of ports on thousands of hosts.
Nmap has more than one hundred command-line options; understanding them
and how best to use them is the subject of Lyon's book.
Like Nmap itself, Nmap Network Scanning begins by
addressing the most commonly used features, and explores more complex
options later. As prelude, chapter one gives an overview of Nmap's
features, introducing the concepts of port scanning, service and OS
discovery, and basic usage examples. Chapter two explains how to get and
install the code, including its status of various platforms, the Zenmap
graphical user interface, community-created scripts, and finding updates to
both the code and important data files.
The book then delves into Nmap usage itself, beginning with the
fundamental functions: host discovery in chapter three, and port scanning
in chapters four and five. The two topics do overlap, as TCP SYN
and ACK scans are used to discover hosts as well as to discover ports. But
Lyon has chosen to craft the initial chapters of the book so that they
mimic the logic of Nmap itself, and host discovery is the first execution
step in any Nmap command. This is no accident; Lyon explains Nmap's
architecture as only its creator could: with real-world examples, he
illustrates how separating host discovery from port scanning allows a
professional security or penetration tester to take hours off of a large
scan through careful planning. And he explains how some host discovery
techniques (such as DNS) expose the user to discovery in exchange for
speed, while others (such as ARP pings) give the opposite tradeoff.
Chapter four's discussion of port scanning explains the broad strokes of
scanning TCP and UDP ports, lists the most common types of scan, and
describes how Nmap distinguishes between open, closed, filtered, and
ambiguous ports. Chapter five covers Nmap's port scanning techniques in
detail. It describes the basic TCP and UDP scans, contrasts when different
techniques produce different results, and explains less commonly used scans
and when they are appropriate. Lyon provides thorough examples, including
real-world scans the reader can execute, and hypothetical "case study"
problems weighing the pros and cons of multiple approaches. Chapter six is
a discussion of optimizing Nmap scan performance, centered on how to select
the right scanning technique, the right scanning target, and the right
timing options. Nmap scans can take a very long time if the wrong
parameters are chosen, so mastering the variables is a valuable skill.
Chapter seven looks at the next step beyond port scanning: service and
version detection, by which Nmap can determine what applications are
running on open ports, and in many cases precisely which version. Chapter
eight looks at operating system detection, which Nmap performs by sending a
complex series of tests to the target machine, then comparing the resulting
"fingerprint" to a database of known profiles. Chapter nine describes one
of Nmap's newest features, the Nmap Scripting Engine (NME). NME is a Lua-based engine that allows constructing
more complex scans and queries that the Nmap core can perform on its own.
The chapter also provides a reference to the carefully-chosen suite of NME
scripts that ships with the current Nmap release.
Chapter ten explores how to use Nmap to perform two higher-level tasks:
mapping out and bypassing firewall rules, and evading or defeating
intrusion detection systems (IDSs). The text covers both general
strategies, and sketches of popular firewall and IDS products on the
market. Chapter eleven explores the other side of the coin, how to defend
against Nmap scans, including detecting scans, blocking or slowing down
scans, and misleading service and OS detection.
The remainder of the book is dominated by reference material. Chapter
twelve introduces Zenmap, the official Nmap GUI client, including how it
can benefit even experienced Nmap hackers. Chapter thirteen explains
Nmap's output formats, including human-readable plaintext, machine-friendly
XML, and "grepable" text. It also covers manipulating and transforming the
XML format for use with other tools. Chapter fourteen describes Nmap's
data files, including the version and OS detection databases, and support
files used by NME. Chapter fifteen is a comprehensive reference guide for
Nmap, detailing all of the over 100 command line options. For further
reference, appendix A contains the document type definition (DTD) for
Nmap's XML output, and the introductory material includes a helpful
reference of IP, TCP, UDP, and ICMP headers.
Documentation and more
Nmap Network Scanning is a thorough guide to Nmap itself,
and a lesson in network scanning at no additional charge. If you are new
to the subject, the educational material will help you fill in the gaps in
your knowledge, from TCP flags and connection setup, to how firewalls
determine which packets to stop and which to allow through to their
destination. The inline examples explain how Nmap performs its scans
(often with real, Internet-accessible URLs as the targets), but also how
the user can and should interpret the results. Longer SOLUTION passages
discuss more complex problems by presenting a case study of a broadly
stated challenge (such as "find all of the servers on a network running an
insecure or nonstandard application") and the steps in which Nmap can help
hone in on the answer. As the author shows, much of being a good network
scanner is knowing what tests to perform, and how to decipher what those
tests tell you.
The book is successful as a comprehensive manual, but Lyon makes it more
than just documentation by infusing it with his experience. First, he is
an experienced scanning and security expert, and in almost every section
shares specific, real-world expertise about the good and bad points of the
available scanning techniques under discussion. As he points out in the
introductory material, when it comes to free software, experience is the
only barrier to becoming an expert, and he shares his without reservation.
For example, in addition to the predefined scan types, Nmap's
--scanflags option allows you to define a custom set of TCP flags
for your probe. The author presents an example where crafting a packet
with both the SYN and FIN flags set will get by certain firewall
configurations because the TCP RFC is ambiguous about how hosts should
interpret certain combinations of flags.
Second, Lyon is the creator of Nmap, and while that does not
automatically mean he would write a better book on the subject, he
uses his background with the project to enhance the text. As noted
earlier, he explains design decisions that affect how Nmap performs its
scans and tests, and understanding why Nmap works the way it does
is far better for the reader than simply understanding what it can and
cannot do. For example, chapter nine describes why (unlike other services)
detecting Skype requires multiple tests, and Lyon explains why Nmap
implements Skype detection as an NME script rather than building a
single-purpose test into the service detection code.
He also draws on the history of the entire project to educate the
reader. He includes background and discussion about scans and tests (such
as the TCP FTP bounce scan) that are less and less useful every year as
operating systems and applications servers close old security
vulnerabilities. He notes changes in the code, such as the 2006 rewrite of
the OS detection module that enhances the program but obsoletes older OS
detection fingerprints. And he explains how new and interesting scans
(such as Gerhard Rieger's IP Protocol scan) were discovered and added to
Nmap's arsenal. Finally, Lyon brings the perspective of an ongoing project
lead to the book, encouraging and explaining the importance of
participation in Nmap's development process -- from consulting the mailing
list, to submitting OS detection fingerprints to the Nmap database, to
properly documenting homemade NME scripts.
Whether you are a novice port scanner looking to learn Nmap, or a
security professional looking for the definitive reference on the
ubiquitous free software scanner, Nmap Network Scanning has
something for you. Nmap Network Scanning is available online
from a variety of retailers; a current list as well as the best available
price can be found at http://nmap.org/book. There you can also
read several sample chapters in a free online edition.
(
Log in to post comments)