第一个SCAN程序,菜鸟级别的入门,写在此,也算是种学习纪念。
#scan.py
import socket
ports = [80,8080]
hosts = ['www.freebuf.com','www.baidu.com','www.sina.com']
for host in hosts:
for port in ports:
try:
s = socket.socket()
print "[+]Attempting to connect to " + host + ":" + str(port)
s.connect((host,port))
s.send('agsdfd \n')
banner = s.recv(1024)
if banner:
print "[+]" + host + ":" + str(port) + " open \n" + "[+]The banner infomations are below: \n" + banner
s.close()
except: pass