diff options
| author | jerome <jerome@xlinfo.fr> | 2025-06-14 16:06:30 +0200 |
|---|---|---|
| committer | jerome <jerome@xlinfo.fr> | 2025-06-14 16:06:30 +0200 |
| commit | 400248ddaa963b1191c3fc31b9e2e202d92dcdd1 (patch) | |
| tree | 6a8a975b3d6f280dc05920c10d3a2f6b567f3db9 /scan.py | |
| parent | d5094c679076ad9c26ff0541a239681eacabfee3 (diff) | |
| download | python-400248ddaa963b1191c3fc31b9e2e202d92dcdd1.tar.gz python-400248ddaa963b1191c3fc31b9e2e202d92dcdd1.zip | |
nmapscanner
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() |
