By Amr Hamdy
Python script that allows you to enter the target IP address and specifies the port range to scan:
import socket
target = input("Enter target IP address: ") # Get IP address from user input
ports = range(1, int(input("Enter port range to scan: "))) # Get port range from user input
def scan_ports(ip):
for port in ports:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
s.connect((ip, port))
print(f"Port {port} is open")
except:
pass
s.close()
scan_ports(target)