summaryrefslogtreecommitdiff
path: root/scan.py
diff options
context:
space:
mode:
authorjerome <jerome@xlinfo.fr>2025-06-14 16:06:30 +0200
committerjerome <jerome@xlinfo.fr>2025-06-14 16:06:30 +0200
commit400248ddaa963b1191c3fc31b9e2e202d92dcdd1 (patch)
tree6a8a975b3d6f280dc05920c10d3a2f6b567f3db9 /scan.py
parentd5094c679076ad9c26ff0541a239681eacabfee3 (diff)
downloadpython-400248ddaa963b1191c3fc31b9e2e202d92dcdd1.tar.gz
python-400248ddaa963b1191c3fc31b9e2e202d92dcdd1.zip
nmapscanner
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()