summaryrefslogtreecommitdiff
path: root/scan.py
diff options
context:
space:
mode:
Diffstat (limited to 'scan.py')
-rw-r--r--scan.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/scan.py b/scan.py
index 80dec63..a8539ea 100644
--- a/scan.py
+++ b/scan.py
@@ -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()