Python实现网络端口扫描器(简单版本)

导航树

代码实现

不多哔哔,直接上代码

代码实现

import socket

def scanner(ip,port):
    try:
        socket.setdefaulttimeout(2)
        ss = socket.socket()
        ss.connect((ip,port))
        data = ss.recv(1024)
        return data
    except:
        return

def comparison(data):
    if 'FreeFloat Ftp Server (Version 1.00)' in data:
        type = '1'
    elif '3Com 3CDaemon FTP Server Version 2.0' in data:
        type = '2'
    else:
        type = '3'
        return type

def main():
    portList = [21,22,25,80,110,443]
    for port in portList:
        data = scanner('xxx.xxx.xxx.xxx', port)
        # print data
        if data:
            res = comparison(data)
            print '[+]xxx.xxx.xxx.xxx:' + str(port) + ':' + str(res)
        else:
            print '[-]xxx.xxx.xxx.xxx:' + str(port) + ': None'

if __name__ == '__main__':
    main()
tag(s): py, attack
show comments · back · home
Edit with markdown

仅有一条评论

  1. 2broear

    好久没来了,dalao还是dalao

    2broear April 7th, 2020 at 11:45 pm回复
召唤看板娘