-
-
Save lasteminista/9ecf647789f42339cd38766957717f21 to your computer and use it in GitHub Desktop.
Port Scanner Code Snippet 1
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 | |
target = '127.0.0.1' | |
port = 80 | |
def scan_port(target, port): | |
print(f'Scan Target > {target}') | |
# Create a socket object | |
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | |
# Test connection | |
test = s.connect_ex((target, port)) | |
if test == 0: | |
print(f'Port {port} is [open]') | |
if __name__ == '__main__': | |
scan_port(target, port) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment