Securus Journal 43.65°N, 79.38°W

Nmap and the services nobody meant to run

A SYN, version and OS scan of a Windows machine on a home network, what Nmap found listening, and why the first machine worth scanning is your own.

In September 1997 the hacker magazine Phrack printed, in its fifty-first issue, “The Art of Port Scanning” by Fyodor, the handle of Gordon Lyon, with the source code of a scanner he called Nmap. Earlier scanners each knew one trick. Nmap put the tricks in one program, and it is still the first thing most people reach for to learn what a machine offers the network.

A service listening on a port is a door, and machines collect doors without anyone deciding to. The scan below was run against a Windows machine on a private network, from that same machine, to see what it had collected.

Nmap Localhost Scan Zenmap’s output for a SYN, version and OS scan of a Windows machine on a home network.

The scan

nmap -sS -sV -O --open -T4 192.168.X.XX

-sS is the SYN scan, Nmap’s default with administrator rights. It sends the first packet of a TCP handshake and never finishes it: a SYN-ACK means open, a reset means closed, silence usually means a firewall. -sV talks to each open service until it can name it and its version. -O compares how the TCP/IP stack answers a set of odd probes against Nmap’s database of known systems. --open shows only open ports, and -T4 shortens the timing.

The run took 32.63 seconds. Of the thousand ports Nmap checks by default, 994 answered closed. Six were open.

Port Nmap’s name What it is
135/tcp msrpc The Windows RPC endpoint mapper
139/tcp netbios-ssn NetBIOS session service, SMB’s older transport
445/tcp microsoft-ds SMB directly over TCP
2179/tcp vmrdp Hyper-V’s Virtual Machine Connection
3389/tcp ms-wbt-server Remote Desktop
5357/tcp http Web Services for Devices, used by Windows network discovery

Latency was about 0.00036 seconds, at zero hops: the machine was talking to itself. The service probes identified Windows, but OS detection returned only a partial fingerprint with no exact version, which filtering or suppressed replies can cause, and so can a Windows build newer than Nmap’s database.

A plainer scan, nmap -sV [IP], against a server found the expected 22 (SSH), 80 (HTTP) and 443 (HTTPS). The view below is from scanme.nmap.org, a host the Nmap project keeps so that people can practise on something they are allowed to scan.

Nmap Ports/Hosts Results Open ports on scanme.nmap.org, in Zenmap’s Ports / Hosts view.

Reading the open ports

Remote Desktop on 3389 is a common remote access method and a high-value target: a full graphical login whose protocol has had wormable flaws, such as BlueKeep (CVE-2019-0708) in May 2019. If nobody connects remotely, it should be off; if someone does, it belongs behind a VPN.

SMB on 139 and 445 is the pair WannaCry and NotPetya used in 2017 to cross corporate networks, and the usual route for lateral movement. A later post closes 445 with a firewall rule.

Port 5357 is easy to miss. Nmap labelled it “Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP),” which names the HTTP server built into Windows, not the service. IANA registers the port as wsdapi, Web Services for Devices, which Windows network discovery uses, and it can expose device metadata to whoever asks. Port 2179 was open because Hyper-V is enabled.

Why scan your own machine first

Some of those six are needed, some are vestigial defaults, and some should be off entirely. Hardening starts with that list, because nothing can be closed until someone knows it is open.

On a network you are authorised to test, the same approach maps the attack surface before anything else happens. Without that authorisation a scan is a probe of someone else’s systems, which is why scanme.nmap.org exists.

It is the part of reconnaissance nobody skips. On your own machine it costs thirty-three seconds.

Sources

  • Fyodor (Gordon Lyon). “The Art of Port Scanning.” Phrack 51, September 1997.
  • Lyon, Gordon. Nmap Network Scanning. Nmap Project, 2009.
  • Microsoft. Security Bulletin MS17-010, March 2017.
  • NIST National Vulnerability Database. CVE-2019-0708 (BlueKeep).
  • IANA. Service Name and Transport Protocol Port Number Registry.