Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python #tells which version of python we are using
- import socket #import sockets
- ip = raw_input("Enter the ip: ") #Asks us to input an ip address eg 127.0.0
- port = input("Enter the port: ") #Asks user to imput a port e.g 80 , 23 , 22 etc
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- if s.connect_ex((ip, port)):
- print "Port", port, "is closed" #tells you port is closed
- else: #if no port is open
- print "Port", port, "is open" #port is open
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement