Active Reconnaissance
Making direct contact with the target: web browsing, ping, traceroute, telnet and netcat, then Nmap in depth — host discovery, port states, scan techniques, timing, output formats and the Nmap Scripting Engine (NSE). Covers deck 3.
Active reconnaissance starts with a direct connection to the target. Unlike passive recon, it makes contact — a phone call, a visit, browsing the website, or connecting to a port. Such connections may leave traces in logs (your IP, time, duration). But not all connections are suspicious: web browsing, for example, looks like normal client activity among thousands of legitimate users, so active recon can be disguised as regular traffic.
Simple active-recon toolsSearch on YouTube
Web browsingSearch on YouTube
During active recon you can use the browser's DevTools to inspect cookies, discover API endpoints and review client-side scripts. Session cookies without the HttpOnly flag, or JavaScript files exposing API paths, hint at gaps like XSS. This client-side exploration builds attack strategies before you run automated scans. Add-ons help: Wappalyzer shows the technologies used on a visited site. A common practice target is http://testphp.vulnweb.com/login.php.
PingSearch on YouTube
ping <TARGET_IP>ping checks whether you can reach the target and it can reach you back, using ICMP Echo. No reply usually means the target is off, booting, crashed, unplugged, behind a firewall that blocks ICMP, or you have no connectivity.
TracerouteSearch on YouTube
traceroute <TARGET_IP>traceroute reveals the routers (hops) on the path to the target. It sends packets with an increasing Time To Live (TTL) header; each router decrements the TTL by one, and the router where TTL hits 0 drops the packet and reveals its IP. On Linux, traceroute sends UDP datagrams: TTL 1 is dropped at the first router (revealing it), TTL 2 at the second, and so on until the target is reached.
Telnet and netcatSearch on YouTube
telnet <TARGET_IP> <PORT> # connect to any TCP service, read/send raw data
nc <TARGET_IP> <PORT> # netcat: collect a service bannerTelnet (TELetype NETwork, 1969) was built for remote administration but sends everything, including credentials, in clear text. It is still used to connect to any TCP service and grab information: connect to an HTTP port and send a HEAD request to get just the response headers, which reveal the server's details.
Netcat (nc) supports TCP and UDP and works as both a listener and a connector. Connect to a service to collect its banner.
NmapSearch on YouTube
Nmap is the network-mapping tool used across phases.
| Pen-test phase | Nmap use | Goal |
|---|---|---|
| Active recon | Basic ping scan, OS info, banner grabbing | Discover what is up and open |
| Scanning | Port scans, vulnerability scans | Discover how to attack |
nmap -V # print the Nmap versionHost discoverySearch on YouTube
Host discovery finds which hosts are alive. -sn disables the port scan (ping scan only).
nmap -sn <TARGET_IP> # ping scan, no port scan
nmap -PE -sn <TARGET_IP> # ICMP echo
nmap -PP -sn <TARGET_IP> # ICMP timestamp
nmap -PM -sn <TARGET_IP> # ICMP address mask
nmap -PR -sn <TARGET_IP> # ARP scan only
nmap -PS -sn <TARGET_IP> # TCP SYN discovery
nmap -PU -sn <TARGET_IP> # UDP discovery
nmap -PR -sn 10.10.10.10/24 # ARP scan a whole subnet
nmap -sn -n 8.8.8.8 # -n = no DNS resolutionARP scanning: before communicating with a computer you need its MAC address. The OS sends an ARP query; any computer that replies is up and on the same subnet. -PR -sn does an ARP scan only — reliable on the local Ethernet/WiFi, and it cannot be blocked like ICMP.
Do not confuse -PS and -sS. -PS is a TCP SYN probe used for host discovery (is the host alive?). -sS is the TCP SYN port scan (which ports are open?).
Target specificationSearch on YouTube
nmap -sL 192.168.56.0/24 # list scan: just list targets, send no packets
nmap 192.168.56.1-10 # a range
nmap -iL targets.txt # input targets from a file
nmap 192.168.56.0/30 # a subnet (/30 = 4 addresses)
# exclude hosts with --excludePort statesSearch on YouTube
| State | Meaning |
|---|---|
| Open | A service is actively listening and can accept connections. |
| Closed | The host is reachable but nothing is listening on the port. |
| Filtered | A firewall/filter blocks Nmap, so it cannot tell whether the port is open or closed. |
| Unfiltered | Nmap can reach the port but cannot tell whether a service is listening. |
| Open|Filtered | Nmap cannot tell whether the port is open or filtered. |
| Closed|Filtered | Nmap cannot tell whether the port is closed or filtered. |
Common optionsSearch on YouTube
nmap -v <TARGET_IP> # verbose
nmap -vv <TARGET_IP> # very verbose
nmap -r <TARGET_IP> # scan ports in consecutive order
nmap -O <TARGET_IP> # OS detection
sudo nmap -sV 192.168.56.107 # service / version detection
nmap --reason <TARGET_IP> # why a port is in a given state
nmap --open <TARGET_IP> # show only open ports
nmap -Pn <TARGET_IP> # treat all hosts as online, skip host discovery-n means no DNS resolution. -Pn skips the host-discovery phase and is used when the host is already known to be up or blocks ping.
Port selectionSearch on YouTube
nmap -F <TARGET_IP> # fast scan: top 100 ports
nmap -p 80 <TARGET_IP> # a single port
nmap -p 22,80,443 <TARGET_IP> # a set of ports
nmap -p- <TARGET_IP> # all 65535 portsBy default (no -p) Nmap scans the top 1000 commonly used ports from the nmap-services database. -F reduces that to 100.
Scan techniquesSearch on YouTube
nmap -sT <TARGET_IP> # TCP connect scan
nmap -sS <TARGET_IP> # TCP SYN (stealth / half-open)
nmap -sU <TARGET_IP> # UDP scan
nmap -sN <TARGET_IP> # Null scan (no flags set)
nmap -sF <TARGET_IP> # FIN scan
nmap -sX <TARGET_IP> # Xmas scan (FIN + PSH + URG)
nmap -sM <TARGET_IP> # Maimon scan (FIN + ACK)
nmap -sA <TARGET_IP> # ACK scan
nmap -sW <TARGET_IP> # Window scan
sudo nmap -sU -p- 192.168.56.107 # all UDP ports (very slow)There are many scan types because targets behave differently, firewalls/IDS block some scans but not others, privilege level (root vs non-root) limits the packets you can send, and stealth-vs-speed trade-offs matter.
-sT(TCP Connect) completes the full 3-way handshake (SYN → SYN-ACK → ACK). Reliable but logged.-sS(TCP SYN, stealth) is the half-open scan: SYN → reads SYN-ACK as open → sends RST instead of the final ACK. Stealthier than-sTbecause the handshake never completes.- Null (
-sN), FIN (-sF), Xmas (-sX) behave identically except for the TCP flags: Null sets none, FIN sets FIN, Xmas sets FIN+PSH+URG. A RST reply means closed; no response means open|filtered; an ICMP unreachable error means filtered. - Maimon (
-sM) sends FIN+ACK.
| Scan | Option | Open if | Closed if | Filtered if |
|---|---|---|---|---|
| TCP Connect | -sT | handshake completes | RST received | no response / ICMP error |
| TCP SYN | -sS | SYN-ACK received | RST received | no response / ICMP unreachable |
| Null | -sN | no response (open|filtered) | RST received | ICMP unreachable |
| FIN | -sF | no response (open|filtered) | RST received | ICMP unreachable |
| Xmas | -sX | no response (open|filtered) | RST received | ICMP unreachable |
| ACK | -sA | (cannot detect open) | (cannot detect closed) | no response / ICMP unreachable |
| Window | -sW | RST with non-zero window | RST with zero window | ICMP unreachable / no response |
| Maimon | -sM | no response (open|filtered) | RST received | ICMP unreachable |
| UDP | -sU | valid UDP response | ICMP port unreachable (type 3, code 3) | no response / other ICMP unreachable |
Which scan does not complete the handshake? The SYN scan (-sS) — it sends SYN, reads SYN-ACK as open, then sends RST instead of the final ACK. This is the go-to answer when a question asks for a stealthy TCP port discovery that avoids simple logging.
TimingSearch on YouTube
sudo nmap -T4 -sS 192.168.56.107| Option | Name | Note |
|---|---|---|
-T0 | Paranoid | Very slow; designed to avoid IDS/IPS. |
-T1 | Sneaky | Slow and stealthy. |
-T2 | Polite | Slows down to reduce network load. |
-T3 | Normal | Default, balanced. |
-T4 | Aggressive | Fast; good for LANs, may trigger IDS. |
-T5 | Insane | Very fast; may overwhelm the network or miss data. |
Use -T0/-T1 for fragile legacy systems (minimal load, low disruption risk) and -T4 on stable networks.
Aggressive scanSearch on YouTube
nmap -A <TARGET_IP>-A combines OS detection (-O), version detection (-sV), default NSE scripts (-sC) and --traceroute in one scan.
Output formatsSearch on YouTube
nmap [options] target | tee output.txt # show on screen and save
nmap -oN scan.txt <target> # normal (human-readable)
nmap -oG scan.gnmap <target> # grepable (easy to parse with grep/awk/cut)
nmap -oX scan.xml <target> # XML (import into Metasploit, Zenmap, reports)
nmap -oA myscan <target> # all three formats at onceNmap Scripting Engine (NSE)Search on YouTube
The NSE automates networking tasks with scripts. Every Nmap install ships with scripts in /usr/share/nmap/scripts (file extension .nse, written in Lua), executed in parallel.
sudo nmap --script-updatedb # rebuild the script database (script.db)
ls -al /usr/share/nmap/scripts | grep "http" # find scripts by keyword
ls -al /usr/share/nmap/scripts/ | grep "ftp"
vim /usr/share/nmap/scripts/http-enum.nse # inspect a script
nmap --script <name> <TARGET_IP> # run one script (no .nse needed)
nmap -p 21 --script ftp-anon 192.168.56.107 # is FTP anonymous login allowed?
nmap -p 21 --script "ftp-*" 192.168.10.149 # all ftp scripts (noisy/slow)
nmap --script name1,name2 <TARGET_IP> # several scripts, comma-separatedBanner grabbingSearch on YouTube
sudo nmap -p22,80 --script banner <TARGET_IP>Banner grabbing collects the initial message a service returns on connection. The banner gives the exact service name and version (e.g. OpenSSH on port 22), which is very useful for matching vulnerabilities.
Vulnerability scanningSearch on YouTube
nmap --script vulners <TARGET_IP> # check services vs the Vulners.com DB
nmap --script ssl-heartbleed <TARGET_IP> # Heartbleed (CVE-2014-0160)The vulners script checks the detected service (e.g. vsftpd 2.3.4) against the Vulners.com database. Each result gives a reference ID (CVE, Exploit-DB, etc.), a CVSS score (10.0 = critical), a link, and may be marked *EXPLOIT* when a working exploit is public. Other tools: searchsploit and Nikto.
NSE script categoriesSearch on YouTube
| Category | Purpose | Example scripts |
|---|---|---|
| auth | Authentication | ssh-auth-methods |
| broadcast | LAN host/service discovery | broadcast-ping, broadcast-dhcp-discover |
| brute | Brute-force logins (risky) | ftp-brute, http-brute |
default (-sC) | Safe, useful quick info | http-title, ssh-hostkey |
| discovery | More network/service info | dns-brute, snmp-info |
| dos | Denial of Service (risky) | http-slowloris |
| exploit | Actively exploit vulns | http-shellshock, smb-vuln-ms17-010 |
| external | Rely on external APIs | whois-ip, ip-geolocation-maxmind |
| fuzzer | Send malformed data | dns-fuzz |
| malware | Detect backdoors/infections | irc-unrealircd-backdoor, ftp-proftpd-backdoor |
| safe | Non-intrusive | http-robots.txt, ssl-cert |
| version | Extend -sV detection | ftp-syst, http-server-header |
| vuln | Check (not exploit) vulns | http-vuln-cve2017-5638, smb-vuln-ms08-067 |
| intrusive | Disruptive/noisy | smtp-enum-users |
The NMAP lab (Day 3) had you run host discovery on a /24, scan single targets and subnets, compare -sS vs -sT, read port states with --reason, detect OS and versions, and save output. The Service Enumeration lab (Day 4) added NSE scripts: ftp-anon, banner, vulners and HTTP scripts (http-apache-server-status, http-methods, http-errors, http-grep) against Metasploitable2.
Quick self-testSearch on YouTube
How does traceroute discover the routers on a path?
It sends packets with an increasing TTL. Each router decrements the TTL; the router where TTL reaches 0 drops the packet and returns an error that reveals its IP. TTL 1 reveals the first hop, TTL 2 the second, and so on.
Difference between -PS and -sS?
-PS is a TCP SYN probe for host discovery (is the host alive?). -sS is the TCP SYN port scan (which ports are open?).
Which scan is stealthy and why?
The SYN scan -sS (half-open). It sends SYN, reads SYN-ACK as open, then sends RST instead of completing the handshake, so the full connection is never logged.
What does -A combine?
OS detection (-O), version detection (-sV), default NSE scripts (-sC) and --traceroute, in a single scan.
How many ports does a default scan check, and how do -F and -p- change this?
Default: the top 1000 ports from nmap-services. -F reduces it to the top 100. -p- scans all 65535 ports.
In Null, FIN and Xmas scans, what reply means closed and what means open?
A RST reply means closed; no response means open|filtered. An ICMP unreachable error means filtered. The three differ only in which TCP flags are set.
What is the difference between the open and filtered port states?
Open: a service is actively listening. Filtered: a firewall or filter blocks Nmap, so it cannot determine whether the port is open or closed.
Which Nmap timing template suits a fragile legacy system, and why?
-T0 (Paranoid) or -T1 (Sneaky). They send packets slowly, generating minimal network load and reducing the risk of destabilising the system.
Where do NSE scripts live, what language are they written in, and how do you run one?
In /usr/share/nmap/scripts (.nse files), written in Lua. Run one with nmap --script <name> <target> (no .nse extension needed).
What is banner grabbing and why is the banner valuable?
Connecting to a service to read the initial message it returns. The banner reveals the exact service name and version, which the attacker matches against known vulnerabilities.
- Active recon makes direct contact with the target and can leave traces, but can be disguised as normal traffic.
- Simple tools:
ping(ICMP echo reachability),traceroute(TTL-based hop discovery),telnet/nc(connect to and banner-grab TCP services), and browser DevTools. - Nmap host discovery uses
-snwith probes-PE/-PP/-PM/-PR/-PS/-PU;-PR(ARP) is best on the local subnet. - Port states: open, closed, filtered, unfiltered and the two ambiguous combinations.
- Scan types:
-sT(connect),-sS(stealth SYN),-sU(UDP),-sN/-sF/-sX(flag scans),-sA/-sW/-sM; timing-T0..-T5;-Abundles-O -sV -sC --traceroute. - Output:
-oN/-oG/-oX/-oA. The NSE (/usr/share/nmap/scripts, Lua) automates banner grabbing, enumeration and vulnerability checks (vulners,ssl-heartbleed) across 14 categories.