Created
December 8, 2019 09:07
-
-
Save TrungNguyen1909/70253c3105af671ace9a827881e56b9c to your computer and use it in GitHub Desktop.
Python open port scanner
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
#!/usr/bin/env python3 | |
import socket | |
import sys | |
import threading | |
HOST = sys.argv[1] | |
SERVER = socket.gethostbyname(HOST) | |
print(F"[*] Port Scanning on {SERVER}") | |
def scan(start,end): | |
for PORT in range(start,end): | |
with socket.socket(socket.AF_INET) as s: | |
ret = s.connect_ex((SERVER,PORT)) | |
if ret == 0: | |
print(F"[+] TCP port {PORT} is opened!") | |
scan(0,65536) | |
print(F"[+] Scanning completed on host {SERVER}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment