6.-IP Network Scanning
6.-IP Network Scanning
IP Network Scanning
Initial Network Scanning with Nmap
Network protocols and respective OSI layers
• Common network protocol:
• Internet Protocols IPv4/v6.
• Internet Control Message Protocol
(ICMP)
• Distance Vector Multicast Routing
Protocol (DVMRP)
• Internet Group Management
Protocol (IGMP)
• Address Resolution Protocol (ARP)
• Internet Protocol Security (IPsec)
• Routing Information Protocol (RIP)
ICMPv4 Sweeping with Nmap
• Within Nmap, use the -PEPM
flag to perform host discovery
using ICMPv4 echo, timestamp,
and subnet mask requests
Ping broadcast addresses
• Within an IP network, the last
address octet is reserved as the
broadcast address (e.g.,
10.10.5.255 within
10.10.5.0/24), which is used to
send traffic to all of the hosts
within a subnet.
Ping broadcast addresses
• This example shows how an
additional subnet (10.12.0.0/24)
is revealed via the
255.255.255.255 broadcast
address.
TCP scanning
• Nmap supports many TCP
scanning modes, which are
particularly useful when
performing stealth scans and
understanding low-level network
configuration.
• For the purpose of identifying
accessible services, the basic TCP
SYN (-sS) mode should be used.
TCP Scanning
• Nmap returns a state (open,
closed, or filtered) for each port.
• These Figures demonstrate SYN
probes eliciting four response
variants:
• a SYN/ACK packet (indicating an
open port);
• RST/ACK (denoting closed);
• no response; or
• an ICMP type 3 message (implying
a filter).
UDP Payload Scanning
• The connectionless nature of UDP means that
services are identified either
• through negative scanning (inferring open ports
based on ICMP unreachable responses of those
which are closed), or
• through use of correctly formatted datagrams to
elicit a response from a service (e.g., DNS, DHCP,
TFTP, and others, as listed in nmappayloads4), known
as payload scanning.
• ICMP is an unreliable indicator because security-
conscious organizations tend to filter messages,
and most operating systems rate-limit ICMP
responses by default.
• Nmap uses a combination of both negative and
payload scanning (versus just a single mode) via
the -sU flag.
• This often clouds output in which both open and
open|filtered states are returned
UDP Payload Scanning
• Using the -sUV flag, you can actively
probe each UDP port and see which
respond.
• Running Nmap in this fashion is,
however, very slow against ambiguous
open|filtered ports, and impractical
when testing large networks.
• This Figure demonstrates using Nmap
to scan five UDP ports of a single host,
taking 114 seconds to complete.
• Deeper testing reveals that port 53 is
indeed listening.
UDP Payload Scanning
• An alternative tool that you can
use to perform UDP payload
scanning is Unicornscan.
• Against the 10.3.0.1 candidate,
results are returned almost
instantly.
Low-Level IP Assessment
Low-Level IP Assessment
• By crafting probe packets and reviewing the responses, you can do
the following:
• Fingerprint the operating system of a target host or network device
• Identify hosts with IP stack implementation flaws
• Enumerate filtering devices and reverse engineer their policy
• Reveal the internal IP addresses of misconfigured systems
Low-Level IP Assessment
• You can manipulate IP and TCP
header values by using Hping3,
Scapy, Nmap, and Firewalk.
• Individual values set within IP
and TCP packet headers are
shown in These Figures.
• By manipulating these fields and
sampling responses to particular
probes, you can reverse
engineer the underlying network
configuration.
Crafting Arbitrary Packets
• This Table lists common Hping3
arguments used to craft TCP
packets from the command line.
• The utility also supports raw IP,
UDP, and scanning modes.
• Power users should consider
Scapy because it offers increased
flexibility.
Crafting Arbitrary Packets
• This Figure demonstrates Hping3
used to perform a TCP SYN port
scan of common ports.
• For full details of the modes
supported, review the
documentation.
Crafting Arbitrary Packets
• To send three TCP SYN probes to
port 80 of 10.3.0.1, use the
command in the following
Figure.
• The IP ID values returned are
sequential, and the flags
received are SYN/ACK, meaning
the port is open.
Crafting Arbitrary Packets
• A closed port sends packets with
RA flags (RST/ACK) set, as
follows:
Crafting Arbitrary Packets
• Next, we find that TCP port 23 is
blocked by an Access Control List
(ACL):