Port Scanning using Python:


We can do port scan using python:

Below python program is written by me while learning python port scan:


import socket

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # Creating a socket


target = 'trhu1.prog.altair.com'

def pscan(port):  # pscan is a module to scan TCP ports
    try:
        con = s.connect((target,port)) # connect is function to connect
        return True
    except:
        return False

for x in range(1,60000):
    if pscan(x):
        print('Port',x, 'rhu1.prog.altair.com is open')

    else:
        print('Port',x,'is closed')


Comments

Post a Comment

Popular Posts