0% found this document useful (0 votes)
56 views1 page

Hackers Arise Port Scanner

This Python script contains a function called checkports that evaluates whether ports on a target IP address are open or closed. It does this by creating sockets and attempting to connect to each port in a supplied list, printing the result. The function is called at the end to check ports 21, 22, 25, 80, 81, and 443 on IP address 192.168.100.5.

Uploaded by

Muhammad Muntzir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views1 page

Hackers Arise Port Scanner

This Python script contains a function called checkports that evaluates whether ports on a target IP address are open or closed. It does this by creating sockets and attempting to connect to each port in a supplied list, printing the result. The function is called at the end to check ports 21, 22, 25, 80, 81, and 443 on IP address 192.168.100.5.

Uploaded by

Muhammad Muntzir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

# this is a simple port scanner that evaluates whether a port is open by whether we

can create a socket at the port


import socket
import sys

# this is our first function!

def checkports(ip,portlist):
try:
for port in portlist:
sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sock.settimeout(5)
result=sock.connect_ex((ip,port))
if result==0:
print('Port {}: \t Open'.format(port))
else:
print('Port {}: \t Closed'.format(port))
sock.close()

except socket.error as error:


print(str(error))
print('Connection Error')
sys.exit()

# this calls our function checkports and passes parameters to it with IP and ports
checkports("192.168.100.5",[21,22,25,80,81,443])

You might also like