Cyber Security Basics 📂 Slides · 17 of 17 50 min read

Scanning Networks: Host Discovery, Port Scanning, Stealth Scans & OS Fingerprinting

A visual, story-driven guide to network scanning — the reconnaissance phase after footprinting. Learn TCP flags and the 3-way handshake, the full port-scan family (SYN/stealth, Xmas, FIN, NULL, ACK, UDP, IDLE zombie), OS fingerprinting, banner grabbing, IDS evasion and proxies, plus the defenses that detect and stop each one.

Scanning Networks

Phase 2 of the attack. Recon told the attacker where to look — scanning knocks on every door to learn what's alive, open, and vulnerable. Live hosts, ports, services, and OS — and how defenders see the knocking.
Host & Port Discovery TCP Flags Stealth Scans Detection & Defense

Press Next → or use ← → arrow keys

The Big Picture

From Recon to Scanning

Attackersends probes Target network host host host probe → ← network information (which hosts/ports/services reply)
🎯
What Scanning Sets Out to Learn

Live hosts · open & closed ports · the OS · running services & processes · the presence of firewalls/IDS · system architecture · and ultimately vulnerabilities. It turns a list of addresses into a live map of the attack surface.

The Story

Rattling Every Doorknob

The burglar who tests every window
A burglar who has already watched a building (reconnaissance) now walks the perimeter at night, quietly trying every door and window to see which are unlocked — and listening for an alarm. Network scanning is that walk: sending crafted packets to thousands of ports and watching which reply "open," which say "closed," and which stay suspiciously silent behind a firewall.
💡
Why It Matters to Defenders

Internet-wide scanners hit every public IP constantly — a new server is typically found and probed within minutes of going online. The exposed, unpatched service you forgot about is exactly what the scan is built to find first.

Foundations

The Language of Scanning — TCP Flags

Most scans work by sending TCP packets with specific flags set and reading the reply. Six flags matter:

FlagMeaningFlagMeaning
SYNInitiate a connectionPSHPush buffered data now
ACKAcknowledge a packetFINGracefully end a connection
URGData is urgent, process firstRSTReset / refuse the connection
🔌
TCP vs UDP

TCP is connection-oriented (handshake, reliable). UDP is connectionless — no flags, no handshake, so it's scanned differently.

🧩
Scans Are Just Flag Combinations

Every scan type below is defined by which flags it sets and what reply it expects — that's the whole trick.

Foundations

The TCP Three-Way Handshake

Host A Host B 1 · SYN 2 · SYN + ACK 3 · ACK — connection established ✓
🤝
Three Steps to a Connection

A sends SYN → B replies SYN+ACK → A replies ACK. That's a live TCP session. Every scan is a deliberate deviation from this dance — completing it, half-completing it, or sending nonsense flags to see how the target reacts.

Methodology

The Scanning Methodology

1 · Live hosts 2 · Open ports 3 · Beyond IDS 4 · Banner grab 5 · Vuln scan 6 · Network diagram 7 · Prepare proxies 8 · Document findings
🧭
A Disciplined Sequence

Find who's alive → find what's open → evade detection → grab banners (service/OS) → scan for vulnerabilities → map the network → route through proxies → and document everything. Defenders run the same steps against themselves.

Step 1 · Live Hosts

Host Discovery — Who's Alive?

ScannerICMP echo → 10.0.0.5 · reply ✓ (live) 10.0.0.6 · reply ✓ (live) 10.0.0.7 · no reply (down/filtered)
📶
ICMP ping & ping sweep

Send an ICMP echo request; a reply means the host is live. A ping sweep does this across a whole range at once (nmap -sn 10.0.0.0/24).

🧰
Beyond ICMP

When ICMP is blocked, scanners use TCP/ARP pings, SSDP, and tools like Angry IP Scanner or nmap to find hosts anyway.

Step 2 · Port Scanning

The Port-Scan Family Tree

Scanning UDP scan TCP scan Open · Full (-sT) Stealth (-sS) Third-party / IDLE Xmas FIN NULL ACK probe
🌳
Two Families, Many Techniques

UDP scanning vs TCP scanning — and TCP splits into open (complete the handshake), stealth (half-open & weird-flag scans that dodge logs), and third-party/IDLE (bounce off a zombie to hide the source).

TCP Scans

Full-Open vs Half-Open (Stealth)

FULL OPEN · nmap -sT · completes handshake Scanner Target SYN SYN+ACK ACK ✓ (port open, but logged) HALF-OPEN / STEALTH · nmap -sS · never finishes Scanner Target SYN SYN+ACK (open!) RST ✗ (abort → often unlogged) Closed port?Target replies RST to thefirst SYN — no service there.
🕵️
Why "Stealth" Wins

Full-open completes the handshake — reliable but logged by the application. Half-open sends RST instead of the final ACK, so the connection never fully forms and older logging often misses it. An open port answers SYN+ACK; a closed port answers RST.

TCP Scans · Inverse Flag

Xmas, FIN & NULL Scans

These "inverse-flag" scans exploit a rule in the TCP spec (RFC 793): a closed port must reply RST; an open port stays silent.

ScanFlags sentOpen portClosed portnmap
XmasFIN+URG+PSHNo responseRST-sX
FINFIN onlyNo responseRST-sF
NULLno flagsNo responseRST-sN
🎄
Why send "bogus" flags?

A packet with no valid session looks like noise, so it can slip past simple filters that only watch for SYN.

🪟
The catch

They only work on RFC-793 stacks. Modern Windows ignores them, so "no response" becomes ambiguous — a known limitation.

TCP Scans · Advanced

ACK Probe & the IDLE (Zombie) Scan

🧱
ACK flag probe (-sA)

Sends a lone ACK. A returned RST = the port is unfiltered (reachable); no reply = a stateful firewall is filtering it. It maps firewalls, not open ports.

🧟
IDLE / IPID scan (-sI)

The attacker never touches the target directly — they bounce packets off a "zombie" host and read its IP-ID counter. The target logs the zombie, not the attacker.

Attacker Zombie Target 1 · probe zombie IPID 2 · spoofed SYN "from zombie" → target 3 · target replies to zombie 4 · re-probe IPID → +2 = open
UDP Scans

Scanning the Silent Protocol — UDP

OPEN PORT — silence Scanner Target UDP probe → …no response (assumed open|filtered) CLOSED PORT — ICMP error Scanner Target UDP probe → ICMP "port unreachable" = closed
🐌
Slow, But Important

UDP has no handshake, so an open port simply stays silent — the scanner infers state from the absence of an ICMP "port unreachable." It's slow and lossy (nmap -sU), but essential: DNS, SNMP, and many trojans live on UDP.

Reading Results

What a Scan Actually Tells You

A real nmap result
$ nmap -sS -sV 10.0.0.6
PORT     STATE  SERVICE   VERSION
22/tcp   open   ssh       OpenSSH 8.2
80/tcp   open   http      nginx 1.18
443/tcp  open   https     nginx 1.18
3306/tcp closed mysql
8080/tcp filtered http-proxy
MAC Address: 00:0C:29:… (VMware)
open
A service is listening & reachable — the doors that matter.
closed
Host is up but nothing listens on that port.
filtered
A firewall/IDS is blocking — the probe got no clear answer.
🔎
Version Detection Is the Real Prize

-sV adds the exact software & version (OpenSSH 8.2, nginx 1.18). That's what an attacker matches against a vulnerability database — and what a defender patches first.

OS & Service ID

OS Fingerprinting & Banner Grabbing

📡
Active fingerprinting
Send crafted TCP/UDP packets and analyze the exact replies (nmap -O). Precise — but it touches the target and can be logged.
👂
Passive fingerprinting
Just watch traffic and read TTL and TCP window size — no packets sent, so it's invisible.
OSTTLTCP Window
Linux645840
FreeBSD6465535
Windows XP12865535
Windows Vista / 7 / Server 20081288192
Cisco Router (iOS 12.4)2554128
🏷️
Banner Grabbing

Many services announce their name & version in a banner (via Telnet, Netcat, etc.). Defense: disable or fake banners, mask the server header, hide file extensions.

Evasion

Scanning Beyond the Firewall & IDS

🧩
Fragmentation
Split the probe into tiny packets so the IDS must reassemble them to notice — many don't.
🎭
Decoys & spoofing
Mix real probes with fake source IPs so the true scanner hides in a crowd.
🐢
Slow / timing
Scan over hours from many IPs so bursts never trip a threshold.
🔀
Out-of-order packets
Send fragments jumbled & delayed to defeat stream reassembly.
🌐
Source-port tricks
Scan from trusted ports (53, 80) that lax firewalls wave through.
🧟
Proxies / zombies
Route through compromised machines so logs blame someone else.
🛡️
The Defender's Answer

A modern IDS/IPS reassembles fragments, correlates slow/distributed probes, and normalizes traffic — turning most evasion tricks back into detectable patterns.

Hiding the Source

Proxies, Proxy Chaining & Anonymizers

Attacker Proxy 1 Proxy 2 Proxy 3 Target target sees only Proxy 3
🔗
Proxy chaining

Bouncing through multiple proxies so each hop only knows the previous one — the target logs the last proxy, not the attacker.

🧅
Anonymizers & Tor

Tor, VPNs, and tools like Tails strip identity to make activity untraceable — a double-edged tool used by both attackers and privacy-conscious defenders.

Toolkit

The Scanning Toolkit (Awareness)

🗺️
Nmap / Zenmap
The standard — host discovery, port & service scans, OS detection, and scripting (NSE) for vuln checks.
🧪
Hping3
Hand-crafts TCP/UDP/ICMP packets — set any flags, test firewall rules, do custom SYN scans (-8, -S, -A).
⚡
Masscan
Internet-scale — can scan the entire IPv4 space in minutes for a single port.
🖥️
NetScan Tools Pro
Windows suite: ping, port scan, DNS, whois, and promiscuous-mode detection.
📱
Mobile scanners
Fing, Network Scanner, PortDroid — port scans & device discovery from a phone.
🕸️
Topology mappers
SolarWinds NTM, OpManager — draw the discovered network into a diagram.
🧑‍🏫
Same Tools, Both Sides

Blue teams run these against their own networks — an authorized scan is the fastest way to find the open port or unpatched service before an attacker does.

Blue Team

Detecting & Defending Against Scans

📊
Detect the pattern
Many ports from one source, or one port across many hosts, in a short window → an IDS/SIEM flags the sweep.
🧱
Shrink the surface
Close unused ports, segment the network, and put services behind a firewall default-deny.
🚦
Rate-limit & drop
Throttle ICMP and SYN floods; silently drop instead of RST so scanners get no clean signal.
🍯
Honeypots
Fake "open" ports no one should touch — one connection = a live attacker probing you.
🏷️
Hide the details
Strip service banners & version headers so a scan learns less even when it succeeds.
🔧
Patch fast
Scanners find the vulnerable version instantly — patching is what makes the finding useless.
👀
Detected Scanning Is an Early Warning

You can't stop the internet from probing you — but a spotted scan tells you who's interested and where they're looking, buying time to harden before exploitation.

Cheat Sheet

Golden Rules of Scanning

🏆 KEY TAKEAWAYS
1
Scanning turns addresses into a live map — hosts, ports, services, OS, and vulnerabilities.
2
Every scan is a TCP-flag trick: open → SYN/ACK, closed → RST, filtered → silence.
3
Full-open is reliable but logged; half-open & inverse-flag scans trade certainty for stealth.
4
Version & OS detection is the real payload — it's what maps a target to a known exploit.
5
Evasion (fragments, decoys, proxies, zombies) hides the source — modern IDS/IPS reverses most of it.
6
Defend by shrinking the surface, hiding banners, detecting the pattern, and patching fast.
FINAL

Know Every Door Before They Do

Phase 2of the attack
6TCP flags
open/closed/filteredPort states
-sV / -OThe real prize
🎯
The Whole Idea

Scanning is the attacker walking your perimeter, testing every port to learn what's alive, open, and exploitable — using TCP-flag games and stealth to stay quiet. The defender wins by scanning first, closing what shouldn't be open, hiding what must stay, and watching for the knock. Find your own open doors before someone else does.

🧠
One Sentence to Remember

Open replies SYN/ACK, closed replies RST, filtered says nothing — master that, and you can read any scan. Next in the kill chain: Enumeration, where open ports become usernames, shares, and footholds.

📡 End of tutorial · Press ← to review, or click Restart

You have completed Slides. View all sections →