Skip to content

Instantly share code, notes, and snippets.

@jboursiquot
Last active September 23, 2020 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jboursiquot/442062d2f661b4bc2a0d0f0b21df1180 to your computer and use it in GitHub Desktop.
Save jboursiquot/442062d2f661b4bc2a0d0f0b21df1180 to your computer and use it in GitHub Desktop.
BaltimoreGo Challenge: Build a Port Scanner

Your challenge is to write a port scanner in Go that uses a worker pool to efficiently scan multiple ports concurrently. It should meet the following requirements:

  1. Accepts a range of ports to scan as an argument (e.g. ./portscan -ports 8080-9090)
  2. Accepts a number of workers to use for performing the scans (e.g. ./portscan -workers 100)
  3. Outputs <PORT> CLOSED for closed ports as they are discovered.
  4. Outputs <PORT> OPEN for open ports as they are discovered.
  5. Extra credit: How could you informed the user of your port scanner of the likely service running on the open ports? (e.g. 5432 is likely a PostgreSQL server)

Hints:

  1. Use the flags package to capture invocation parameters.
  2. Rely on the net package.
  3. Make use of channels for communication across goroutines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment