python 埠掃描

Rocky_Ansi發表於2016-08-23
#!/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()

  

相關文章