python脚本获取banner信息

import socket 
def getbanner(IP,port):	
		socket.setdefaulttimeout(2)
		s=socket.socket()
		try:
		s.connect((IP,port))
		banner=s.recv(1024)
		s.close()
		return banner
	except:
		print IP + "is not reachable"
def checkbanner(banner):
	if ("2.3.4" in banner):
		print "it is valubale"
	else:
		print "it is not valuable"
if __name__=="__main__":
	IP1="192.168.80.10"
	IP2="192.168.80.100"
	port=21
	banner1=getbanner(IP1,port)
	banner2=getbanner(IP2,port)
if banner1:
	print IP1
	checkbanner(banner1)
else:
	print "it have not a banner"
if  banner2:
	print IP
	checkbanner(banner2)
else:
	print "it hava not a banner"
上一篇:php – 有概率的横幅旋转广告


下一篇:Android设置顶部banner背景透明度时影响全局背景问题