Advertisement
antraxo9000

Untitled

May 1st, 2019
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. import json
  2. import requests
  3. import threading
  4. import os
  5.  
  6.  
  7. # configuration
  8. INPUT_FILE_PATH = 'accounts.txt'
  9. OUTPUT_FILE_PATH = 'tokens.txt'
  10.  
  11.  
  12. LOGIN_URL = 'https://discordapp.com/api/v6/auth/login'
  13. REQUEST_HEADER = {
  14. 'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36',
  15. 'content-type': 'application/json'
  16. }
  17.  
  18.  
  19. class Client:
  20. def __init__(self, email, password):
  21. self.email = email
  22. self.password = password
  23. self.message = ''
  24.  
  25. def get_message(self):
  26. return self.message
  27.  
  28. def get_token(self):
  29. data = {
  30. 'email': self.email,
  31. 'password': self.password,
  32. }
  33.  
  34. try:
  35. response = requests.post(LOGIN_URL, data=json.dumps(data), headers=REQUEST_HEADER)
  36. if response.status_code == 200:
  37. return response.json()['token']
  38. else:
  39. self.message = 'Authentication failed'
  40. return False
  41. except Exception as e:
  42. self.message = 'Connection established failed'
  43. return False
  44.  
  45.  
  46. class Process:
  47. def __init__(self):
  48. self.lock = threading.Lock()
  49. self.thread_count = 0
  50.  
  51. def _worker(self, email, password):
  52. client = Client(email, password)
  53. result = client.get_token()
  54.  
  55. if result is False:
  56. result = client.get_message()
  57.  
  58. data = email + ':' + password + '\t\t' + result
  59. print(data)
  60. with open(OUTPUT_FILE_PATH, 'a+') as f:
  61. f.write(data + '\n')
  62.  
  63. def _start_work(self, line):
  64. _line = line.rstrip('\n')
  65. if _line:
  66. _info = _line.split(':')
  67. if len(_info) > 1:
  68. _email = _info[0]
  69. _password = _info[1]
  70. self._worker(_email, _password)
  71.  
  72. def start(self):
  73. if os.path.isfile(OUTPUT_FILE_PATH):
  74. os.remove(OUTPUT_FILE_PATH)
  75.  
  76. with open(INPUT_FILE_PATH) as f:
  77. line = f.readline()
  78. self._start_work(line)
  79. while line:
  80. line = f.readline()
  81. self._start_work(line)
  82. print('Completed')
  83.  
  84.  
  85. process = Process()
  86. process.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement