All exams← All Certified Ethical Hacker (CEH) notes

Scanning Networks: Certified Ethical Hacker (CEH) revision notes

Revision notes

## Network Scanning: CEH Revision

Network scanning is a crucial phase in ethical hacking, following reconnaissance. Its primary goal is to identify live hosts, open ports, services running on those ports, operating systems, and potential vulnerabilities within a target network. This active process provides a detailed blueprint of the target's network infrastructure.

## Host Discovery

Before scanning ports, identifying active hosts is essential. Tools like Nmap are invaluable here.

  • Ping Sweeps (ICMP): Sending ICMP Echo Request packets to a range of IPs. If an Echo Reply is received, the host is live. Nmap's `-sn` (ping scan) option performs this.
  • ARP Scans: For local networks, ARP requests can identify active hosts even if they block ICMP.
  • TCP/UDP Pings: Sending TCP SYN or ACK packets to common ports (e.g., 80, 443) or UDP packets to known ports (e.g., 53, 161) can also reveal live hosts, especially if ICMP is blocked.

## Port Scanning Techniques

Port scanning identifies which ports are open, closed, or filtered.

  • TCP SYN Scan (-sS): The stealthiest and most common TCP scan. It sends a SYN packet and if a SYN/ACK is received, the port is open, but the scanner sends an RST instead of an ACK, never completing the handshake. This makes it harder for firewalls/IDPS to log. Requires root privileges.
  • TCP Connect Scan (-sT): Completes the full three-way handshake. This is noisy, easily logged, but doesn't require root. Used when SYN scans are not possible.
  • UDP Scan (-sU): Sends UDP packets to target ports. If an ICMP Port Unreachable message is received, the port is closed. No response usually means the port is open or filtered. Slower and less reliable than TCP scans.
  • FIN Scan (-sF), XMAS Scan (-sX), NULL Scan (-sN): These scans exploit RFC 793 behavior. For closed ports, they should respond with an RST. For open ports, they should *not* respond. They are stealthier but less effective against Windows hosts due to different TCP stack implementations.
  • ACK Scan (-sA): Used to map firewall rulesets. It determines if ports are filtered (no RST) or unfiltered (RST received), but *cannot* determine if a port is open or closed.

## OS and Service Detection

Beyond just open ports, identifying the specific services and operating systems provides critical information.

  • OS Detection (-O): Nmap analyzes TCP/IP stack fingerprints (e.g., initial window size, TCP options) to guess the target's operating system.
  • Service Version Detection (-sV): Nmap connects to open ports and queries the services to identify the application and its exact version (e.g., Apache 2.4.41, OpenSSH 8.2p1). This is vital for finding known vulnerabilities.

## Evasion Techniques

Attackers employ methods to bypass security controls during scanning:

  • Decoy Scans (-D): Sending scan packets from multiple spoofed IP addresses alongside the real one to confuse logs.
  • Fragmentation (--frag): Splitting scan packets into smaller fragments to bypass simple packet filters.
  • Timing Options (-T): Adjusting scan speed to avoid detection by IDPS (e.g., `-T0` for paranoid, `-T5` for insane).

Tools: The primary tool for network scanning is Nmap (Network Mapper), renowned for its versatility and powerful features. Other tools include Hping3 for custom packet crafting and Netcat for banner grabbing.

Key facts

Flashcards

What is the primary purpose of network scanning in ethical hacking?
To identify live hosts, open ports, running services, operating systems, and potential vulnerabilities within a target network.
tap to reveal
Which Nmap scan type is considered the 'stealthiest' and why?
TCP SYN scan (-sS), because it performs a 'half-open' scan without completing the TCP three-way handshake, making it harder to log.
tap to reveal
What Nmap option is used for OS detection?
` -O ` (uppercase O)
tap to reveal
How does an Nmap UDP scan (-sU) typically determine if a port is closed?
By receiving an ICMP Port Unreachable message from the target host.
tap to reveal
What is the main use of an Nmap ACK scan (-sA)?
To map firewall rulesets, determining if ports are filtered or unfiltered, but not if they are open or closed.
tap to reveal
Name two Nmap techniques used to evade IDS/Firewalls.
Decoy scans (-D) and packet fragmentation (--frag).
tap to reveal
What Nmap option is used to identify the specific application and its version running on an open port?
` -sV ` (service version detection)
tap to reveal
What is the main difference between Nmap's TCP Connect scan (-sT) and SYN scan (-sS)?
Connect scan completes the full TCP handshake (noisy, no root needed), while SYN scan performs a half-open handshake (stealthier, requires root).
tap to reveal
Practice questions

Scanning Networks: 5 practice questions

Q1. In Nmap, which scan type is known as a 'half-open' or 'stealth' scan because it does not complete the full TCP three-way handshake, making it less likely to be logged?
  • A.  TCP Connect Scan (-sT)
  • B.  SYN Stealth Scan (-sS)
  • C.  XMAS Scan (-sX)
  • D.  UDP Scan (-sU)
Show answer & explanation
✓ Answer: B. SYN Stealth Scan (-sS)
The SYN Stealth Scan (-sS) sends a SYN packet and awaits a SYN/ACK response. If received, the port is open, but the scanner immediately sends an RST packet, avoiding a full connection and logging.
Q2. An ethical hacker is attempting to map out the ruleset of a stateless firewall. Which Nmap scan is specifically designed for this purpose by sending packets with only the ACK flag set?
  • A.  ACK Flag Probe Scan (-sA)
  • B.  Window Scan (-sW)
  • C.  NULL Scan (-sN)
  • D.  FIN Scan (-sF)
Show answer & explanation
✓ Answer: A. ACK Flag Probe Scan (-sA)
The ACK scan (-sA) is used to map firewall rulesets. It determines if they are stateful or stateless and which ports are filtered, as unfiltered ports will return an RST packet.
Q3. During a FIN scan (-sF) against a target system with a closed port that follows RFC 793, what response should the ethical hacker expect to receive from the target?
  • A.  No response
  • B.  An RST/ACK packet
  • C.  An ICMP Port Unreachable message
  • D.  A SYN/ACK packet
Show answer & explanation
✓ Answer: B. An RST/ACK packet
According to TCP RFC 793, a closed port must respond to a probe packet that doesn't have the SYN bit set (like a FIN packet) with an RST/ACK packet. An open port would give no response.
Q4. Which of the following tools is primarily a network vulnerability scanner, designed to check for thousands of known vulnerabilities, misconfigurations, and potential security holes?
  • A.  John the Ripper
  • B.  Nessus
  • C.  Wireshark
  • D.  Metasploit
Show answer & explanation
✓ Answer: B. Nessus
Nessus is a widely-used vulnerability scanner that automates the process of identifying security weaknesses in a network, unlike Wireshark (packet analyzer) or Metasploit (exploitation framework).
Q5. An ethical hacker is on the same Layer 2 subnet as their target and wants to discover live hosts quickly and reliably, even if they have host-based firewalls blocking ICMP. Which technique is most suitable?
  • A.  ARP Scan
  • B.  TCP SYN Ping
  • C.  UDP Ping
  • D.  ICMP Echo Ping Sweep
Show answer & explanation
✓ Answer: A. ARP Scan
An ARP scan is highly effective on a local subnet because it operates at Layer 2 (Data Link) and cannot be easily blocked by host firewalls, which typically operate at Layer 3 (Network) and above.
Test yourself
See the Certified Ethical Hacker (CEH) page

More Certified Ethical Hacker (CEH) topics