This commit is contained in:
whackx 2023-07-30 23:58:48 +02:00
parent 9737bfd50d
commit efec1c5cd9
1 changed files with 12 additions and 10 deletions

View File

@ -1,11 +1,13 @@
#!/usr/bin/python3 #!/usr/bin/env python3
import socket import socket
host = "1.1.1.1"
portList = [21,22,53,80,443,3306,8443,8080] HOST = "1.1.1.1"
for port in portList: port_list = [21, 22, 53, 80, 443, 3306, 8443, 8080]
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) for port in port_list:
try: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host,port)) try:
print("Port ", port, " is open") s.connect((HOST, port))
except: print("Port ", port, " is open")
print("Port ", port, " is closed") except Exception:
print("Port ", port, " is closed")