Skip to content

Instantly share code, notes, and snippets.

@matefs
Created September 29, 2023 23:57
Show Gist options
  • Save matefs/381051094d6b36db3269bf713db1bd80 to your computer and use it in GitHub Desktop.
Save matefs/381051094d6b36db3269bf713db1bd80 to your computer and use it in GitHub Desktop.
porta-aberta-fechada-python
#!/usr/bin/python
import socket
ip = "192.168.0.1"
porta = 80 # Se for porta 81 vai constar fechada.
meusocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
res = meusocket.connect_ex((ip, porta))
if (res == 0 ):
print("Porta Aberta")
else:
print("Porta Fechada")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment