Port scanning

After finding a host on the network, perhaps after doing a ping sweep or monitoring the network traffic, you typically want to scan the ports and see which ports are open and accepting connections. You can learn a lot about a machine just by seeing what ports are open. You might be able to determine whether it is Windows or Linux or whether it is hosting an email server, a web server, a database server, and more.

There are many types of port scans, but this example demonstrates the most basic and straightforward port scan example, which is a TCP connect scan. It connects like any typical client and sees whether the server accepts the request. It does not send or receive any data and immediately disconnects, logging if it was ...

Get Security with Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.