Skip to content

Instantly share code, notes, and snippets.

@basvandorst
Created February 14, 2018 15:08
Show Gist options
  • Save basvandorst/4ba7d0f692b30e1eafea6fe5710d15f5 to your computer and use it in GitHub Desktop.
Save basvandorst/4ba7d0f692b30e1eafea6fe5710d15f5 to your computer and use it in GitHub Desktop.
Simple multithreaded portscanner
from threading import Thread
import socket
def scan(ip, port):
try:
con = socket.socket()
result = con.connect_ex((ip,port))
if result == 0:
print '[+] Port %d open' %port
else:
print '[-] Port %d closed' %port
except:
print '[-] Port %d error' %port
host = 'www.ping.nl'
ports = [21,22,25,53,80,8080]
for port in ports:
t = Thread(target=scan, args=(host, port))
t.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment