python 端口扫描

#!/usr/bin/env python
#-*- coding:utf-8 -*-
import socket #iptable=[]
nmapport=[21, 22, 23, 80, 110] def retbanner(ip, port):
try:
socket.setdefaulttimeout(2)
s=socket.socket()
s.connect((ip, port))
banner=s.recv(1024)
return banner
except Exception, e:
return "[-] Errors: "+str(e) def IpTbale():
for i in range(1, 255):
for port in nmapport:
ip="192.168.0.{0}".format(i)
str="checking {0}:{1}".format(ip, port)
print str
retbanner(ip, port) if __name__ == '__main__':
IpTbale()

  

上一篇:Java实现FTP文件与文件夹的上传和下载


下一篇:Cornerstone无法上传静态库文件(.a文件)