Member-only story

Building a Port Scanner in 16 Lines of Code

Chris Doucette
3 min readDec 3, 2018

Introduction

Another great tool to learn how to make is a port scanner. These tools can be very useful to be able to identify opened ports on your hosts or firewalls that are not meant to be open. Building a port scanner can be very simple but allows for other features to be added. Today we will be building a simple port scanner in 20 lines of code. Lets get started!

Building the Tool

First we will need to import a few standard libraries to help us out

The socket library is a low level networking interface library that allows us to create network connections within our script. The argparse library is used to interpret arguments passed to our script. The sys library allows us to interact with our system. Finally, the datetime library allows us to get the time within our script.

Now lets start building the actual tool!

--

--

Chris Doucette
Chris Doucette

Written by Chris Doucette

Cybersecurity Analyst and Finance Enthusiast

Responses (7)