Thursday, September 29, 2016

Simple TCP Scanner

#!/usr/bin/python
# Written in September, 2016 for fun.
import socket, sys

port_list = [7, 8, 9, 21, 22, 23, 80, 135, 139, 443, 445, 1025]

try:
    host = sys.argv[1]
except:
    host = raw_input("Scanned Host: ")

for port in port_list:
    #print port, "\n"
    s = socket.socket()
    re = s.connect_ex((host, port))
    if (re == 0):
        print host, ":", port, "is open!"
    else:
        print host, ":", port, "is closed!"
    s.close()

print "Done!"

No comments:

Post a Comment