Skip to content

Instantly share code, notes, and snippets.

@AlexLynd
Last active September 24, 2021 13:14
Show Gist options
  • Save AlexLynd/5e089e9328f93a3a4741bb4b368f9b13 to your computer and use it in GitHub Desktop.
Save AlexLynd/5e089e9328f93a3a4741bb4b368f9b13 to your computer and use it in GitHub Desktop.
Python port scanner [GCI 2019-20]
import socket
host = raw_input("enter host: ")
IP = socket.gethostbyname(host) # for remote
print("scanning\n----------")
for port in range(1,1025):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
open = sock.connect_ex((IP, port))
if open == 0: print "Port {}: open".format(port)
sock.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment