Advertisement
AlessandroCFW

Untitled

Apr 14th, 2023
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.43 KB | None | 0 0
  1. # made by xolo#4942
  2. # version 4.1.5
  3.  
  4. try:
  5. import datetime
  6. import json
  7. import os
  8. import uuid
  9. import asyncio
  10. import random
  11. import requests
  12. import configparser
  13. from colorama import Fore, Back, Style
  14. import fake_useragent
  15. import aiohttp
  16.  
  17. except ModuleNotFoundError:
  18. print("Modules not installed properly installing now")
  19. os.system("pip install requests")
  20. os.system("pip install configparser")
  21. os.system("pip install colorama")
  22. os.system("pip install fake_useragent")
  23. os.system("pip install aiohttp")
  24.  
  25. ua = fake_useragent.UserAgent()
  26. config = configparser.ConfigParser()
  27. config.read('config.ini')
  28. class Sniper:
  29. def __init__(self) -> None:
  30. self.webhookEnabled = False if not "configWebhook" in config or not bool(config["configWebhook"]["enabled"] == "on") else True
  31. self.webhookUrl = config["configWebhook"]["webhook"] if self.webhookEnabled else None
  32. self.accounts = None
  33. self.items = self._load_items()
  34. self.title = ("""
  35. ▒██ ██▒ ▒█████ ██▓ ▒█████ ██████ ███▄ █ ██▓ ██▓███ ▓█████ ██▀███
  36. ▒▒ █ █ ▒░▒██▒ ██▒▓██▒ ▒██▒ ██▒ ▒██ ▒ ██ ▀█ █ ▓██▒▓██░ ██▒▓█ ▀ ▓██ ▒ ██▒
  37. ░░ █ ░▒██░ ██▒▒██░ ▒██░ ██▒ ░ ▓██▄ ▓██ ▀█ ██▒▒██▒▓██░ ██▓▒▒███ ▓██ ░▄█ ▒
  38. ░ █ █ ▒ ▒██ ██░▒██░ ▒██ ██░ ▒ ██▒▓██▒ ▐▌██▒░██░▒██▄█▓▒ ▒▒▓█ ▄ ▒██▀▀█▄
  39. ▒██▒ ▒██▒░ ████▓▒░░██████▒░ ████▓▒░ ▒██████▒▒▒██░ ▓██░░██░▒██▒ ░ ░░▒████▒░██▓ ▒██▒
  40. ▒▒ ░ ░▓ ░░ ▒░▒░▒░ ░ ▒░▓ ░░ ▒░▒░▒░ ▒ ▒▓▒ ▒ ░░ ▒░ ▒ ▒ ░▓ ▒▓▒░ ░ ░░░ ▒░ ░░ ▒▓ ░▒▓░
  41. ░░ ░▒ ░ ░ ▒ ▒░ ░ ░ ▒ ░ ░ ▒ ▒░ ░ ░▒ ░ ░░ ░░ ░ ▒░ ▒ ░░▒ ░ ░ ░ ░ ░▒ ░ ▒░
  42. ░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ▒ ░░░ ░ ░░ ░
  43. ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
  44.  
  45. """)
  46. self.checks = 0
  47. self.buys = 0
  48. self.request_method = 2
  49. self.total_ratelimits = 0
  50. self.last_time = 0
  51. self.errors = 0
  52. self.clear = "cls" if os.name == 'nt' else "clear"
  53. self.version = "4.1.5"
  54. self.task = None
  55. self._setup_accounts()
  56. # / couldn't fix errors aka aiohttp does not support proxies
  57. # self.proxylist = open("proxylist.txt").read().splitlines()
  58. # self.workingProxies = []
  59. # asyncio.run(self.start_proxy())
  60. # print(self.workingProxies)
  61. self.check_version()
  62. asyncio.run(self.start())
  63.  
  64. # / couldn't fix errors aka aiohttp does not support proxies
  65. #async def check(self, proxy):
  66. # async with aiohttp.ClientSession() as session:
  67. # async with session.get('http://httpbin.org/ip', proxy=f'http://{proxy}', timeout=aiohttp.ClientTimeout(total=2), ssl = False) as resp:
  68. # if resp.status == 200:
  69. # self.workingProxies.append(proxy)
  70. # return
  71.  
  72. #def get_working_proxy(self):
  73. # if len(self.workingProxies) != 0:
  74. # proxy = random.choice(self.workingProxies)
  75. # return f"http://{proxy}"
  76. # else:
  77. # return None
  78.  
  79. #async def start_proxy(self):
  80. # self.status = "Proxy checker"
  81. # self._print_stats
  82. # coroutines = []
  83. # for proxy in self.proxylist:
  84. # coroutines.append(self.check(proxy))
  85. # await asyncio.gather(*coroutines)
  86.  
  87. def check_version(self):
  88. self.task = "Github Checker"
  89. self._print_stats()
  90. response = requests.get("https://pastebin.com/raw/MXFsQ0TQ")
  91.  
  92. if response.status_code != 200:
  93. pass
  94. print(response.text)
  95. if not response.text == self.version:
  96. print("NEW UPDATED VERSION PLEASE UPDATE YOUR FILE")
  97. print("will continue in 5 seconds")
  98. import time
  99. time.sleep(5)
  100.  
  101. class DotDict(dict):
  102. def __getattr__(self, attr):
  103. return self[attr]
  104.  
  105. def _setup_accounts(self) -> None:
  106. self.task = "Account Loader"
  107. self._print_stats
  108. cookies = self._load_cookies()
  109. for i in cookies:
  110. response = asyncio.run(self._get_user_id(cookies[i]["cookie"]))
  111. response2 = asyncio.run(self._get_xcsrf_token(cookies[i]["cookie"]))
  112. cookies[i]["id"] = response
  113. cookies[i]["xcsrf_token"] = response2["xcsrf_token"]
  114. cookies[i]["created"] = response2["created"]
  115. self.accounts = cookies
  116.  
  117. def _load_cookies(self) -> dict:
  118. with open("cookie.txt", "r") as file:
  119. lines = file.read().split('\n')
  120. my_dict = {}
  121. for i, line in enumerate(lines):
  122. my_dict[str(i+1)] = {}
  123. my_dict[str(i+1)] = {"cookie": line}
  124. return my_dict
  125.  
  126. def _load_items(self) -> list:
  127. with open('limiteds.txt', 'r') as f:
  128. return [line.strip() for line in f.readlines()]
  129.  
  130. async def _get_user_id(self, cookie) -> str:
  131. async with aiohttp.ClientSession(cookies={".ROBLOSECURITY": cookie}) as client:
  132. response = await client.get("https://users.roblox.com/v1/users/authenticated")
  133. data = await response.json()
  134. if data.get('id') == None:
  135. raise Exception("Couldn't scrape user id. Error:", data)
  136. return data.get('id')
  137.  
  138. def _print_stats(self) -> None:
  139. print(f"Version: {self.version}")
  140. print(Fore.GREEN + Style.BRIGHT + self.title)
  141. print(Fore.RESET + Style.RESET_ALL)
  142. print(Style.BRIGHT + f" [ Total buys: {Fore.GREEN}{Style.BRIGHT}{self.buys}{Fore.WHITE}{Style.BRIGHT} ]")
  143. print(Style.BRIGHT + f" [ Total errors: {Fore.RED}{Style.BRIGHT}{self.errors}{Fore.WHITE}{Style.BRIGHT} ]")
  144. print(Style.BRIGHT + f" [ Last Speed: {Fore.YELLOW}{Style.BRIGHT}{self.last_time}{Fore.WHITE}{Style.BRIGHT} ]")
  145. print(Style.BRIGHT + f" [ Total ratelimits: {Fore.RED}{Style.BRIGHT}{self.total_ratelimits}{Fore.WHITE}{Style.BRIGHT} ]")
  146. print(Style.BRIGHT + f" [ Total price checks: {Fore.YELLOW}{Style.BRIGHT}{self.checks}{Fore.WHITE}{Style.BRIGHT} ]")
  147. print()
  148. print(Style.BRIGHT + f" [ Current Task: {Fore.GREEN}{Style.BRIGHT}{self.task}{Fore.WHITE}{Style.BRIGHT} ]")
  149.  
  150. async def _get_xcsrf_token(self, cookie) -> dict:
  151. async with aiohttp.ClientSession(cookies={".ROBLOSECURITY": cookie}) as client:
  152. response = await client.post("https://accountsettings.roblox.com/v1/email", headers={'User-Agent': ua.random})
  153. xcsrf_token = response.headers.get("x-csrf-token")
  154. if xcsrf_token is None:
  155. raise Exception("An error occurred while getting the X-CSRF-TOKEN. "
  156. "Could be due to an invalid Roblox Cookie")
  157. return {"xcsrf_token": xcsrf_token, "created": datetime.datetime.now()}
  158.  
  159. async def _check_xcsrf_token(self) -> bool:
  160. for i in self.accounts:
  161. if self.accounts[i]["xcsrf_token"] is None or \
  162. datetime.datetime.now() > (self.accounts[i]["created"] + datetime.timedelta(minutes=10)):
  163. try:
  164. response = await self._get_xcsrf_token(self.accounts[i]["cookie"])
  165. self.accounts[i]["xcsrf_token"] = response["xcsrf_token"]
  166. self.accounts[i]["created"] = response["created"]
  167. return True
  168. except Exception as e:
  169. print(f"{e.__class__.__name__}: {e}")
  170. return False
  171. return True
  172. return False
  173.  
  174. async def start(self) -> None:
  175. async def buy_item(item_id: int, price: int, user_id: int, creator_id: int,
  176. product_id: int, cookie: str, x_token: str) -> None:
  177.  
  178. """
  179. Purchase a limited item on Roblox.
  180. Args:
  181. item_id (int): The ID of the limited item to purchase.
  182. price (int): The price at which to purchase the limited item.
  183. user_id (int): The ID of the user who will be purchasing the limited item.
  184. creator_id (int): The ID of the user who is selling the limited item.
  185. product_id (int): The ID of the product to which the limited item belongs.
  186. cookie (str): The .ROBLOSECURITY cookie associated with the user's account.
  187. x_token (str): The X-CSRF-TOKEN associated with the user's account.
  188. """
  189.  
  190.  
  191. data = {
  192. "collectibleItemId": item_id,
  193. "expectedCurrency": 1,
  194. "expectedPrice": price,
  195. "expectedPurchaserId": user_id,
  196. "expectedPurchaserType": "User",
  197. "expectedSellerId": creator_id,
  198. "expectedSellerType": "User",
  199. "idempotencyKey": "random uuid4 string that will be your key or smthn",
  200. "collectibleProductId": product_id
  201. }
  202. total_errors = 0
  203. async with aiohttp.ClientSession() as client:
  204. while True:
  205. if total_errors >= 10:
  206. print("Too many errors encountered. Aborting purchase.")
  207. return
  208.  
  209. data["idempotencyKey"] = str(uuid.uuid4())
  210. response = await client.post(f"https://apis.roblox.com/marketplace-sales/v1/item/{item_id}/purchase-item",
  211. json=data,
  212. headers={"x-csrf-token": x_token, 'User-Agent': ua.random},
  213. cookies={".ROBLOSECURITY": cookie})
  214.  
  215. if response.status == 429:
  216. print("Ratelimit encountered. Retrying purchase in 0.5 seconds...")
  217. await asyncio.sleep(0.5)
  218. continue
  219.  
  220. try:
  221. json_response = await response.json()
  222. except aiohttp.ContentTypeError as e:
  223. self.errors += 1
  224. print(f"JSON decode error encountered: {e}. Retrying purchase...")
  225. total_errors += 1
  226. continue
  227.  
  228. if not json_response["purchased"]:
  229. self.errors += 1
  230. print(f"Purchase failed. Response: {json_response}. Retrying purchase...")
  231. total_errors += 1
  232. else:
  233. print(f"Purchase successful. Response: {json_response}.")
  234. self.buys += 1
  235.  
  236.  
  237. while True:
  238. self.task = "Item Scraper"
  239. t0 = asyncio.get_event_loop().time()
  240. os.system(self.clear)
  241. self._print_stats()
  242. if not await self._check_xcsrf_token():
  243. raise Exception("x_csrf_token couldn't be generated")
  244.  
  245.  
  246. for currentItem in self.items:
  247. async with aiohttp.ClientSession() as session:
  248.  
  249. if not currentItem.isdigit():
  250. raise Exception(f"Invalid item id given ID: {currentItem}")
  251.  
  252. currentAccount = self.accounts[str(random.randint(1, len(self.accounts)))]
  253. async with session.post("https://catalog.roblox.com/v1/catalog/items/details",
  254. json={"items": [{"itemType": "Asset", "id": int(currentItem)}]},
  255. headers={"x-csrf-token": currentAccount['xcsrf_token']},
  256. cookies={".ROBLOSECURITY": currentAccount["cookie"]}) as response:
  257. self.checks += 1
  258.  
  259. try:
  260. jsonr = await response.json()
  261. except:
  262. print("JSON response error")
  263. self.errors += 1
  264.  
  265. if response.status == 429:
  266. print("Rate limit hit")
  267. self.total_ratelimits += 1
  268. await asyncio.sleep(30)
  269. continue
  270.  
  271. if response.status != 200:
  272. print("Random error:", jsonr)
  273. self.errors += 1
  274. if jsonr.get("message") == 'Token Validation Failed':
  275. self.status = "getting x token"
  276. self._print_stats()
  277. response = await self._get_xcsrf_token(currentAccount["cookie"])
  278. currentAccount["xcsrf_token"] = response["xcsrf_token"]
  279. currentAccount["created"] = response["created"]
  280. elif jsonr.get("errors")[0]["message"] is not None and jsonr.get("errors")[0]["message"] == 'Invalid asset type id.':
  281. raise Exception("Invalid Item Id given")
  282.  
  283. await asyncio.sleep(10)
  284. continue
  285.  
  286. try:
  287. json_response = jsonr["data"][0]
  288. except Exception as e:
  289. print("Json Error:", e)
  290.  
  291. if json_response.get("priceStatus") != "Off Sale" and 0 if json_response.get('unitsAvailableForConsumption') is None else json_response.get('unitsAvailableForConsumption') > 0:
  292. productid_response = await session.post("https://apis.roblox.com/marketplace-items/v1/items/details",
  293. json={"itemIds": [json_response["collectibleItemId"]]},
  294. headers={"x-csrf-token": self.accounts[str(random.randint(1, len(self.accounts)))]["xcsrf_token"]},
  295. cookies={".ROBLOSECURITY": self.accounts[str(random.randint(1, len(self.accounts)))]["cookie"]})
  296.  
  297.  
  298. if productid_response.status == 404:
  299. print("Product not found")
  300. self.errors += 1
  301. continue
  302.  
  303. try:
  304. da = await productid_response.json(content_type='application/json')
  305. productid_data = da[0]
  306. except (json.JSONDecodeError, aiohttp.ContentTypeError) as e:
  307. print(f'Error decoding JSON: {e}')
  308. self.errors += 1
  309. continue
  310. coroutines = []
  311. for i in self.accounts:
  312. coroutines.append(buy_item(item_id = json_response["collectibleItemId"], price = json_response['price'], user_id = self.accounts[i]["id"], creator_id = json_response['creatorTargetId'], product_id = productid_data['collectibleProductId'], cookie = self.accounts[i]["cookie"], x_token = self.accounts[i]["xcsrf_token"]))
  313. self.task = "Item Buyer"
  314. self._print_stats()
  315. await asyncio.gather(*coroutines)
  316. t1 = asyncio.get_event_loop().time()
  317. self.last_time = round(t1 - t0, 3)
  318. await asyncio.sleep(1)
  319.  
  320. sniper = Sniper()
  321. sniper
  322.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement