Last active
September 24, 2021 13:14
-
-
Save AlexLynd/5e089e9328f93a3a4741bb4b368f9b13 to your computer and use it in GitHub Desktop.
Python port scanner [GCI 2019-20]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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