Skip to content

Instantly share code, notes, and snippets.

@TrungNguyen1909
Created December 8, 2019 09:07
Show Gist options
  • Save TrungNguyen1909/70253c3105af671ace9a827881e56b9c to your computer and use it in GitHub Desktop.
Save TrungNguyen1909/70253c3105af671ace9a827881e56b9c to your computer and use it in GitHub Desktop.
Python open port scanner
#!/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