SECURITY ENGINEERING · PART 5 · ETHICAL HACKING, STEP BY STEP · SCANNING · 62 OF 229

Network Scanning and Enumeration, Step by Step

Scanning finds which services a host exposes; enumeration extracts the detail from each one. This episode gives the step-by-step method testers use: host discovery, a full port scan, version detection, then service-by-service enumeration of web, SMB, SSH, DNS, SNMP, mail and databases, with example lab output, how to keep notes, what every step looks like in defender logs, and how to shrink what a scan can find.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 9
  9. 10
  10. 11
  11. 12
  12. 13
  13. 14
  14. 15
  15. 16
  16. 17
  17. 18
  18. 19
  19. 20
  20. 21
  21. 22
  22. 23
  23. 24
  24. 25
  25. 26
  26. 27
  27. 28
  28. 29
  29. 30
  30. 31
  31. 32
  32. 33
  33. 34
  34. 35
  35. 36
  36. 37
  37. 38
  38. 39
  39. 40
  40. 41
  41. 42
  42. 43
  43. 44
  44. 45
  45. 46
  46. 47
  47. 48
  48. 49
  49. 50
  50. 51
  51. 52
  52. 53
  53. 54
  54. 55
  55. 56
  56. 57
  57. 58
  58. 59
  59. 60
  60. 61
  61. 62
  62. 63
  63. 64
  64. 106
  65. 107
  66. 108
  67. 109
  68. 110
  69. 111
  70. 112
  71. 113
  72. 114
  73. 115
  74. 116
  75. 117
  76. 118
  77. 119
  78. 120
  79. 121
  80. 122
  81. 123
  82. 124
  83. 125
  84. 126
  85. 127
  86. 128
  87. 129
  88. 130
  89. 131
  90. 132
  91. 133
  92. 134
  93. 135
  94. 136
  95. 137
  96. 138
  97. 139
  98. 140
  99. 141
  100. 142
  101. 143
  102. 144
1 / 14

Press play to hear the narration, or step through at your own pace.

Key takeaways

  • Live hosts
  • all ports
  • versions
  • enumerate each service
  • take notes
  • defenders should see every step

Notes

The method

The method has four steps, from broad to deep. One: host discovery, to see which addresses are alive. Two: a port scan of all sixty five thousand TCP ports, plus the most common UDP ports. Three: service and version detection on the open ports. Four: enumerate each service with tools made for it. Write everything down. And repeat the whole process whenever you gain new access, because an internal position reveals services the outside never saw.

Four steps
  • 1. host discovery: which addresses are alive
  • 2. port scan: all 65,535 TCP ports, plus top UDP
  • 3. service and version detection on open ports
  • 4. enumerate each service with its own tools
  • write everything down repeat when you gain access

Step 1: live hosts

Step one is host discovery. The dash s n option tells Nmap to find live hosts without scanning ports. On a local network it uses ARP, which is fast and reliable. Across the internet, many hosts block ping, so a host that looks down may be up; the dash capital P n option skips discovery and scans anyway. This step turns a range of two hundred and fifty four addresses into a short list worth scanning.

host discovery
nmap -sn 10.10.10.0/24
# Nmap scan report for 10.10.10.5
# Host is up (0.0004s latency).
# Nmap scan report for 10.10.10.20
# Host is up (0.0006s latency).

# -sn: discovery only, no port scan
# local network: ARP, very reliable
# internet: hosts may block ping;
# use -Pn to scan anyway

Step 2: every port

Step two: scan every port. By default Nmap checks the thousand most common, and administrators often move services to unusual ports. Dash p dash scans all of them. Then run a second, slower scan with version detection and default scripts on only the open ports, which is much quicker than doing everything at once. Always save the output with dash o capital A. On this lab host we found four ports, including one on eighty eighty one that a default scan would miss.

full port scan, then detail
nmap -p- --min-rate 1000 -oA full \
  10.10.10.20
# 22/tcp   open
# 80/tcp   open
# 445/tcp  open
# 8081/tcp open

nmap -sV -sC -p 22,80,445,8081 \
  -oA detail 10.10.10.20

Step 3: versions

Step three turns ports into leads. Version detection reports the product and exact version, and the default scripts add detail: page titles, the operating system, supported options. On this lab host we see an old OpenSSH, an old Apache, a Samba file server from twenty sixteen, and an administration console on the unusual port. Exact versions can be matched against known vulnerabilities, and an administration console is always worth a closer look.

example lab output
22/tcp   open  ssh    OpenSSH 7.2p2
80/tcp   open  http   Apache 2.4.18
|_http-title: Welcome to the shop
445/tcp  open  smb    Samba 4.3.11
| smb-os-discovery: Ubuntu 16.04
8081/tcp open  http   Jetty 9.2
|_http-title: Admin console

# old versions and an admin console:
# both go to the top of the list

Step 4: web services

Step four is service by service, starting with web, the largest surface. Identify the server, framework and content system. Read the robots file, the sitemap, the page source and the JavaScript, which often list endpoints. Search for hidden paths with a content discovery tool such as ffuf or gobuster, which tries a wordlist of names. Check for other virtual hosts on the same address, API documentation left exposed, login pages with default credentials, and the TLS configuration.

Enumerating HTTP
  • identify: server, framework, CMS (whatweb, wappalyzer)
  • read: robots.txt, sitemap, page source, JS files
  • find hidden paths: ffuf, gobuster, feroxbuster
  • virtual hosts on the same IP
  • API docs: /swagger, /openapi
  • login pages and default credentials
  • TLS configuration

File sharing and remote

File sharing and remote access services come next. For SMB, the Windows file sharing protocol: which shares exist, can they be listed without a password, which user names does it reveal, and is signing required. For SSH: the version and whether passwords are accepted. For remote desktop: is network level authentication required. FTP: is anonymous login allowed. NFS: which folders are exported, and to whom. The first question for every service is the same: does it need a login at all?

Enumerating common services
  • SMB 445: shares, users, signing, anonymous access (smbclient, enum4linux-ng, netexec)
  • SSH 22: version, auth methods
  • RDP 3389: NLA required?
  • FTP 21: anonymous login?
  • NFS 2049: exported folders
  • LDAP 389: anonymous bind?
  • for each: is a login needed at all?

Infrastructure services

Then the infrastructure services, which are quiet but generous. DNS may allow a zone transfer or reveal internal names. SNMP, the device management protocol, with the default community string public, can expose a device's entire configuration, and it runs on UDP, which many people forget to scan. Mail servers may confirm which user names exist. And databases and caches such as MongoDB or Redis are, far too often, reachable from the network with no password at all.

DNS, SNMP, mail, databases
  • DNS 53: zone transfer, version, internal names
  • SNMP 161/udp: community "public" exposes the whole device configuration
  • SMTP 25: user checks, open relay
  • databases: MySQL, Postgres, MongoDB, Redis reachable without a password?
  • do not forget UDP

Notes

Note-taking is a professional skill, not an afterthought. Keep one folder per host, with the raw output of every tool. Maintain a table: host, port, service, version, notes and next step. Record the time and your source address for every action, so the client can match it to their logs. Keep a running list of every user name, share and path found, because they become inputs for later phases. The report is written from these notes.

Keep a record
  • one folder per host; raw tool output saved (-oA)
  • a table: host, port, service, version, notes, next step
  • timestamps and source IP for every action
  • user names, shares, paths found: one running list
  • screenshots as evidence
  • the report is written from these notes

The defender view

For defenders, scanning is the loudest phase of an attack. The firewall shows one source touching many ports or many hosts. An intrusion detection system such as Suricata or Zeek flags port scans and Nmap's script probes. Web logs show bursts of not found errors and paths from well-known wordlists. File servers log anonymous session attempts. Internet scanning is constant background noise. A scan that starts from inside your network is different: it usually means someone has a foothold.

What it looks like in logs
  • firewall: one source, many ports or many hosts, denied
  • IDS (Suricata, Zeek): "port scan", Nmap script probes
  • web: bursts of 404s, a tool User-Agent, wordlist paths
  • SMB and LDAP: anonymous session attempts
  • auth logs: logins from an unusual internal host
  • internal scans matter most

Shrink what scans find

The defense is to give a scan less to find. Close or firewall everything that is not needed. Put administration interfaces behind a VPN or keep them internal. Remove anonymous access from file shares, directories, device management and databases. Change default settings. Segment the network, so a foothold on one machine sees few others. Scan yourself every week and compare with last week. And alert on scanning that starts inside the network.

Hardening
  • close or firewall everything that is not needed
  • admin interfaces: VPN or internal only no anonymous access: SMB, FTP, LDAP, SNMP, databases
  • SNMPv3; change defaults
  • segment the network: a foothold should see little
  • scan yourself first, weekly
  • alert on internal scanning

Common mistakes

Mistakes. Scanning only the top thousand ports. Forgetting UDP. Trusting a single scan and never rescanning after gaining access. Running aggressive scans against fragile systems such as printers, medical devices or industrial equipment, which can crash. Keeping no notes and no saved output. On the defender side: dismissing internal scanning alerts as noise, and leaving exact version banners on every service.

Avoid these
  • scanning only the top 1,000 ports
  • forgetting UDP
  • trusting one scan; no rescan after access
  • aggressive scans on fragile systems (printers, OT)
  • no notes, no saved output
  • defenders: ignoring internal scan alerts as "noise"
  • banners that reveal versions

Say it like this

In the interview: I run a full TCP port scan and the top UDP ports, then version detection and default scripts on what is open. Then I enumerate per service: for web, technologies, hidden content and virtual hosts; for SMB, shares, users and signing; SSH authentication methods; DNS, SNMP and databases, always checking whether anonymous access works. I save all output with timestamps, and after any new access I repeat the process from that position.

In the interview
  • "Full TCP port scan plus top
  • UDP, then version detection
  • and default scripts on open
  • ports. Then per service: web
  • content and vhosts, SMB
  • shares and users, SSH auth, DNS, SNMP, databases, always
  • checking anonymous access. I
  • log everything with times."

Interview questions

Q1What is the difference between scanning and enumeration?

Scanning identifies live hosts and open ports. Enumeration actively queries the discovered services to extract detailed information such as software versions, user names, shares, directories and configuration, which is used to identify weaknesses.

Q2Why scan all 65,535 ports?

Default scans cover only the most common ports. Services are frequently run on non-standard ports, and administrative or forgotten services on high ports are often the weakest. A full TCP scan ensures nothing listening is missed.

Q3What do the Nmap options -sV and -sC do?

-sV performs service and version detection by probing open ports and matching responses. -sC runs the default set of Nmap Scripting Engine scripts, which gather extra information such as page titles, supported methods and protocol details.

Q4What is SMB enumeration?

Querying the Windows file sharing service to list shares, users, groups, password policy and OS details, and to test for anonymous or guest access and whether SMB signing is enforced. Tools include smbclient, enum4linux-ng and NetExec.

Q5Why is SNMP a security risk?

SNMP versions 1 and 2c authenticate with a plaintext community string, often left at the default "public". Anyone who can reach the service may read device configuration, interfaces, routing and sometimes credentials. SNMPv3 with authentication and encryption should be used.

Q6What is directory brute forcing?

Requesting many candidate paths from a wordlist against a web server to discover files, directories and endpoints that are not linked, such as admin panels, backups and API routes. Tools include ffuf, gobuster and feroxbuster.

Q7How can defenders detect network scanning?

Through firewall logs showing one source contacting many ports or hosts, IDS signatures for scan patterns and tool probes, bursts of web 404 responses, and honeypot ports or hosts that no legitimate system should contact.

Q8How do you reduce the attack surface that scanning reveals?

Close unnecessary ports, restrict administrative services to internal networks or VPN, disable anonymous access, remove default configurations, segment networks, and scan your own environment regularly to detect new exposure.