summaryrefslogtreecommitdiff
path: root/scan.py
diff options
context:
space:
mode:
authorjerome <jerome@xlinfo.fr>2023-12-18 00:02:09 +0100
committerjerome <jerome@xlinfo.fr>2023-12-18 00:02:09 +0100
commita1203ccb343703ba5ae522254f75b6384a1831a7 (patch)
treec54e1e6cf0da29170419b2fd9880ff6dcea28742 /scan.py
downloadpython-a1203ccb343703ba5ae522254f75b6384a1831a7.tar.gz
python-a1203ccb343703ba5ae522254f75b6384a1831a7.zip
depĂ´t initial
Diffstat (limited to 'scan.py')
-rw-r--r--scan.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/scan.py b/scan.py
new file mode 100644
index 0000000..8b878ef
--- /dev/null
+++ b/scan.py
@@ -0,0 +1,17 @@
+import socket
+
+host="127.0.0.1"
+for port in range(0,65535):
+ try:
+ s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
+ s.settimeout(0.5)
+ s.connect((host,port)) # un tuple en argument : (( ))
+ try:
+ banner = s.recv(1024)
+ print("Le port ",port," est ouvert", banner.decode("utf-8").strip())
+ except:
+ print("Le port ",port," est ouvert")
+ except:
+ pass
+
+s.close()