🥐Simple Port Scanner
Building a Simple Port Scanner in Python 🕵️♂️🔍
Let's delve into the world of cybersecurity by creating a basic but effective port scanner using Python. This script will help you identify open ports on a target machine. Ready? Let's begin!
Explanation:
Imports:
sys
: Provides access to some variables used or maintained by the Python interpreter and to functions that interact with the interpreter.socket
: Provides low-level networking interface.datetime
: Supplies classes for working with dates and times.
Target Definition:
The target is either set as the IPv4 address of the provided hostname or as a command-line argument.
Banner:
A simple banner is displayed, indicating the target and the time the scan started.
Port Scanning:
The script attempts to connect to ports in the range from 50 to 84.
If the connection is successful (result == 0), the script prints that the port is open.
Exception Handling:
Handles potential exceptions like keyboard interrupt, hostname resolution failure, and socket errors.
Feel free to explore and modify this script as you continue your journey into cybersecurity.
Last updated