LEARN CYBER SECURITY

Python for Cyber Security | Port Scanner

 

PORT SCANNER USING PYTHON

This blog post particularly focuses on how to make a port scanner using python. Python is a great and an obvious-to-learn programming language for all hackers and cyber security experts. 
This series will help you get started with Python for developing advance tools in field of Networking, cyber security and Penetration Testing.
Here's the code.
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

host = input("Enter the host: ")

port = int(input("Enter the port: "))

   

def myscan(port):

    if sock.connect_ex((host, port)):

           print("The port is closed.")

    else:

           print("The port is open.")

myscan(port)

  Save it somewhere on your PC. Open terminal and run the python file and give it a go.

root@bandit:~/demo# python scanner.py
Enter the host: 192.168.1.1
Enter the port: 443

The port is open.

In this way, you can make a very basic port scanner(No need of nmap 😉😉 )


Here's the link to youtube tutorial. Click



Post a Comment

0 Comments