Scanning Strategy: A Three-Phase Approach Instead of a Single Command
Not a single Russian-language manual explains a simple thing: scanning is not a single command, but a sequence of steps, where each one builds on the result of the previous one. Command nmap -A -p- targetWhile technically functional, it creates three problems in practice. For more details, see our guide to creating CTF tasks .
Time. A full scan of 65,535 TCP ports, including version detection and scripting, can take anywhere from a few minutes to an hour, depending on the network, timing, and number of open ports. In a CTF competition, where every minute counts, this is an unaffordable luxury.
Noise. An aggressive scan generates thousands of packets per second. In MITRE ATT&CK terminology, this is Active Scanning (T1595, Reconnaissance) —this is the activity the blue team uses to detect the initial stages of an attack. If the task includes an IDS component, your IP will be banned before you see the results.
Target instability. Vulnerable services in CTF labs often run on custom binaries with a limited thread pool. Dozens of simultaneous nmap connections—and the process crashes before exploitation begins. On HackTheBox and TryHackMe, this is a regular occurrence for Easy and Medium machines.
The nmap network reconnaissance working strategy is built in three phases.
Phase 1 - Quick scan of top ports. Let's launch nmap --top-ports 1000 -T4 target— a thousand of the most common TCP ports in 15-30 seconds. This is more than enough to detect SSH on 22, HTTP on 80/443, SMB on 445, and other standard services. A thousand ports is nmap's default set, and according to nmap.org, it covers the vast majority of real-world services.
Phase 2 is a full port scan. If Phase 1 didn't yield enough clues or the task involves non-standard ports, we launch it. nmap -p- -T4 targetThe output is a complete list of open ports without details.
Phase 3 is a targeted enumeration. We take specific ports from Phase 1 or 2 and precisely define versions: nmap -sV -sC -p 22,80,8080,9999 targetScripts and probes are sent only to the required ports—quickly, accurately, and without unnecessary load on the host.
Understanding this sequence is useful not only for documentation, but also for understanding how your activity is seen by the defensive side.
Nmap Port Scan Types for CTF
Nmap supports over a dozen scanning methods. Beginners often try to solve every problem with the default SYN scan, but the method should be chosen based on the situation. Three types are critically important to get started.
TCP SYN scan — nmap stealth scan
SYN scan ( -sS) is the default method when running with root privileges. It's often called "half-open" or stealth port scanning. The mechanics are as follows: nmap sends a TCP SYN packet, receives a SYN/ACK from the open port, and immediately responds with a RST—the three-way handshake is not completed. A full TCP connection is not established, and most services don't log this attempt.
In practice: sudo nmap -sS 10.10.10.5The key is - sudo: Sending raw TCP packets requires root privileges. Without them, nmap will silently switch to TCP Connect.
SYN scan works against any RFC-compliant TCP stack and clearly distinguishes between three port states: open (SYN/ACK), closed (RST), and filtered (no response or ICMP unreachable). On a fast network, it scans thousands of ports per second. It's the optimal choice for CTF: fast, accurate, and leaves a minimal footprint.
A nuance worth keeping in mind: the word "stealth" in the name nmap stealth scan doesn't mean invisibility. Modern IDS systems (Snort, Suricata) detect SYN scans without any problems—they just leave fewer traces in service logs compared to a full connection.
TCP Connect: Scanning without Root
If you work without sudo— in a restricted container, on a shared host, or in an environment without raw socket access — nmap uses TCP Connect ( -sT). Instead of raw packets, it calls the system connect()— the same mechanism used by browsers and any network applications. The connection is established completely: SYN → SYN/ACK → ACK.
Team: nmap -sT 10.10.10.5.
The downsides are straightforward: every connection is logged on the target host, and scanning requires more packets and time. Some services log every attempt that fails without transmitting data to syslog, so the administrator will see a series of strange connections from a single IP address. CTF Connect scanning works fine, but be aware that it leaves more traces.
UDP: The Ports Everyone Forgets About
UDP scanning ( -sU) is the most underrated part of nmap network reconnaissance. Beginners skip UDP entirely and then spend hours searching for an attack vector among TCP ports, unaware that the key to the machine lies on SNMP (port 161) or TFTP (port 69). DNS on 53, DHCP on 67/68—all these services operate over UDP.
The main problem is speed. UDP has no acknowledgement mechanism: if a port is open, there may be no response at all, and nmap marks it as open|filteredClosed ports return ICMP Port Unreachable (Type 3, Code 3), but many operating systems (especially Linux) strictly limit the frequency of ICMP responses, which stretches the scan for tens of minutes.
Practical advice: don't scan all UDP ports. Command sudo nmap -sU --top-ports 50 10.10.10.5Covers the most common UDP services in a reasonable amount of time. UDP scanning can be combined with TCP SYN scanning in a single run: sudo nmap -sS -sU --top-ports 200 10.10.10.5- will check both protocols simultaneously.
Nmap Network Reconnaissance: Enumeration of Services
A list of open ports is a starting point, not a final result. The real value lies in the software versions: Apache httpd 2.4.49 with path traversal and Apache 2.4.62 without it are two different worlds. It's the enumeration of services that turns reconnaissance into an attack plan.
Determining versions with -sV and --version-intensity
Flag -sVforces nmap to connect to open ports, send special probes, and match responses against a database nmap-service-probes. There are thousands of templates out there for hundreds of protocols.
A typical CTF command: nmap -sV -p 22,80,445 10.10.10.5The output may look like this:
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.9p1 Debian 10+deb10u2
80/tcp open http Apache httpd 2.4.38 ((Debian))
445/tcp open smb Samba smbd 4.9.5-Debian
From this, you can search for CVEs for specific versions of OpenSSH and Apache. The version is the first thing that catches your eye.
The parameter that most beginner guides ignore is --version-intensityIt controls how many probes nmap sends to determine the service version. The range is from 0 (only the most likely probes) to 9 (all available). The default is 7, and if --version-all— 9. For CTF, the optimal value is 5: nmap -sV --version-intensity 5 -p 22,80 target— covers standard services without unnecessary delays. If nmap doesn't determine the version, try again with --version-intensity 9only for the problematic port.
OS detection and when to use -A
Flag -OEnables operating system fingerprinting. Nmap analyzes the target's TCP/IP stack, including TTL values, TCP window sizes, and behavior during non-standard requests. The results are compared to a database. nmap-os-dbThe method works best when the target has both open and closed ports—the more diverse the responses, the more accurate the identification.
Team: sudo nmap -O -p 22,80 10.10.10.5If confidence is low, add --osscan-guess— nmap will return the most likely option.
Aggressive flag -Aunites -sV, -O, -sC(default scripts) and traceroute. Convenient for the final phase, but dangerous as a first command. -Aruns scripts that can be noisy and load the host. Use -AOnly in Phase 3, on known ports. Never as a starting team on an unknown target.
Not a single Russian-language manual explains a simple thing: scanning is not a single command, but a sequence of steps, where each one builds on the result of the previous one. Command nmap -A -p- targetWhile technically functional, it creates three problems in practice. For more details, see our guide to creating CTF tasks .
Time. A full scan of 65,535 TCP ports, including version detection and scripting, can take anywhere from a few minutes to an hour, depending on the network, timing, and number of open ports. In a CTF competition, where every minute counts, this is an unaffordable luxury.
Noise. An aggressive scan generates thousands of packets per second. In MITRE ATT&CK terminology, this is Active Scanning (T1595, Reconnaissance) —this is the activity the blue team uses to detect the initial stages of an attack. If the task includes an IDS component, your IP will be banned before you see the results.
Target instability. Vulnerable services in CTF labs often run on custom binaries with a limited thread pool. Dozens of simultaneous nmap connections—and the process crashes before exploitation begins. On HackTheBox and TryHackMe, this is a regular occurrence for Easy and Medium machines.
The nmap network reconnaissance working strategy is built in three phases.
Phase 1 - Quick scan of top ports. Let's launch nmap --top-ports 1000 -T4 target— a thousand of the most common TCP ports in 15-30 seconds. This is more than enough to detect SSH on 22, HTTP on 80/443, SMB on 445, and other standard services. A thousand ports is nmap's default set, and according to nmap.org, it covers the vast majority of real-world services.
Phase 2 is a full port scan. If Phase 1 didn't yield enough clues or the task involves non-standard ports, we launch it. nmap -p- -T4 targetThe output is a complete list of open ports without details.
Phase 3 is a targeted enumeration. We take specific ports from Phase 1 or 2 and precisely define versions: nmap -sV -sC -p 22,80,8080,9999 targetScripts and probes are sent only to the required ports—quickly, accurately, and without unnecessary load on the host.
Understanding this sequence is useful not only for documentation, but also for understanding how your activity is seen by the defensive side.
Nmap Port Scan Types for CTF
Nmap supports over a dozen scanning methods. Beginners often try to solve every problem with the default SYN scan, but the method should be chosen based on the situation. Three types are critically important to get started.
TCP SYN scan — nmap stealth scan
SYN scan ( -sS) is the default method when running with root privileges. It's often called "half-open" or stealth port scanning. The mechanics are as follows: nmap sends a TCP SYN packet, receives a SYN/ACK from the open port, and immediately responds with a RST—the three-way handshake is not completed. A full TCP connection is not established, and most services don't log this attempt.
In practice: sudo nmap -sS 10.10.10.5The key is - sudo: Sending raw TCP packets requires root privileges. Without them, nmap will silently switch to TCP Connect.
SYN scan works against any RFC-compliant TCP stack and clearly distinguishes between three port states: open (SYN/ACK), closed (RST), and filtered (no response or ICMP unreachable). On a fast network, it scans thousands of ports per second. It's the optimal choice for CTF: fast, accurate, and leaves a minimal footprint.
A nuance worth keeping in mind: the word "stealth" in the name nmap stealth scan doesn't mean invisibility. Modern IDS systems (Snort, Suricata) detect SYN scans without any problems—they just leave fewer traces in service logs compared to a full connection.
TCP Connect: Scanning without Root
If you work without sudo— in a restricted container, on a shared host, or in an environment without raw socket access — nmap uses TCP Connect ( -sT). Instead of raw packets, it calls the system connect()— the same mechanism used by browsers and any network applications. The connection is established completely: SYN → SYN/ACK → ACK.
Team: nmap -sT 10.10.10.5.
The downsides are straightforward: every connection is logged on the target host, and scanning requires more packets and time. Some services log every attempt that fails without transmitting data to syslog, so the administrator will see a series of strange connections from a single IP address. CTF Connect scanning works fine, but be aware that it leaves more traces.
UDP: The Ports Everyone Forgets About
UDP scanning ( -sU) is the most underrated part of nmap network reconnaissance. Beginners skip UDP entirely and then spend hours searching for an attack vector among TCP ports, unaware that the key to the machine lies on SNMP (port 161) or TFTP (port 69). DNS on 53, DHCP on 67/68—all these services operate over UDP.
The main problem is speed. UDP has no acknowledgement mechanism: if a port is open, there may be no response at all, and nmap marks it as open|filteredClosed ports return ICMP Port Unreachable (Type 3, Code 3), but many operating systems (especially Linux) strictly limit the frequency of ICMP responses, which stretches the scan for tens of minutes.
Practical advice: don't scan all UDP ports. Command sudo nmap -sU --top-ports 50 10.10.10.5Covers the most common UDP services in a reasonable amount of time. UDP scanning can be combined with TCP SYN scanning in a single run: sudo nmap -sS -sU --top-ports 200 10.10.10.5- will check both protocols simultaneously.
Nmap Network Reconnaissance: Enumeration of Services
A list of open ports is a starting point, not a final result. The real value lies in the software versions: Apache httpd 2.4.49 with path traversal and Apache 2.4.62 without it are two different worlds. It's the enumeration of services that turns reconnaissance into an attack plan.
Determining versions with -sV and --version-intensity
Flag -sVforces nmap to connect to open ports, send special probes, and match responses against a database nmap-service-probes. There are thousands of templates out there for hundreds of protocols.
A typical CTF command: nmap -sV -p 22,80,445 10.10.10.5The output may look like this:
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.9p1 Debian 10+deb10u2
80/tcp open http Apache httpd 2.4.38 ((Debian))
445/tcp open smb Samba smbd 4.9.5-Debian
From this, you can search for CVEs for specific versions of OpenSSH and Apache. The version is the first thing that catches your eye.
The parameter that most beginner guides ignore is --version-intensityIt controls how many probes nmap sends to determine the service version. The range is from 0 (only the most likely probes) to 9 (all available). The default is 7, and if --version-all— 9. For CTF, the optimal value is 5: nmap -sV --version-intensity 5 -p 22,80 target— covers standard services without unnecessary delays. If nmap doesn't determine the version, try again with --version-intensity 9only for the problematic port.
OS detection and when to use -A
Flag -OEnables operating system fingerprinting. Nmap analyzes the target's TCP/IP stack, including TTL values, TCP window sizes, and behavior during non-standard requests. The results are compared to a database. nmap-os-dbThe method works best when the target has both open and closed ports—the more diverse the responses, the more accurate the identification.
Team: sudo nmap -O -p 22,80 10.10.10.5If confidence is low, add --osscan-guess— nmap will return the most likely option.
Aggressive flag -Aunites -sV, -O, -sC(default scripts) and traceroute. Convenient for the final phase, but dangerous as a first command. -Aruns scripts that can be noisy and load the host. Use -AOnly in Phase 3, on known ports. Never as a starting team on an unknown target.