Reconnaissance Techniques · Topic 5 of 8

Scanning Concepts, Host and Port Discovery

Learn network scanning for the CEH exam: TCP flags, ping sweeps, Nmap host discovery and port scan types, port states and common scanning tools.

  • 6 min
  • Includes a diagram
In a nutshell
  • The SYN scan is -sS, the connect scan is -sT, and UDP is -sU.
  • Null, FIN and Xmas: closed returns RST, open returns nothing.
  • ACK scans map firewalls, and idle scans use a zombie host.

What it is

Network scanning is the second phase. It sends probes to the address ranges found in footprinting to learn which hosts are alive, which ports are open and which services answer.

Scanning is active. It generates traffic that an intrusion detection system can log, so authorization matters.

Host discoverywhich hosts are livePort scanningwhich ports are openService discoverywhat runs on themOS discoverywhat system it is

How it works

TCP basics for scanning

A TCP connection starts with a three-way handshake: SYN, then SYN/ACK, then ACK. Many scan types are variations that stop early or send unusual flag combinations.

FlagMeaning
SYNStart a connection
ACKAcknowledge received data
FINClose a connection politely
RSTReset, refuse or abort a connection
PSHPush data to the application now
URGThe data is urgent

Scanning tools

ToolNotes
Nmap (and Zenmap, its graphical front end)The standard scanner for hosts, ports, services and OS
Hping3Crafts custom packets, useful for firewall testing
MasscanVery fast scanner for large address ranges
Angry IP ScannerSimple graphical ping and port scanner
NetScanTools ProWindows toolkit with many network utilities
Metasploit auxiliary scannersScanning modules inside the framework

Host discovery

Host discovery decides which addresses to scan further. Nmap sends different probes depending on the options.

TechniqueNmap optionIdea
ICMP echo ping-PEEcho request, a reply means the host is up
ICMP timestamp or address mask ping-PP, -PMAlternative ICMP types when echo is blocked
ARP ping-PRWorks on the local network and is hard to block
TCP SYN ping-PSSends SYN to a port, either SYN/ACK or RST proves the host is up
TCP ACK ping-PASends ACK, an RST reply shows a live host
UDP ping-PUSends UDP, a port unreachable reply shows a live host
IP protocol ping-POTries other IP protocols
Ping scan only-snHost discovery without a port scan
Skip discovery-PnTreat all hosts as up and scan them anyway

A ping sweep sends echo requests to a whole range. Hosts that block ICMP will not answer, which is why ARP, TCP and UDP probes are also used.

Port and service discovery

Ports are 16 bit numbers, from 0 to 65535. Well-known ports are 0 to 1023, registered ports are 1024 to 49151, and dynamic ports are 49152 to 65535.

Scan typeNmap optionBehaviorResult for open port
TCP connect-sTFull handshake through the operating systemConnection completes
SYN (half-open, stealth)-sSSYN, then RST instead of ACKSYN/ACK received
Null-sNNo flags setNo response
FIN-sFOnly FIN setNo response
Xmas-sXFIN, PSH and URG setNo response
ACK-sAOnly ACK setMaps firewall rules, does not find open ports
Window-sWACK scan that reads the TCP window fieldOpen or closed from window size
Idle-sIUses a zombie host with predictable IP IDSpoofs scan through the zombie
UDP-sUUDP datagramsOften no response
SCTP INIT-sYSCTP version of a SYN scanINIT-ACK received

For null, FIN and Xmas scans, a closed port returns RST and an open port stays silent. These work against systems that follow the TCP specification, and they often fail against Windows hosts, which tend to send RST for both open and closed ports.

For an ACK scan, an RST reply means the port is unfiltered, and no reply or an ICMP unreachable means a firewall is filtering.

For a UDP scan, an ICMP port unreachable message means closed. No response means open or filtered, so UDP scans are slow and uncertain.

Port states in Nmap

A SYN scan: a SYN and ACK reply means the port is open and the scanner answers with RST so the handshake never completes, an RST reply means closed, and no reply or an ICMP unreachable means filtered.

StateMeaning
openAn application accepts connections
closedReachable but nothing listens
filteredA firewall or filter blocks the probe, so the state is unknown
unfilteredReachable but open or closed is not determined (ACK scan)
open or filteredCannot tell, typical for UDP, null, FIN and Xmas
closed or filteredCannot tell, used by the idle scan

Service version detection

Service discovery learns which program listens on a port and its version. In Nmap, -sV probes the open ports and compares the answers with a database. -A turns on OS detection, version detection, script scanning and traceroute together. The Nmap Scripting Engine (NSE) runs scripts for deeper checks. Timing templates -T0 to -T5 (paranoid, sneaky, polite, normal, aggressive, insane) trade speed for stealth.

By default Nmap scans the 1000 most common ports. The -p option picks ports, -p- covers all 65535, and -F scans fewer ports than the default.

A worked example

A tester sweeps a /24 network with an ARP ping, gets 14 live hosts, and then runs a SYN scan on all of them. One host shows port 443 as open and port 8080 as filtered. A version scan of the open port shows an old web server release, which becomes a finding for the report.

How the exam asks about this

  • "Which scan sends SYN and then RST, so no full connection is made?" -> SYN (half-open or stealth) scan, -sS.
  • "A scan sets FIN, PSH and URG. What is it?" -> An Xmas scan.
  • "Which scan identifies firewall rules rather than open ports?" -> The ACK scan.

What to remember for the exam

  • The SYN scan is -sS, the connect scan is -sT, and UDP is -sU.
  • Null, FIN and Xmas: closed returns RST, open returns nothing.
  • ACK scans map firewalls, and idle scans use a zombie host.
  • Filtered means a firewall blocks the probe.
  • -Pn skips host discovery, and -sn only does discovery.
Watch out

Null, FIN and Xmas scans do not work reliably against Windows systems, so a question about unreliable results on Windows points to those scans.

Common mistakes

Calling the SYN scan "stealthy" without qualification. Modern intrusion detection systems log it. The name only means no full connection.

Reading no response as closed. For UDP and for flag-based scans it can mean open or filtered.

Mixing up -sn and -Pn. The first does discovery only. The second skips discovery.

Check yourself

  • What does a SYN/ACK reply to a SYN scan show?

    That the port is open.

  • What does the Nmap option -Pn do?

    It skips host discovery and scans the target as if it were up.

  • What does an ICMP port unreachable reply to a UDP probe mean?

    The UDP port is closed.

Topic 5 of 8 in Reconnaissance Techniques

Test yourself on Reconnaissance Techniques

The full EC-Council 312-50 question bank has 1,000 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by EC-Council. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.