Skip to content

Instantly share code, notes, and snippets.

Last active May 23, 2020 11:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save pranavek/25f57ce24a2b2087772071f50b158b07 to your computer and use it in GitHub Desktop.
import sys
import socket
from datetime import datetime
if(len(sys.argv) < 2):
print("Usage: python3 %s <host>"%sys.argv[0])
ip = socket.gethostbyname(sys.argv[1])
print("Started the port scanning at ",
for port in range(20,81):
sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
open = sock.connect_ex((ip,port))
print("Cheking for port %d"%port)
if open == 0:
print("The port %d is open"%port)
print("Port scanning end at ",
except KeyboardInterrupt:
print("I'm interrupted, mayday, mayday..")
except socket.gaierror:
print("Cannot resolve hostname!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment