Advertisement
Guest User

Untitled

a guest
Aug 28th, 2018
1,667
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.72 KB | None | 0 0
  1. import requests, threading, pickle, random, sys, glob, os
  2. from utils import *
  3. from pprint import pprint
  4. from bs4 import BeautifulSoup
  5.  
  6. print (" ")
  7. print (" ")
  8. print (" ")
  9. print ("I edited this to work better! ")
  10. print (" ")
  11. print (" ")
  12. print (" ")
  13.  
  14. global accounts_created
  15. accounts_created = 0
  16. accounts_joined = 0
  17. accounts_favorited = 0
  18. accounts_followed = 0
  19. used_proxies = []
  20.  
  21.  
  22. PATH = "./cookies/" # SERVER
  23. PATH = ".\\cookies\\" # COMPUTER
  24.  
  25. class myThread(threading.Thread):
  26. global used_proxies
  27. global accounts_joined
  28. global accounts_favorited
  29. global accounts_followed
  30.  
  31. def __init__(self, username=None, proxies=None, group=None, favorite=None, follow=None):
  32. threading.Thread.__init__(self)
  33. self.username = username or get_random_name()
  34. self.password = "insaneclient101"
  35. self.email = "{0}@insaney101.com".format(self.username)
  36. self.s = requests.Session()
  37. self.cookies = None
  38. self.proxies = proxies or self.scrape()
  39. self.proxy = None
  40. self.group = group
  41. self.should_create = not username
  42. self.favorite = favorite
  43. self.follow = follow
  44. self.successfully_created = True
  45.  
  46. def run(self):
  47. if self.should_create:
  48. self.create()
  49. if self.successfully_created:
  50. print("{0.username} {0.favorite}".format(self))
  51. if self.group and self.successfully_created:
  52. self.cookies = self.get_cookies()
  53. self.join_group()
  54. if self.favorite and self.successfully_created:
  55. self.cookies = self.get_cookies()
  56. self.favorite_item()
  57. if self.follow and self.successfully_created:
  58. self.cookies = self.get_cookies()
  59. self.follow_user()
  60. # self.scrape()
  61.  
  62. def favorite_item(self, amount = 1):
  63. def retry():
  64. self.new_proxy()
  65. if amount < 5:
  66. try:
  67. self.favorite_item(amount = amount + 1)
  68. except Exception as e2:
  69. print("Unnamed error".format(self, str(e2)))
  70. else:
  71. pass
  72. print("{0.username} favoriting item attempt #{1}".format(self, amount))
  73. headers = """
  74. Connection: keep-alive
  75. Upgrade-Insecure-Requests: 1
  76. User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
  77. Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
  78. Accept-Encoding: gzip, deflate, sdch, br
  79. Accept-Language: en-US,en;q=0.8
  80. """
  81. try:
  82. r = self.s.get(url = self.favorite,
  83. headers = string_to_dict(headers),
  84. timeout = 10,
  85. cookies = self.cookies,
  86. # proxies = self.proxy,
  87. verify = False)
  88. csrf = r.text.split("setToken('")[1].split("'")[0]
  89.  
  90. headers = """
  91. Host: www.roblox.com
  92. Connection: keep-alive
  93. Content-Length: {}
  94. Pragma: no-cache
  95. Cache-Control: no-cache
  96. Accept: */*
  97. Origin: https://www.roblox.com
  98. X-CSRF-TOKEN: {}
  99. User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
  100. Content-Type: application/x-www-form-urlencoded; charset=UTF-8
  101. Referer: {}
  102. Accept-Encoding: gzip, deflate, br
  103. Accept-Language: en-US,en;q=0.8
  104. """
  105. data = "assetID={}".format(self.favorite.split("/")[-2])
  106. headers = headers.format(len(data), csrf, self.favorite)
  107. r = self.s.post(url = "https://www.roblox.com/favorite/toggle",
  108. data = data,
  109. headers = string_to_dict(headers),
  110. cookies = self.cookies,
  111. # proxies = self.proxy,
  112. verify = False)
  113. if r.status_code == 200 and "{\"success\":true}" in r.text:
  114. print("{0.username} successfully liked item {0.favorite}".format(self))
  115. with open("history.txt", "a") as f:
  116. f.write("{0.username}:{0.favorite}\n".format(self))
  117. global accounts_favorited
  118. accounts_favorited += 1
  119. return True
  120. except Exception as e:
  121. exc_type, exc_obj, exc_tb = sys.exc_info()
  122. fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
  123. print(exc_type, fname, exc_tb.tb_lineno)
  124. retry()
  125. return
  126.  
  127. if r.text == "{\"success\":false,\"message\":\"Whoa. Slow down.\"}":
  128. print("{0.username} going too fast, waiting 30 seconds.".format(self))
  129. return False
  130. print("{0.username} successfully liked item {0.favorite}".format(self, r.text))
  131. accounts_favorited += 1
  132. return False
  133.  
  134.  
  135. def get_cookies(self):
  136. # print("Logging in as {0.username}".format(self))
  137. # self.s.cookies.clear()
  138. # self.s.cookies.update(pickle.load(open("cookies\\{0.username}.txt".format(self), "rb")))
  139.  
  140. # return pickle.load(open("./cookies/{0.username}.txt".format(self), "rb")) # server
  141. x = None
  142. with open(PATH + "{0.username}.txt".format(self), "rb") as f:
  143. return pickle.load(f) #computer
  144.  
  145. def create(self, amount = 1):
  146. def retry():
  147. self.new_proxy()
  148. if amount < 10:
  149. try:
  150. self.create(amount = amount + 1)
  151. except Exception as e2:
  152. self.successfully_created = False
  153. print("Bot has gay and don't know what happening.".format(self, str(e2)))
  154. else:
  155. self.successfully_created = False
  156. # print("Tried 5 proxies, none of them worked.")
  157. pass
  158. print("Creating {0.username}... attempt #{1}".format(self, amount))
  159. self.s = requests.Session()
  160. headers = """
  161. Host: api.roblox.com
  162. Connection: keep-alive
  163. Content-Length: {}
  164. Accept: application/json, text/plain, */*
  165. Origin: https://www.roblox.com
  166. User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36
  167. Content-Type: application/x-www-form-urlencoded
  168. Referer: https://www.roblox.com/
  169. Accept-Encoding: gzip, deflate, br
  170. Accept-Language: en-US,en;q=0.8
  171. """
  172. data = "isEligibleForHideAdsAbTest=True&username={0.username}&password={0.password}&birthday=18+Dec+1941&gender={1}&context=RollerCoasterSignupForm"
  173. data = data.format(self, random.randint(2, 3))
  174. headers = headers.format(len(data))
  175.  
  176. r = None
  177.  
  178. try:
  179. r = self.s.post(url = "https://api.roblox.com/signup/v1",
  180. data = data,
  181. headers = string_to_dict(headers),
  182. proxies = self.proxy,
  183. timeout = 10,
  184. verify = False)
  185. except Exception as e:
  186. # print("{0.username} -> ERROR -> {1}".format(self, str(e)))
  187. self.successfully_created = False
  188. retry()
  189. return
  190.  
  191. try:
  192. userID = r.json()["userId"]
  193. if userID:
  194. self.userID = userID
  195. with open("accounts.txt", "a") as f:
  196. f.write("{0.username}:{0.password}:{0.email}:{0.userID}:{1}\n".format(self, self.proxy["https"].replace("https://", "").replace(":", ",")))
  197. self.successfully_created = True
  198. print("Successfully created a account {0.username}:{0.password}:{0.email}:{0.userID}:{1}".format(self, (self.proxy["https"] or "None").replace("https://", "").replace(":", ",")))
  199. global accounts_created
  200. accounts_created += 1
  201. used_proxies.append(self.proxy)
  202. self.save_cookies()
  203. except Exception as e:
  204. if r.json()["reasons"][0] == "Captcha":
  205. print("{0.username} -> CAPTCHA, is blocking.".format(self))
  206. self.successfully_created = False
  207. retry()
  208. return
  209. else:
  210. self.successfully_created = False
  211. print("Username already taken")
  212.  
  213.  
  214. def save_cookies(self):
  215. pickle.dump(self.s.cookies, open(PATH + "{0.username}.txt".format(self), "wb"))
  216.  
  217. def new_proxy(self):
  218. self.proxy = random.choice(self.proxies)
  219. self.proxy = {"https": "https://" + self.proxy}
  220. if self.proxy in used_proxies:
  221. self.new_proxy()
  222. return
  223. return self.proxy
  224.  
  225.  
  226. def scrape():
  227. s = requests.Session()
  228. print("Stealing proxies...")
  229. proxies_urls = ["http://sslproxies24.blogspot.com/feeds/posts/default",
  230. "http://proxyserverlist-24.blogspot.com/feeds/posts/default"]
  231. proxies = []
  232.  
  233. for proxies_url in proxies_urls:
  234. r = s.get(url = proxies_url)
  235.  
  236. for proxy in r.text.split("&lt;br /&gt;"):
  237. if not proxy: continue
  238. if (len(proxy) > 21 or len(proxy) < 10) or "span" in proxy: continue
  239. proxies.append(proxy)
  240. proxies = list(set(proxies))
  241. print("Found {} proxies".format(len(proxies)))
  242. print(" ")
  243. print(" ")
  244. print("Starting to create/favorite")
  245. print("This ussualy takes 5-30 seconds")
  246. print(" ")
  247. return proxies
  248.  
  249.  
  250. # for _ in range(40):
  251. # manager.load(myThread(proxies=proxies))
  252.  
  253. # if len(sys.argv) == 3
  254.  
  255. def get_history():
  256. try:
  257. with open("history.txt", "r") as f:
  258. return f.read()
  259. except Exception as e:
  260. return ""
  261.  
  262. for _ in range(1):
  263. with open("config.txt", "r") as config:
  264. config = config.read()
  265. manager = ThreadManager(MAX_THREADS = int(config.split("\n")[0].split("=")[1]))
  266. proxies = None
  267. history = get_history()
  268.  
  269. try:
  270. with open("proxies.txt", "r") as p:
  271. proxies = p.read().split("\n")
  272. except Exception as e:
  273. proxies = scrape()
  274.  
  275. create_amount = int(config.split("\n")[1].split("=")[1])
  276. for _ in range(create_amount):
  277. manager.load(myThread(proxies=proxies))
  278.  
  279. max_amount = 0
  280. if "amount=" in config:
  281. max_amount = int(config.split("amount=")[1].split("\n")[0])
  282. print(max_amount)
  283.  
  284. reverse = 1
  285. offset = 0
  286.  
  287. accounts = glob.glob(PATH + "*.txt")[::reverse][offset:]
  288. print(len(accounts))
  289. random.shuffle(accounts)
  290.  
  291. if "favorite=yes" in config:
  292. with open("favorites.txt", "r") as favorites:
  293. for favorite in favorites.read().split("\n"):
  294. if not favorite: continue
  295. for account in accounts:
  296. if len(manager.threads) > max_amount: break
  297. account = account.replace(PATH, "").replace(".txt", "")
  298. manager.load(myThread(proxies=proxies, username=account if not create_amount else None, favorite=favorite))
  299.  
  300. manager.start()
  301.  
  302. print("{} accounts created.".format(accounts_created))
  303. print("{} accounts liked an item.".format(accounts_favorited))
  304. # for account in glob.glob("cookies\\*.txt")[:10]:
  305. # manager.load(myThread(proxies=proxies, username=account[8:-2], favorite="https://www.roblox.com/catalog/590588883/B-W-Nike-Shoes"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement