1
My code is always "port is opened". My idea is: if the destination responds, the door is open. Otherwise, it may be filtered...
#####################################
# Portscan UDP #
# #
#####################################
# -*- coding: utf-8 -*-
#!/usr/bin/python3
import socket
ip = (input("Type IP or Address: "))
ports = []
count = 0
while count < 5:
ports.append(int(input("Type the port: ")))
count += 1
for port in ports:
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
client.bind((ip, port))
msg = 'hi'
client.sendto(msg.encode(), (ip,port))
data, address = client.recvfrom(1024)
#print("Recebida ->", str(data))
if data != None:
print (str(port) + " -> Port is opened")
else:
print (str(port) + " -> Port is closed")
print ("Scan Finished")
But what’s the problem? I ran the code and everything seems fine, an exception is thrown when the port is in use
– Miguel
Always gives that all the doors are open. Apparently does not work!
– Paul Sigonoso
Nop, well try to put there the 80. In my soon generates an exception. More precisely:
PermissionError: [Errno 13] Permission denied
– Miguel
Has to run as root!
– Paul Sigonoso