Skip to content

Instantly share code, notes, and snippets.

@mah3uz
Last active March 12, 2016 19:29
Show Gist options
  • Save mah3uz/2562fb2d40bc3db80172 to your computer and use it in GitHub Desktop.
Save mah3uz/2562fb2d40bc3db80172 to your computer and use it in GitHub Desktop.
Check Open Port
#!/usr/bin/python
import socket
ip = raw_input("Enter the IP: ")
port = input("Enter the Port: ")
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if s.connect_ex((ip, port)):
print "Port", port, "is closed"
else:
print "Port", port, "is open"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment