mirror of
				https://gitea.augustin64.fr/piair/MsRewards-Reborn.git
				synced 2025-10-26 12:53:34 +01:00 
			
		
		
		
	Compare commits
	
		
			8 Commits
		
	
	
		
			db157771de
			...
			3eb193eca3
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 3eb193eca3 | ||
|  | f566b2eeda | ||
|  | 52e88f81b9 | ||
|  | 1a8137783c | ||
|  | 6f13b2532d | ||
|  | 3978c44bbc | ||
|  | 49dc53ed32 | ||
|  | ba66a96c65 | 
| @@ -25,6 +25,9 @@ RUN curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyri | ||||
| RUN apt update \ | ||||
|     && apt install -y redis grafana | ||||
|  | ||||
| # Configure Grafana | ||||
| RUN grafana-cli plugins install frser-sqlite-datasource | ||||
|  | ||||
| COPY requirements.txt /app/requirements.txt | ||||
| RUN python3 -m pip install -r requirements.txt | ||||
|  | ||||
|   | ||||
							
								
								
									
										50
									
								
								V6.py
									
									
									
									
									
								
							
							
						
						
									
										50
									
								
								V6.py
									
									
									
									
									
								
							| @@ -9,7 +9,7 @@ from modules.db import add_to_database | ||||
| from modules.driver_tools import * | ||||
| from modules.error import * | ||||
|  | ||||
| import os | ||||
| from selenium.common.exceptions import NoSuchElementException | ||||
|  | ||||
| # create a webdriver  | ||||
| def create_driver(mobile=False): | ||||
| @@ -24,9 +24,7 @@ def create_driver(mobile=False): | ||||
|         "Chrome/22 Mobile Safari/537.36" | ||||
|     ) | ||||
|  | ||||
|     # Profile dir | ||||
|     chrome_profile_dir = "/app/MsRewards-Reborn/user_data/profile/"+config.UserCredentials.get_mail() | ||||
|     os.makedirs(chrome_profile_dir, exist_ok=True) | ||||
|     chrome_profile_dir = init_profile(config.UserCredentials.get_mail()) | ||||
|  | ||||
|     # Full list on https://github.com/GoogleChrome/chrome-launcher/blob/main/docs/chrome-flags-for-tools.md | ||||
|     arguments = [ | ||||
| @@ -52,7 +50,6 @@ def create_driver(mobile=False): | ||||
|         chrome_options.add_argument(arg) | ||||
|  | ||||
|     driver = uc.Chrome(options=chrome_options) | ||||
|     set_language(driver) | ||||
|     return driver | ||||
|  | ||||
|  | ||||
| @@ -383,22 +380,35 @@ def login_part_1(): | ||||
|     driver = config.WebDriver.driver | ||||
|     driver.get("https://login.live.com") | ||||
|     wait_until_visible(By.ID, "i0116", browser=driver) | ||||
|     mail_elem = driver.find_element(By.ID, "i0116") | ||||
|     send_keys_wait(mail_elem, config.UserCredentials.get_mail()) | ||||
|     mail_elem.send_keys(Keys.ENTER) | ||||
|     send_wait_and_confirm( | ||||
|         driver.find_element(By.ID, "i0116"), | ||||
|         config.UserCredentials.get_mail() | ||||
|     ) | ||||
|     wait_until_visible(By.ID, "i0118", browser=driver) | ||||
|     pwd_elem = driver.find_element(By.ID, "i0118") | ||||
|     send_keys_wait(pwd_elem, config.UserCredentials.get_password()) | ||||
|     pwd_elem.send_keys(Keys.ENTER) | ||||
|     custom_sleep(2) | ||||
|     send_wait_and_confirm( | ||||
|         driver.find_element(By.ID, "i0118"), | ||||
|         config.UserCredentials.get_password() | ||||
|     ) | ||||
|     # 2FA | ||||
|     if "Entrez le code de sécurité" in driver.page_source: | ||||
|         try: | ||||
|             a2f_elem = driver.find_element(By.ID, "idTxtBx_SAOTCC_OTC") | ||||
|             a2f_elem.send_keys(config.UserCredentials.get_tfa().now()) | ||||
|             a2f_elem.send_keys(Keys.ENTER) | ||||
|         except Exception as err: | ||||
|             log_error(err) | ||||
|     try: | ||||
|         if not wait_until_visible(By.ID, "idTxtBx_SAOTCC_OTC", browser=driver, timeout=5, raise_error=False): | ||||
|             custom_sleep(2) | ||||
|             return | ||||
|  | ||||
|         tfa = config.UserCredentials.get_tfa() | ||||
|         if tfa is None: | ||||
|             error("2FA needed but no code available for this account, sending error") | ||||
|             raise ValueError("2FA needed but no code available for this account") | ||||
|         else: | ||||
|             a2f_code = tfa.now() | ||||
|  | ||||
|         info(f"Need 2FA, I have code: {a2f_code}") | ||||
|         send_wait_and_confirm( | ||||
|             driver.find_element(By.ID, "idTxtBx_SAOTCC_OTC"), | ||||
|             a2f_code | ||||
|         ) | ||||
|     except Exception as err: | ||||
|         log_error(err) | ||||
|  | ||||
|  | ||||
| # Accept all cookies question, and check if the account is locked | ||||
| @@ -699,7 +709,7 @@ def json_start(json_entry, cred: UserCredentials): | ||||
|             config.WebDriver.switch_to_driver("PC") | ||||
|             driver = config.WebDriver.driver | ||||
|             try: | ||||
|                 if str(account_id) in json_entry["unban"]: | ||||
|                 if "unban" in json_entry and str(account_id) in json_entry["unban"]: | ||||
|                     login_part_1() | ||||
|                     info("\nGO TO example.com TO PROCEED or wait 1200 secs.") | ||||
|                     for _ in range(1200): | ||||
|   | ||||
							
								
								
									
										13
									
								
								clean.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										13
									
								
								clean.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| docker-do () { # Check if sudo needs to be used | ||||
|     if id -nG "$(whoami)" | grep -qw "docker"; then | ||||
|         docker $@ | ||||
|     else | ||||
|         sudo docker $@ | ||||
|     fi | ||||
| } | ||||
|  | ||||
| docker-do stop MsRewards | ||||
| docker-do rm MsRewards | ||||
| docker-do image rm msrewards | ||||
| @@ -46,6 +46,7 @@ server { | ||||
|         proxy_pass         "http://127.0.0.1:6666"; | ||||
|         chunked_transfer_encoding off; | ||||
|         proxy_buffering off; | ||||
|         set_header X-Accel-Buffering no; | ||||
|     } | ||||
|      | ||||
| } | ||||
| @@ -59,7 +60,6 @@ sqlite3 /app/MsRewards-Reborn/MsRewards.db "CREATE TABLE comptes (id INTEGER PRI | ||||
| printf  "\nconfigurating grafana\n" | ||||
|  | ||||
| cp /app/MsRewards-Reborn/config/grafana.ini /etc/grafana/ | ||||
| grafana-cli plugins install frser-sqlite-datasource | ||||
|  | ||||
| printf  "setting up default dashboard" | ||||
| cp /app/MsRewards-Reborn/config/Stats-dashbord.json /usr/share/grafana/public/dashboards/home.json  | ||||
|   | ||||
							
								
								
									
										1459
									
								
								config/grafana.ini
									
									
									
									
									
								
							
							
						
						
									
										1459
									
								
								config/grafana.ini
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -50,9 +50,14 @@ class Config: | ||||
|         """ | ||||
|         self.discord = DiscordConfig() | ||||
|         self.discord.avatar_url = settings["avatarlink"] | ||||
|         self.discord.wh_link = discord[config[args.config]["discord"]]["errorsL"] | ||||
|  | ||||
|         if self.discord.wh_link != "": | ||||
|         if ( | ||||
|             "discord" in config[args.config] | ||||
|             and config[args.config]["discord"] in discord | ||||
|             and "errorsL" in discord[config[args.config]["discord"]] | ||||
|             and discord[config[args.config]["discord"]]["errorsL"] != "" | ||||
|             ): | ||||
|             self.discord.wh_link = discord[config[args.config]["discord"]]["errorsL"] | ||||
|             self.discord.wh = Webhook.from_url(self.discord.wh_link, adapter=RequestsWebhookAdapter()) | ||||
|         else: | ||||
|             self.discord.wh = FakeWebHook() | ||||
|   | ||||
| @@ -9,6 +9,6 @@ class DiscordConfig: | ||||
|  | ||||
|  | ||||
| class FakeWebHook: | ||||
|     def send(self, *args): | ||||
|         debug(f"Used a webhook call without webhook url with {args}") | ||||
|     def send(self, *args, **kwargs): | ||||
|         debug(f"Used a webhook call without webhook url with {args} {kwargs}") | ||||
|          | ||||
|   | ||||
| @@ -30,7 +30,8 @@ class UserCredentials: | ||||
|  | ||||
|     def get_tfa(self): | ||||
|         if not self.tfa_enable(): | ||||
|             warning("Warning: TFA is not enabled. Calling get_tfa is an expected behaviour.") | ||||
|             warning("Warning: TFA is not enabled. Can't get a TFA code.") | ||||
|             return None | ||||
|         return TOTP(self.data[self.current]["2fa"]) | ||||
|  | ||||
|     def next_account(self): | ||||
| @@ -41,4 +42,5 @@ class UserCredentials: | ||||
|             debug("No new credentials.") | ||||
|  | ||||
|     def is_valid(self): | ||||
|         return self.current < self.total | ||||
|         return (self.current < self.total | ||||
|                 and self.get_mail() != "" and self.get_mail is not None) | ||||
|   | ||||
| @@ -1,3 +1,5 @@ | ||||
| import os | ||||
| import json | ||||
| from random import uniform | ||||
|  | ||||
| from selenium.common import TimeoutException | ||||
| @@ -10,33 +12,36 @@ from modules.Tools.logger import debug | ||||
| from modules.Tools.tools import * | ||||
|  | ||||
|  | ||||
| def set_language(ldriver): | ||||
|     ldriver.get("chrome://settings/languages") | ||||
|     action = ActionChains(ldriver) | ||||
|     action.reset_actions() | ||||
|     # select language | ||||
|     x_coord = 1200 | ||||
|     y_coord = 150 | ||||
|     action.move_by_offset(x_coord, y_coord).click().perform() | ||||
|     sleep(0.5) | ||||
|     # scroll down | ||||
|     action.reset_actions() | ||||
|     elm = ldriver.find_element(By.XPATH, "/html/body") | ||||
|     ActionChains(ldriver) \ | ||||
|         .send_keys("french") \ | ||||
|         .pause(0.5) \ | ||||
|         .send_keys(Keys.TAB + Keys.TAB + Keys.ENTER + Keys.TAB + Keys.TAB + Keys.ENTER) \ | ||||
|         .perform() | ||||
|     x_coord = 1163 | ||||
|     y_coord = 717 | ||||
|     action.move_by_offset(x_coord, y_coord).click().perform() | ||||
|     # put to the top | ||||
|     sleep(0.5) | ||||
|     action.reset_actions() | ||||
|     x_coord = 1257 | ||||
|     y_coord = 328 | ||||
|     action.move_by_offset(x_coord, y_coord).click().perform() | ||||
|     action.click().perform() | ||||
| def init_profile(mail): | ||||
|     chrome_profile_dir = "/app/MsRewards-Reborn/user_data/profile/"+mail | ||||
|     os.makedirs(chrome_profile_dir, exist_ok=True) | ||||
|  | ||||
|     preferences_file = os.path.join(chrome_profile_dir, "Default", "Preferences") | ||||
|     if not os.path.exists(preferences_file): | ||||
|         os.makedirs(os.path.join(chrome_profile_dir, "Default"), exist_ok=True) | ||||
|         with open(preferences_file, "w") as f: | ||||
|             json.dump( | ||||
|                 { | ||||
|                     "intl": { | ||||
|                         "accept_languages": "fr-FR,en-US,en", | ||||
|                         "selected_languages": "fr-FR,en-US,en" | ||||
|                     } | ||||
|                }, f | ||||
|             ) | ||||
|     else: | ||||
|         with open(preferences_file, "r") as f: | ||||
|             settings = json.load(f) | ||||
|          | ||||
|         if "intl" not in settings: | ||||
|             settings["intl"] = {} | ||||
|  | ||||
|         settings["intl"]["accept_languages"] = "fr-FR,en-US,en" | ||||
|         settings["intl"]["selected_languages"] = "fr-FR,en-US,en" | ||||
|  | ||||
|         with open(preferences_file, "w") as f: | ||||
|             json.dump(settings, f) | ||||
|  | ||||
|     return chrome_profile_dir | ||||
|  | ||||
|  | ||||
| # Deal with RGPD popup as well as some random popup like 'are you satisfied' one | ||||
| @@ -60,13 +65,18 @@ def send_keys_wait(element, keys: str) -> None: | ||||
|         element.send_keys(i) | ||||
|         sleep(uniform(0.1, 0.3)) | ||||
|  | ||||
| def send_wait_and_confirm(element, keys: str) -> None: | ||||
|     send_keys_wait(element, keys) | ||||
|     element.send_keys(Keys.ENTER) | ||||
|  | ||||
|  | ||||
| # Wait for the presence of the element identifier or [timeout]s | ||||
| def wait_until_visible(search_by: str, identifier: str, timeout: int = 20, browser=None) -> bool: | ||||
| def wait_until_visible(search_by: str, identifier: str, timeout: int = 20, browser=None, raise_error=True) -> bool: | ||||
|     try: | ||||
|         WebDriverWait(browser, timeout).until( | ||||
|             expected_conditions.visibility_of_element_located((search_by, identifier)), "element not found") | ||||
|         return True | ||||
|     except TimeoutException as e: | ||||
|         error(f"element {identifier} not found after {timeout}s") | ||||
|         if raise_error: | ||||
|             error(f"element {identifier} not found after {timeout}s") | ||||
|         return False | ||||
|   | ||||
		Reference in New Issue
	
	Block a user