Compare commits

..

No commits in common. "3eb193eca3d1f30064605b6c3030bdb73afdbf3d" and "db157771def588aa5b2791e31e3c416e54b86f34" have entirely different histories.

10 changed files with 1516 additions and 100 deletions

View File

@ -25,9 +25,6 @@ RUN curl -fsSL https://packages.redis.io/gpg | gpg --dearmor -o /usr/share/keyri
RUN apt update \ RUN apt update \
&& apt install -y redis grafana && apt install -y redis grafana
# Configure Grafana
RUN grafana-cli plugins install frser-sqlite-datasource
COPY requirements.txt /app/requirements.txt COPY requirements.txt /app/requirements.txt
RUN python3 -m pip install -r requirements.txt RUN python3 -m pip install -r requirements.txt

50
V6.py
View File

@ -9,7 +9,7 @@ from modules.db import add_to_database
from modules.driver_tools import * from modules.driver_tools import *
from modules.error import * from modules.error import *
from selenium.common.exceptions import NoSuchElementException import os
# create a webdriver # create a webdriver
def create_driver(mobile=False): def create_driver(mobile=False):
@ -24,7 +24,9 @@ def create_driver(mobile=False):
"Chrome/22 Mobile Safari/537.36" "Chrome/22 Mobile Safari/537.36"
) )
chrome_profile_dir = init_profile(config.UserCredentials.get_mail()) # Profile dir
chrome_profile_dir = "/app/MsRewards-Reborn/user_data/profile/"+config.UserCredentials.get_mail()
os.makedirs(chrome_profile_dir, exist_ok=True)
# Full list on https://github.com/GoogleChrome/chrome-launcher/blob/main/docs/chrome-flags-for-tools.md # Full list on https://github.com/GoogleChrome/chrome-launcher/blob/main/docs/chrome-flags-for-tools.md
arguments = [ arguments = [
@ -50,6 +52,7 @@ def create_driver(mobile=False):
chrome_options.add_argument(arg) chrome_options.add_argument(arg)
driver = uc.Chrome(options=chrome_options) driver = uc.Chrome(options=chrome_options)
set_language(driver)
return driver return driver
@ -380,35 +383,22 @@ def login_part_1():
driver = config.WebDriver.driver driver = config.WebDriver.driver
driver.get("https://login.live.com") driver.get("https://login.live.com")
wait_until_visible(By.ID, "i0116", browser=driver) wait_until_visible(By.ID, "i0116", browser=driver)
send_wait_and_confirm( mail_elem = driver.find_element(By.ID, "i0116")
driver.find_element(By.ID, "i0116"), send_keys_wait(mail_elem, config.UserCredentials.get_mail())
config.UserCredentials.get_mail() mail_elem.send_keys(Keys.ENTER)
)
wait_until_visible(By.ID, "i0118", browser=driver) wait_until_visible(By.ID, "i0118", browser=driver)
send_wait_and_confirm( pwd_elem = driver.find_element(By.ID, "i0118")
driver.find_element(By.ID, "i0118"), send_keys_wait(pwd_elem, config.UserCredentials.get_password())
config.UserCredentials.get_password() pwd_elem.send_keys(Keys.ENTER)
) custom_sleep(2)
# 2FA # 2FA
try: if "Entrez le code de sécurité" in driver.page_source:
if not wait_until_visible(By.ID, "idTxtBx_SAOTCC_OTC", browser=driver, timeout=5, raise_error=False): try:
custom_sleep(2) a2f_elem = driver.find_element(By.ID, "idTxtBx_SAOTCC_OTC")
return a2f_elem.send_keys(config.UserCredentials.get_tfa().now())
a2f_elem.send_keys(Keys.ENTER)
tfa = config.UserCredentials.get_tfa() except Exception as err:
if tfa is None: log_error(err)
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 # Accept all cookies question, and check if the account is locked
@ -709,7 +699,7 @@ def json_start(json_entry, cred: UserCredentials):
config.WebDriver.switch_to_driver("PC") config.WebDriver.switch_to_driver("PC")
driver = config.WebDriver.driver driver = config.WebDriver.driver
try: try:
if "unban" in json_entry and str(account_id) in json_entry["unban"]: if str(account_id) in json_entry["unban"]:
login_part_1() login_part_1()
info("\nGO TO example.com TO PROCEED or wait 1200 secs.") info("\nGO TO example.com TO PROCEED or wait 1200 secs.")
for _ in range(1200): for _ in range(1200):

View File

@ -1,13 +0,0 @@
#!/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

View File

@ -46,7 +46,6 @@ server {
proxy_pass "http://127.0.0.1:6666"; proxy_pass "http://127.0.0.1:6666";
chunked_transfer_encoding off; chunked_transfer_encoding off;
proxy_buffering off; proxy_buffering off;
set_header X-Accel-Buffering no;
} }
} }
@ -60,6 +59,7 @@ sqlite3 /app/MsRewards-Reborn/MsRewards.db "CREATE TABLE comptes (id INTEGER PRI
printf "\nconfigurating grafana\n" printf "\nconfigurating grafana\n"
cp /app/MsRewards-Reborn/config/grafana.ini /etc/grafana/ cp /app/MsRewards-Reborn/config/grafana.ini /etc/grafana/
grafana-cli plugins install frser-sqlite-datasource
printf "setting up default dashboard" printf "setting up default dashboard"
cp /app/MsRewards-Reborn/config/Stats-dashbord.json /usr/share/grafana/public/dashboards/home.json cp /app/MsRewards-Reborn/config/Stats-dashbord.json /usr/share/grafana/public/dashboards/home.json

File diff suppressed because it is too large Load Diff

View File

@ -50,14 +50,9 @@ class Config:
""" """
self.discord = DiscordConfig() self.discord = DiscordConfig()
self.discord.avatar_url = settings["avatarlink"] self.discord.avatar_url = settings["avatarlink"]
self.discord.wh_link = discord[config[args.config]["discord"]]["errorsL"]
if ( if self.discord.wh_link != "":
"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()) self.discord.wh = Webhook.from_url(self.discord.wh_link, adapter=RequestsWebhookAdapter())
else: else:
self.discord.wh = FakeWebHook() self.discord.wh = FakeWebHook()

View File

@ -9,6 +9,6 @@ class DiscordConfig:
class FakeWebHook: class FakeWebHook:
def send(self, *args, **kwargs): def send(self, *args):
debug(f"Used a webhook call without webhook url with {args} {kwargs}") debug(f"Used a webhook call without webhook url with {args}")

View File

@ -30,8 +30,7 @@ class UserCredentials:
def get_tfa(self): def get_tfa(self):
if not self.tfa_enable(): if not self.tfa_enable():
warning("Warning: TFA is not enabled. Can't get a TFA code.") warning("Warning: TFA is not enabled. Calling get_tfa is an expected behaviour.")
return None
return TOTP(self.data[self.current]["2fa"]) return TOTP(self.data[self.current]["2fa"])
def next_account(self): def next_account(self):
@ -42,5 +41,4 @@ class UserCredentials:
debug("No new credentials.") debug("No new credentials.")
def is_valid(self): 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)

View File

@ -1,5 +1,3 @@
import os
import json
from random import uniform from random import uniform
from selenium.common import TimeoutException from selenium.common import TimeoutException
@ -12,36 +10,33 @@ from modules.Tools.logger import debug
from modules.Tools.tools import * from modules.Tools.tools import *
def init_profile(mail): def set_language(ldriver):
chrome_profile_dir = "/app/MsRewards-Reborn/user_data/profile/"+mail ldriver.get("chrome://settings/languages")
os.makedirs(chrome_profile_dir, exist_ok=True) action = ActionChains(ldriver)
action.reset_actions()
preferences_file = os.path.join(chrome_profile_dir, "Default", "Preferences") # select language
if not os.path.exists(preferences_file): x_coord = 1200
os.makedirs(os.path.join(chrome_profile_dir, "Default"), exist_ok=True) y_coord = 150
with open(preferences_file, "w") as f: action.move_by_offset(x_coord, y_coord).click().perform()
json.dump( sleep(0.5)
{ # scroll down
"intl": { action.reset_actions()
"accept_languages": "fr-FR,en-US,en", elm = ldriver.find_element(By.XPATH, "/html/body")
"selected_languages": "fr-FR,en-US,en" ActionChains(ldriver) \
} .send_keys("french") \
}, f .pause(0.5) \
) .send_keys(Keys.TAB + Keys.TAB + Keys.ENTER + Keys.TAB + Keys.TAB + Keys.ENTER) \
else: .perform()
with open(preferences_file, "r") as f: x_coord = 1163
settings = json.load(f) y_coord = 717
action.move_by_offset(x_coord, y_coord).click().perform()
if "intl" not in settings: # put to the top
settings["intl"] = {} sleep(0.5)
action.reset_actions()
settings["intl"]["accept_languages"] = "fr-FR,en-US,en" x_coord = 1257
settings["intl"]["selected_languages"] = "fr-FR,en-US,en" y_coord = 328
action.move_by_offset(x_coord, y_coord).click().perform()
with open(preferences_file, "w") as f: action.click().perform()
json.dump(settings, f)
return chrome_profile_dir
# Deal with RGPD popup as well as some random popup like 'are you satisfied' one # Deal with RGPD popup as well as some random popup like 'are you satisfied' one
@ -65,18 +60,13 @@ def send_keys_wait(element, keys: str) -> None:
element.send_keys(i) element.send_keys(i)
sleep(uniform(0.1, 0.3)) 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 # 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, raise_error=True) -> bool: def wait_until_visible(search_by: str, identifier: str, timeout: int = 20, browser=None) -> bool:
try: try:
WebDriverWait(browser, timeout).until( WebDriverWait(browser, timeout).until(
expected_conditions.visibility_of_element_located((search_by, identifier)), "element not found") expected_conditions.visibility_of_element_located((search_by, identifier)), "element not found")
return True return True
except TimeoutException as e: except TimeoutException as e:
if raise_error: error(f"element {identifier} not found after {timeout}s")
error(f"element {identifier} not found after {timeout}s")
return False return False

View File

@ -1 +1 @@
v6.8.45 v6.8.43