Port Scanner Code
And here it is
#!/python24
import socket
host = raw_input(“What is the IP? “)
port0 = raw_input(“What is the starting port? “)
port1 = raw_input(“What is the finishing port? “)
output = raw_input(“What shall the log output file be called? “)
port = port0
print “Scanning ports…”
z = open(output + “.log”, “a”)
z.write(“Scan result: “)
z.close()
while int(port) <= int(port1):
try:
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect((host, int(port)))
z = open(output + “.log”, “a”)
z.write(str(port) + ” is open. \n”)
z.close()
s.close()
print port
port = int(port) + 1
except socket.error:
z = open(output + “.log”, “a”)
z.write(“Port: ” + str(port) + ” is closed. “)
z.close()
s.close()
print port
port = int(port) + 1