Guest User

Untitled

a guest
Feb 25th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.83 KB | None | 0 0
  1. import subprocess
  2. import configparser
  3. import requests
  4. import psutil
  5. import signal
  6. import random
  7. import string
  8. import os.path
  9. import time
  10. import sys
  11. import os
  12.  
  13.  
  14. class RobloxBot:
  15. """A simple Roblox bot class"""
  16. def __init__(self):
  17. # creates a request session
  18. self.session = requests.session()
  19. # creates headers
  20. self.headers = {'User-Agent': 'Roblox/WinInet'}
  21. # sets sessions headers
  22. self.session.headers.update(self.headers)
  23.  
  24. def sign_in(self, username, password):
  25. # creates login payload
  26. payload = {'username': username, 'password': password, 'submitLogin': 'Log+In'}
  27. # loops until successful
  28. proxy = "nope"
  29. while True:
  30. try:
  31. # posts login data to roblox
  32. r = self.session.post('https://www.roblox.com/newlogin', data=payload, headers={'Referer': 'https://www.roblox.com/'}, timeout=5)
  33. # checks status
  34. r.raise_for_status()
  35. # notifies user
  36. print('Found working proxy:', proxy)
  37. except:
  38. print(proxy, 'could not connect.')
  39. continue
  40. # validates log in
  41. if 'My Feed' in r.text:
  42. # notifies user
  43. print('Successfully logged into:', username)
  44. return True
  45. elif 'not a robot!' in r.text:
  46. # if a captcha is present
  47. print('Captcha found. Retrying.')
  48. continue
  49. else:
  50. # notifies user
  51. print('Login failed for:', username)
  52. return False
  53.  
  54. def like_game(self, game_id):
  55. # creates referer headers
  56. referer = {'Referer': 'https://www.roblox.com/games/{}'.format(game_id)}
  57. # gets authticket for user
  58. auth_ticket = self.session.get('https://www.roblox.com/game-auth/getauthticket', headers=referer).text
  59. # gets browser tracker
  60. browser = ''.join(str(random.randint(0,9)) for x in range(10))
  61. # formats uri parameters for game launch
  62. mapped_uri = "roblox-player:1+launchmode:play+gameinfo:{}+launchtime:1493656459622+placelauncherurl:https%3A%2F%2Fassetgame.roblox.com%2Fgame%2FPlaceLauncher.ashx%3Frequest%3DRequestGame%26browserTrackerId%3D{}%26placeId%3D{}%26isPartyLeader%3Dfalse+browsertrackerid:{}".format(auth_ticket, browser, game_id, browser)
  63. # launches roblox
  64. roblox = subprocess.Popen([game_path, mapped_uri])
  65. # notifies user
  66. print('Successfully launched Roblox and joined game:', game_id)
  67. # waits 10 seconds
  68. time.sleep(game_launch_time)
  69. # kills process
  70. for process in psutil.process_iter():
  71. # check whether the process name matches
  72. if process.name() == 'RobloxPlayerBeta.exe':
  73. # kills process
  74. process.kill()
  75. # gets cookies
  76. r = self.session.get('https://www.roblox.com/games/{}'.format(game_id))
  77. # extracts csrf token
  78. csrf_token = r.text.split("Roblox.XsrfToken.setToken('")[-1].split("');")[0]
  79. # creates like payload
  80. payload = {'assetId': game_id, 'vote': 'true'}
  81. # creates like headers
  82. headers = {'X-CSRF-TOKEN': csrf_token, 'Referer': r.url}
  83. # sends like post request to roblox
  84. r = self.session.post('https://www.roblox.com/voting/vote', params=payload, headers=headers)
  85. # validates like
  86. if r.json()['Success']:
  87. # notifies user
  88. print('Successfully liked game:', game_id)
  89. else:
  90. # notifies user
  91. print('There was a problem liking the game:', game_id)
  92. print('Reason:', r.json()['Model']['ReasonForNotVoteable'])
  93. # sends favourite to roblox
  94. r = self.session.post('https://www.roblox.com/favorite/toggle', params={'assetId': game_id}, headers=headers)
  95. # validates favourite
  96. if r.json()['success']:
  97. # notifies user
  98. print('Successfully favourited game:', game_id)
  99. else:
  100. # notifies user
  101. print('There was a problem favoriting game:', game_id)
  102.  
  103. def start(userpass):
  104. # instantiates roblox bot
  105. bot = RobloxBot()
  106. # signs up on roblox with username and password
  107. if bot.sign_in(username=userpass[0], password=userpass[1]):
  108. # likes game with certain id
  109. bot.like_game(game_id=game_id)
  110.  
  111. if __name__ == '__main__':
  112. # reads config file
  113. config = configparser.ConfigParser()
  114. config.read('config.ini')
  115. try:
  116. # sets game path
  117. game_path = config['general']['game_path']
  118. # verifies game exists
  119. if os.path.isfile(game_path):
  120. print('Verified game exists.')
  121. else:
  122. sys.exit('Could not find your Roblox launcher.')
  123. # sets proxy list path
  124. proxy_list_path = config['general']['proxy_list_path']
  125. # gets proxy list
  126. proxies = open(proxy_list_path).read().split('\n')
  127. # notifies user
  128. print('Loaded proxies.')
  129. # sets account list path
  130. account_list_path = config['general']['account_list_path']
  131. # notifies user
  132. print('Loaded accounts.')
  133. # gets thread count
  134. thread_count = int(config['general']['thread_count'])
  135. game_launch_time = int(config['general']['game_launch_time'])
  136. except KeyError:
  137. sys.exit('Config file error.')
  138. # prompts user for game id
  139. game_id = input('Please enter the game mode ID: ')
  140. # gets accounts
  141. accounts = [x.split(':') for x in open(account_list_path).read().split('\n')]
  142. # iterates through accounts
  143. for username, password in accounts:
  144. # instantiates roblox bot
  145. bot = RobloxBot()
  146. # signs up on roblox with username and password
  147. if bot.sign_in(username=username, password=password):
  148. # likes game with certain id
  149. bot.like_game(game_id=game_id)
Add Comment
Please, Sign In to add comment