My code is always giving "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")