diff options
Diffstat (limited to 'scan.py')
| -rw-r--r-- | scan.py | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -4,10 +4,15 @@ import socket def scan(host,*ports): for port in ports: s=socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s.settimeout(2) # Set a 2-second timeout addr_server=(host,int(port)) tentative=s.connect_ex(addr_server) #connect_ex renvoie 0 en cas de succès... if tentative==0: print(f"Le port {port} ouvert") + try: + print(s.recv(1024).decode().strip()) + except: + pass else: print(f"Le port {port} fermé") s.close() |
