Python-FTP漏洞扫描脚本

import socket
import os
import sys

def retBanner(ip, port):
    try:
        socket.setdefaulttimeout(2)
        s = socket.socket()
        s.connect((ip, port))
        banner = s.recv(1024)
        return banner
    except:
        return
        
def checkVulns(banner, filename):
    f = open(filename, 'r')
    for line in f.readlines():
        if line.strip('\n') in banner:
            print "[+] Server is vulnerable: " + banner.strip('\n')


def main():
    if len(sys.argv) == 2:
        filename = sys.argv[1]
        if not os.path.isfile(filename):
            print '[-] ' + filename + ' does not exist.'
            exit(0)
            if not os.access(filename,os.R_OK):
                print '[-]'+filename+'access denied'
                exit(0)
            else:
                print '[-] Usage:'+str(sys.argv[0])+'<vuln filename>'
                exit(0)
    portList = [21, 22, 25, 80, 110, 443]
    for x in range(1, 10):
        ip = '10.0.21.' + str(x)
        for port in portList:
            banner = retBanner(ip, port)

    if banner:
        print '[+] ' + ip + ': ' + banner
        checkVulns(banner)


if __name__ == '__main__':
    main()

发布了84 篇原创文章 · 获赞 30 · 访问量 7万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览