skip to content

Scan Types

The scan-type flags differ in which packets go out, what a response implies, and whether you need root. Interviewers ask you to justify -sS over -sT, or why UDP scanning is slow and ambiguous.

on this pageshow

questions

5

In Nmap, what does a SYN scan (-sS) send, and how does it read open, closed and filtered answers from a firewalled test server?

level: juniorimportance: must knowfreq 52%

answer

  1. half of a handshake
  2. the default for privileged users
  3. reply flags decide the state
  4. silence and ICMP errors share a state
  5. which handshake packet is never sent

basics

~20 s

A SYN scan sends one TCP SYN per port and never completes the handshake. A SYN/ACK reply means open, a RST means closed, and silence or an ICMP unreachable error means filtered. It is Nmap's default for privileged users.

solid answer

~40 s

`-sS` sends a raw TCP SYN to each port and never sends the final ACK, so no connection is completed (half-open). A SYN/ACK back means `open`, a RST means `closed`, and no answer after retransmissions, or an ICMP unreachable error, means `filtered`. It needs raw-packet privilege and is Nmap's default when the user has it. The state is an inference from one reply, not a fact about the port: the same port can read `open` from the local network and `filtered` from across the internet, so an assessor records where the scan ran from and uses `--reason` to see which reply produced each label.

code

bash · 2 lines
bash
# SYN scan of four ports, printing the reason each state was assigned
sudo nmap -sS -p 22,80,443,8080 --reason 192.0.2.10

go deeper

for a junior

Recall the three answers: SYN/ACK is open, RST is closed, silence or an ICMP unreachable error is filtered, and no final ACK is ever sent.

for a middle

Explain why raw packets need privilege, why a SYN scan is the default for privileged users, and why silence costs retransmissions and time.

for a senior

Show that the label is an inference from one reply on one path: compare vantage points, use --reason, and say what firewall and flow logs would show for the same scan.

for a principal

Defend a standing scan method: SYN scans are cheap and reliable, but the evidence is only as good as the recorded vantage point and the signed scope behind it.

## What the scan sends Nmap's **TCP SYN scan** (`-sS`) writes a raw TCP segment with only the SYN flag set to each target port, exactly as a client would to start a connection, and then waits. It never sends the final ACK that would complete the three-way handshake, which is why it is called a **half-open** scan. Because Nmap builds and reads raw packets itself, the scan needs raw-packet privilege (root on Unix). When that privilege is present, a SYN scan is what Nmap does by default if no scan type is given. The reference guide gives the reasons it is the default and the most popular technique: - it is fast, scanning thousands of ports per second on a network without restrictive firewalls; - it works against any compliant TCP stack rather than depending on the quirks of particular platforms; - it gives a clear, reliable split between `open`, `closed` and `filtered`. ## Reading the answers | What comes back for the SYN probe | Port state | Reason Nmap reports with `--reason` | |---|---|---| | A segment with SYN and ACK set | `open` | `syn-ack` | | A segment with RST set | `closed` | `reset` | | Nothing, after several retransmissions | `filtered` | `no-response` | | An ICMP unreachable error (type 3, code 0, 1, 2, 3, 9, 10 or 13) | `filtered` | an ICMP reason such as `admin-prohibited` for code 13 | A bare SYN coming back with no ACK also marks the port open; the reference guide calls this an extremely rare simultaneous-open case. The three states are an **inference from one reply (or its absence)**, not a statement about the port itself: the reference guide stresses that a state describes how Nmap sees the port, so the same port can read `open` from the local network and `filtered` from across the internet. ## Why silence is not the same as a closed port A closed port is reachable and answers with a reset immediately. A port behind a filter that drops the probe answers with nothing, so Nmap has to retransmit several times in case the probe was lost to congestion. That is why filtered ports slow a scan down dramatically, and why a report with many `filtered` lines is also a report that took a long time to produce. ## What the defender sees Because the handshake is never completed, the application on the target usually has no connection to log. The scan is still visible in other places: 1. **Firewall logs** record SYN segments, denied or accepted, from one source to many destination ports in a short time. 2. **Connection-tracking and flow records** show many attempts that never became established connections. 3. **A sensor** can alert on one source touching many ports; how that rule is written belongs to the network-defence owners, but the reference guide is blunt that a decent IDS catches this scan. Half-open therefore means "no completed connection", never "no evidence". Neither an empty application log nor a quiet host proves that nothing was scanned. ## Authorisation and scope A SYN scan is a probe of a system you do not own unless a written scope says otherwise. An assessor works from a signed scope listing the address ranges, the ports and the window, and records the scanner's network position next to the results, because that position decides what answers come back. A typical audit line looks like this: ```bash sudo nmap -sS -p 22,80,443,8080 --reason 192.0.2.10 ``` The `--reason` column then lets a reviewer check each state against the reply that produced it instead of taking the label on trust.

  • Why can one Nmap SYN scan label the same port open from one network and filtered from another?
    A state describes how Nmap sees the port from where it scans, not an intrinsic property of the port. A firewall policy that allows the inside network and drops the outside returns a SYN/ACK to one scanner and silence to the other. Record the scanner's network position with the results, and treat a difference between vantage points as a finding about the filtering path.
  • Why does a report full of filtered ports usually come from a slow scan?
    A closed port answers at once with a reset, but a filter that drops probes gives Nmap nothing to read. Nmap then retransmits several times in case the probe was lost to congestion before it settles on filtered. Many silent ports multiply that waiting, so a large filtered count is both a firewall finding and the main reason the scan took long.
  • Why is a closed port still useful information for an auditor?
    A closed port is reachable: it received the probe and answered, with no application listening. On a host that was meant to be shielded, a closed state rather than filtered shows that no filter stands in front of that port, and it may open later. Administrators who want such ports hidden block them so they read filtered instead.

  • A SYN scan completes the handshake and then closes the connection
  • No reply to the probe means the port is closed
  • A SYN scan works for any user without raw-packet privilege
  • Filtered means the port is open behind a firewall
  • Half-open scanning leaves no trace anywhere on the network
open as a page

Why would an assessor choose Nmap's SYN scan over the TCP connect scan, and what changes in privilege, packets and target logs?

level: middleimportance: must knowfreq 46%

basics

~20 s

-sS sends raw SYN packets, needs raw-packet privilege and never completes the handshake. -sT asks the operating system to connect(), needs no privilege, but completes connections to open ports, so it is slower and more likely to be logged.

open as a page

What does an authorised Nmap ACK scan (-sA) of a firewalled test server map when it reports ports unfiltered and filtered, and why can it never report open?

level: seniorimportance: should knowfreq 20%

basics

~20 s

An ACK scan sends bare ACK segments. A reset, from open and closed ports alike, means unfiltered; silence or an ICMP unreachable error means filtered. It maps what the rule set lets through, never which ports are open.

open as a page

Why is an authorised Nmap UDP scan (-sU) of a firewalled test server so slow, and why does it list most ports as open|filtered?

level: seniorimportance: should knowfreq 26%

basics

~20 s

A UDP scan sends a datagram per port, and only a UDP reply (open) or an ICMP port unreachable (closed) is conclusive. Silence is reported open|filtered, and retransmissions plus rate-limited ICMP errors make the scan slow.

open as a page

Why do Nmap's FIN, NULL and Xmas scans (-sF, -sN, -sX) report a Linux host mostly open|filtered but a Windows host all closed?

level: middleimportance: nice to knowfreq 14%

basics

~20 s

NULL, FIN and Xmas probes carry no SYN, RST or ACK bit. An RFC 793-compliant stack resets them on closed ports and drops them on open ones: reset means closed, silence means open|filtered. Stacks that always reset make every port look closed.

open as a page