Compare commits
17 Commits
fc8e666927
...
d4920ec322
Author | SHA1 | Date | |
---|---|---|---|
|
d4920ec322 | ||
|
31e38b7258 | ||
|
2cc1fcbc72 | ||
|
35c846e671 | ||
|
dc3e31d8d5 | ||
|
f1cce097ad | ||
|
da707ade5a | ||
|
6be44e829a | ||
|
76acfb42c4 | ||
|
a47a460a56 | ||
|
6de49e8874 | ||
|
b89d3036bb | ||
|
cf6905b169 | ||
|
962c2eab86 | ||
|
26c4869830 | ||
|
2e0f148d0c | ||
|
f0acd9e2f2 |
512
V6.py
512
V6.py
@ -5,21 +5,26 @@ from modules.driver_tools import *
|
|||||||
from modules.cards import *
|
from modules.cards import *
|
||||||
import modules.globals as g
|
import modules.globals as g
|
||||||
|
|
||||||
|
from modules.Classes.Config import Config
|
||||||
|
from modules.Classes.UserCredentials import UserCredentials
|
||||||
|
from modules.Tools.logger import warning, info, debug, error, critical
|
||||||
|
|
||||||
|
|
||||||
driver = g.driver
|
driver = g.driver
|
||||||
display = g.display
|
display = g.display
|
||||||
|
|
||||||
|
|
||||||
# create a webdriver
|
# create a webdriver
|
||||||
def create_driver(mobile=False, headless=False):
|
def create_driver(mobile=False):
|
||||||
PC_USER_AGENT = (
|
PC_USER_AGENT = (
|
||||||
"Mozilla/5.0 (X11; Linux x86_64)"
|
"Mozilla/5.0 (X11; Linux x86_64)"
|
||||||
"AppleWebKit/537.36 (KHTML, like Gecko)"
|
"AppleWebKit/537.36 (KHTML, like Gecko)"
|
||||||
"Chrome/118.0.0.0 Safari/537.36 Edg/118.0.2088.46"
|
"Chrome/122.0.0.0 Safari/537.36 Edg/122.0.2088.46"
|
||||||
)
|
)
|
||||||
MOBILE_USER_AGENT = (
|
MOBILE_USER_AGENT = (
|
||||||
"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N)"
|
"Mozilla/5.0 (Linux; Android 7.0; Nexus 5 Build/MRA58N)"
|
||||||
"AppleWebKit/537.36 (KHTML, like Gecko)"
|
"AppleWebKit/537.36 (KHTML, like Gecko)"
|
||||||
"Chrome/%s Mobile Safari/537.36"
|
"Chrome/22 Mobile Safari/537.36"
|
||||||
)
|
)
|
||||||
chrome_options = webdriver.ChromeOptions()
|
chrome_options = webdriver.ChromeOptions()
|
||||||
if mobile:
|
if mobile:
|
||||||
@ -28,20 +33,20 @@ def create_driver(mobile=False, headless=False):
|
|||||||
chrome_options.add_argument(f"--user-agent={PC_USER_AGENT}")
|
chrome_options.add_argument(f"--user-agent={PC_USER_AGENT}")
|
||||||
# disabled as it may cause detection
|
# disabled as it may cause detection
|
||||||
if g.proxy_enabled:
|
if g.proxy_enabled:
|
||||||
PROXY = f"{g.proxy_address}:{g.proxy_port}" # IP:PORT or HOST:PORT
|
chrome_options.add_argument(f'--proxy-server={g.proxy_address}:{g.proxy_port}')
|
||||||
chrome_options.add_argument(f'--proxy-server={PROXY}')
|
|
||||||
driver = uc.Chrome(options=chrome_options)
|
driver = uc.Chrome(options=chrome_options)
|
||||||
set_language(driver)
|
set_language(driver)
|
||||||
return (driver)
|
return driver
|
||||||
|
|
||||||
|
|
||||||
def log_error(error, l_driver=driver, log=g.full_log):
|
def log_error(error_message, l_driver=driver, log=g.full_log):
|
||||||
global driver
|
global driver
|
||||||
if l_driver is None:
|
if l_driver is None:
|
||||||
l_driver = driver
|
l_driver = driver
|
||||||
if type(error) is not str:
|
if type(error_message) is not str:
|
||||||
error = format_error(error)
|
error_message = format_error(error_message)
|
||||||
printf(f"\n\n\033[93m Erreur : {str(error)} \033[0m\n\n")
|
|
||||||
|
error(str(error_message))
|
||||||
if g.discord_enabled_error:
|
if g.discord_enabled_error:
|
||||||
with open("page.html", "w") as f:
|
with open("page.html", "w") as f:
|
||||||
try:
|
try:
|
||||||
@ -56,13 +61,13 @@ def log_error(error, l_driver=driver, log=g.full_log):
|
|||||||
if not log:
|
if not log:
|
||||||
embed = Embed(
|
embed = Embed(
|
||||||
title="An Error has occured",
|
title="An Error has occured",
|
||||||
description=str(error),
|
description=str(error_message),
|
||||||
colour=Colour.red(),
|
colour=Colour.red(),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
embed = Embed(
|
embed = Embed(
|
||||||
title="Full log is enabled",
|
title="Full log is enabled",
|
||||||
description=str(error),
|
description=str(error_message),
|
||||||
colour=Colour.blue(),
|
colour=Colour.blue(),
|
||||||
)
|
)
|
||||||
file = File("screenshot.png")
|
file = File("screenshot.png")
|
||||||
@ -73,21 +78,20 @@ def log_error(error, l_driver=driver, log=g.full_log):
|
|||||||
|
|
||||||
|
|
||||||
# close the tab currently on and go back to the one first, or the one specified
|
# close the tab currently on and go back to the one first, or the one specified
|
||||||
def close_tab(tab, SwitchTo=0) -> None:
|
def close_tab(tab, switch_to: int = 0) -> None:
|
||||||
driver.switch_to.window(tab)
|
driver.switch_to.window(tab)
|
||||||
driver.close()
|
driver.close()
|
||||||
driver.switch_to.window(driver.window_handles[SwitchTo])
|
driver.switch_to.window(driver.window_handles[switch_to])
|
||||||
|
|
||||||
|
|
||||||
# play_quiz[N]([int : override]) make the quiz with N choice each time. They usually have between 4 and 10 questions.
|
# play_quiz[N]([int : override]) make the quiz with N choice each time. They usually have between 4 and 10 questions.
|
||||||
# override is the number of question, by default, it's the number of question in this specific quiz. Can be useful in some case, where the program crashes before finishing the quiz
|
# override is the number of question, by default, it's the number of question in this specific quiz.
|
||||||
|
# Can be useful in some case, where the program crashes before finishing the quiz
|
||||||
def play_quiz2(override=10) -> None:
|
def play_quiz2(override=10) -> None:
|
||||||
printf("starting play_quiz2")
|
info("Starting to play quiz 2.")
|
||||||
|
debug(f"override: {override}")
|
||||||
for j in range(override):
|
for j in range(override):
|
||||||
try:
|
|
||||||
# rgpd_popup(driver)
|
|
||||||
custom_sleep(uniform(3, 5))
|
custom_sleep(uniform(3, 5))
|
||||||
|
|
||||||
js_function = """
|
js_function = """
|
||||||
function get_correct_answer(){
|
function get_correct_answer(){
|
||||||
function br(n) { for (var r, t = 0, i = 0; i < n.length; i++)t += n.charCodeAt(i); return r = parseInt(_G.IG.substr(_G.IG.length - 2), 16), t += r, t.toString() } // Ms check function
|
function br(n) { for (var r, t = 0, i = 0; i < n.length; i++)t += n.charCodeAt(i); return r = parseInt(_G.IG.substr(_G.IG.length - 2), 16), t += r, t.toString() } // Ms check function
|
||||||
@ -104,42 +108,38 @@ def play_quiz2(override=10) -> None:
|
|||||||
return(get_correct_answer())
|
return(get_correct_answer())
|
||||||
"""
|
"""
|
||||||
correct_answer_value = driver.execute_script(js_function)
|
correct_answer_value = driver.execute_script(js_function)
|
||||||
|
try:
|
||||||
answer_elem = driver.find_element(By.ID, f"rqAnswerOption{correct_answer_value}")
|
answer_elem = driver.find_element(By.ID, f"rqAnswerOption{correct_answer_value}")
|
||||||
answer_elem.click()
|
answer_elem.click()
|
||||||
if g.log:
|
except exceptions.ElementNotInteractableException:
|
||||||
progressBar(j, 10, name="quiz 2")
|
answer_elem = driver.find_element(By.ID, f"rqAnswerOption{correct_answer_value}")
|
||||||
|
|
||||||
except exceptions.ElementNotInteractableException as e:
|
|
||||||
driver.execute_script("arguments[0].click();", answer_elem)
|
driver.execute_script("arguments[0].click();", answer_elem)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log_error(e)
|
log_error(e)
|
||||||
break
|
break
|
||||||
printf("play_quiz2 done")
|
info("Quiz 2 done.")
|
||||||
custom_sleep(3)
|
custom_sleep(3)
|
||||||
|
|
||||||
|
|
||||||
def play_quiz8():
|
def play_quiz8():
|
||||||
|
info(f"Starting Quiz 8")
|
||||||
override = len(findall("<span id=\"rqQuestionState.\" class=\"emptyCircle\"></span>", driver.page_source)) + 1
|
override = len(findall("<span id=\"rqQuestionState.\" class=\"emptyCircle\"></span>", driver.page_source)) + 1
|
||||||
printf(f"play_quiz8 : start, override : {override}")
|
debug(f"override : {override}")
|
||||||
|
correct_answers = ["Should", "be", "reset", "before", "you", "see", "this."] # supress warning
|
||||||
try:
|
try:
|
||||||
counter = 0
|
|
||||||
# rgpd_popup(driver)
|
|
||||||
for _ in range(override):
|
for _ in range(override):
|
||||||
sleep(uniform(3, 5))
|
sleep(uniform(3, 5))
|
||||||
correct_answers = []
|
correct_answers = []
|
||||||
for i in range(1, 9):
|
for i in range(1, 9): # todo: remove this odd 1-offset
|
||||||
try:
|
try:
|
||||||
element = driver.find_element(By.ID, f"rqAnswerOption{i - 1}")
|
element = driver.find_element(By.ID, f"rqAnswerOption{i - 1}")
|
||||||
if 'iscorrectoption="True"' in element.get_attribute("outerHTML"):
|
if 'iscorrectoption="True"' in element.get_attribute("outerHTML"):
|
||||||
correct_answers.append(f'rqAnswerOption{i - 1}')
|
correct_answers.append(f'rqAnswerOption{i - 1}')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
printf(f"can't find rqAnswerOption{i - 1}. Probably already clicked" + str(e))
|
warning(f"can't find rqAnswerOption{i - 1}. Probably already clicked" + str(e))
|
||||||
shuffle(correct_answers)
|
shuffle(correct_answers)
|
||||||
for answer_id in correct_answers:
|
for answer_id in correct_answers:
|
||||||
wait_until_visible(By.ID, answer_id, timeout=20, browser=driver)
|
wait_until_visible(By.ID, answer_id, timeout=20, browser=driver)
|
||||||
counter += 1
|
|
||||||
if g.log:
|
|
||||||
progressBar(counter, 16, name="Quiz 8")
|
|
||||||
try:
|
try:
|
||||||
answer_elem = driver.find_element(By.ID, answer_id)
|
answer_elem = driver.find_element(By.ID, answer_id)
|
||||||
answer_elem.click()
|
answer_elem.click()
|
||||||
@ -155,27 +155,28 @@ def play_quiz8():
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log_error(f"{format_error(e)} \n Good answers : {' '.join(correct_answers)}")
|
log_error(f"{format_error(e)} \n Good answers : {' '.join(correct_answers)}")
|
||||||
|
info("Quiz 8 done.")
|
||||||
custom_sleep(3)
|
custom_sleep(3)
|
||||||
|
|
||||||
|
|
||||||
def play_quiz4(override: int = None):
|
def play_quiz4(override: int = None):
|
||||||
printf("play_quiz4 : start")
|
info(f"Starting Quiz 4")
|
||||||
|
|
||||||
if not override:
|
if not override:
|
||||||
try: # fidelity quiz are much longer than usual ones
|
try: # fidelity quiz are much longer than usual ones
|
||||||
override = int(findall('rqQuestionState([\d]{1,2})"', driver.page_source)[-1])
|
override = int(findall('rqQuestionState([\d]{1,2})"', driver.page_source)[-1])
|
||||||
printf(f"Override : {override}")
|
|
||||||
except:
|
except:
|
||||||
override = 3
|
override = 3
|
||||||
|
debug(f"Override : {override}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for i in range(override):
|
for i in range(override):
|
||||||
custom_sleep(uniform(3, 5))
|
custom_sleep(uniform(3, 5))
|
||||||
txt = driver.page_source
|
txt = driver.page_source
|
||||||
# rgpd_popup(driver)
|
|
||||||
answer_option = search('correctAnswer":"([^"]+)', txt)[1]
|
answer_option = search('correctAnswer":"([^"]+)', txt)[1]
|
||||||
answer_option = answer_option.replace("\\u0027", "'") # replace Unicode weird symbols
|
answer_option = answer_option.replace("\\u0027", "'") # replace Unicode weird symbols
|
||||||
try:
|
|
||||||
answer_element = driver.find_element(By.CSS_SELECTOR, f'[data-option="{answer_option}"]')
|
answer_element = driver.find_element(By.CSS_SELECTOR, f'[data-option="{answer_option}"]')
|
||||||
|
try:
|
||||||
answer_element.click()
|
answer_element.click()
|
||||||
except exceptions.ElementNotInteractableException:
|
except exceptions.ElementNotInteractableException:
|
||||||
driver.execute_script("arguments[0].click();", answer_element)
|
driver.execute_script("arguments[0].click();", answer_element)
|
||||||
@ -183,27 +184,30 @@ def play_quiz4(override: int = None):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
log_error(e)
|
log_error(e)
|
||||||
raise ValueError(e)
|
raise ValueError(e)
|
||||||
|
info("Quiz 8 done.")
|
||||||
custom_sleep(3)
|
custom_sleep(3)
|
||||||
|
|
||||||
|
|
||||||
# do_poll() answer a random thing to poll, on of daily activities
|
# do_poll() answer a random thing to poll, on of daily activities
|
||||||
def do_poll():
|
def do_poll():
|
||||||
printf("do_poll : start")
|
info("Starting poll")
|
||||||
try:
|
|
||||||
try:
|
try:
|
||||||
answer_elem = driver.find_element(By.ID, f"btoption{choice([0, 1])}")
|
answer_elem = driver.find_element(By.ID, f"btoption{choice([0, 1])}")
|
||||||
|
try:
|
||||||
answer_elem.click()
|
answer_elem.click()
|
||||||
except exceptions.ElementNotInteractableException:
|
except exceptions.ElementNotInteractableException:
|
||||||
driver.execute_script("arguments[0].click();", answer_elem)
|
driver.execute_script("arguments[0].click();", answer_elem)
|
||||||
custom_sleep(uniform(2, 2.5))
|
custom_sleep(uniform(2, 2.5))
|
||||||
except Exception as error:
|
except Exception as err:
|
||||||
log_error(error)
|
log_error(err)
|
||||||
raise ValueError(error)
|
raise ValueError(err)
|
||||||
|
info("Poll done.")
|
||||||
custom_sleep(3)
|
custom_sleep(3)
|
||||||
|
|
||||||
|
|
||||||
|
# Find each playable card and tries to click on it to earn points
|
||||||
|
# todo : refactor
|
||||||
def all_cards():
|
def all_cards():
|
||||||
# input("1")
|
|
||||||
driver.get("https://rewards.bing.com")
|
driver.get("https://rewards.bing.com")
|
||||||
wait_until_visible(By.CLASS_NAME, "c-card-content", 10, driver)
|
wait_until_visible(By.CLASS_NAME, "c-card-content", 10, driver)
|
||||||
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
|
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
|
||||||
@ -211,7 +215,7 @@ def all_cards():
|
|||||||
try:
|
try:
|
||||||
promo()
|
promo()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
printf("no promo card")
|
info("no promo card")
|
||||||
if (len(liste) < 10): # most likely an error during loading
|
if (len(liste) < 10): # most likely an error during loading
|
||||||
if "suspendu" in driver.page_source:
|
if "suspendu" in driver.page_source:
|
||||||
raise Banned()
|
raise Banned()
|
||||||
@ -324,7 +328,7 @@ def promo():
|
|||||||
try:
|
try:
|
||||||
spotify(driver)
|
spotify(driver)
|
||||||
except:
|
except:
|
||||||
printf("no new windows", driver)
|
warning("no new windows")
|
||||||
driver.get("https://rewards.bing.com")
|
driver.get("https://rewards.bing.com")
|
||||||
driver.refresh()
|
driver.refresh()
|
||||||
custom_sleep(3)
|
custom_sleep(3)
|
||||||
@ -335,33 +339,30 @@ def try_play(nom="inconnu"):
|
|||||||
rgpd_popup(driver)
|
rgpd_popup(driver)
|
||||||
|
|
||||||
def play(number):
|
def play(number):
|
||||||
if number == 8 or number == 9:
|
if number in [8, 9]:
|
||||||
try:
|
try:
|
||||||
printf(f"\033[96mQuiz 8 detected on `{nom}` \033[0m")
|
debug(f"Quiz 8 detected on `{nom}`.")
|
||||||
play_quiz8()
|
play_quiz8()
|
||||||
printf(f"\033[92mQuiz 8 succeeded on `{nom}` \033[0m")
|
except Exception as err:
|
||||||
custom_sleep(uniform(3, 5))
|
error(f"fail of PlayQuiz 8. Aborted {err}")
|
||||||
except Exception as e:
|
|
||||||
printf(f"fail of PlayQuiz 8. Aborted {e} \033[0m")
|
|
||||||
|
|
||||||
elif number == 5 or number == 4:
|
elif number in [4, 5]:
|
||||||
try:
|
try:
|
||||||
printf(f"\033[96mQuiz 4 detected on `{nom}` \033[0m")
|
debug(f"Quiz 4 detected on `{nom}`")
|
||||||
play_quiz4()
|
play_quiz4()
|
||||||
printf(f"\033[92mQuiz 4 succeeded on `{nom}` \033[0m")
|
except Exception as err:
|
||||||
custom_sleep(uniform(3, 5))
|
error(f"Fail of PlayQuiz 4. Aborted {err}.")
|
||||||
except Exception as e:
|
|
||||||
printf(f"Fail of PlayQuiz 4. Aborted {e} \033[0m")
|
|
||||||
|
|
||||||
elif number == 3 or number == 2:
|
elif number in [2, 3]:
|
||||||
try:
|
try:
|
||||||
printf(f"\033[96mQuiz 2 detected on `{nom}`\033[0m")
|
debug(f"\033[96mQuiz 2 detected on `{nom}`\033[0m")
|
||||||
play_quiz2()
|
play_quiz2()
|
||||||
printf(f"\033[92mQuiz 2 succeeded on `{nom}`\033[0m")
|
except Exception as err:
|
||||||
except Exception as e:
|
error(f"fail of PlayQuiz 2. Aborted {err}")
|
||||||
printf(f"fail of PlayQuiz 2. Aborted {e}")
|
|
||||||
else:
|
else:
|
||||||
printf("There is an error. rqAnswerOption present in page but no action to do. skipping.")
|
error("`rqAnswerOption` present in page but no action to do.")
|
||||||
|
|
||||||
|
custom_sleep(uniform(3, 5))
|
||||||
|
|
||||||
if "pas connecté à Microsoft Rewards" in driver.page_source:
|
if "pas connecté à Microsoft Rewards" in driver.page_source:
|
||||||
custom_sleep(5)
|
custom_sleep(5)
|
||||||
@ -369,57 +370,44 @@ def try_play(nom="inconnu"):
|
|||||||
custom_sleep(5)
|
custom_sleep(5)
|
||||||
rgpd_popup(driver)
|
rgpd_popup(driver)
|
||||||
custom_sleep(5)
|
custom_sleep(5)
|
||||||
printf("not connected, fixed")
|
debug("Detected and fixed connection popup")
|
||||||
if "legaltextbox" in driver.current_url:
|
|
||||||
log_error("dev1")
|
if "bt_PollRadio" in driver.page_source:
|
||||||
driver.find_element(By.CLASS_NAME, "actionLink").click()
|
debug("Poll detected")
|
||||||
log_error("dev2")
|
do_poll()
|
||||||
try:
|
|
||||||
if wait_until_visible(By.ID, "rqStartQuiz", 5, driver):
|
elif "rqQuestionState" in driver.page_source:
|
||||||
|
number = driver.page_source.count("rqAnswerOption")
|
||||||
|
warning(f"recovery détecté. quiz : {number}")
|
||||||
|
play(number - 1)
|
||||||
|
|
||||||
|
elif search("([0-9]) de ([0-9]) finalisée", driver.page_source):
|
||||||
|
info("On fidelity page.")
|
||||||
|
fidelity()
|
||||||
|
|
||||||
|
elif wait_until_visible(By.ID, "rqStartQuiz", 5, driver):
|
||||||
custom_sleep(3)
|
custom_sleep(3)
|
||||||
driver.find_element(By.ID, "rqStartQuiz").click() # start the quiz
|
driver.find_element(By.ID, "rqStartQuiz").click() # start the quiz
|
||||||
answer_number = driver.page_source.count("rqAnswerOption")
|
answer_number = driver.page_source.count("rqAnswerOption")
|
||||||
play(answer_number)
|
play(answer_number)
|
||||||
else:
|
|
||||||
raise (NameError("going to next part"))
|
|
||||||
except Exception as e: # if there is no start button, an error is thrown
|
|
||||||
if "bt_PollRadio" in driver.page_source:
|
|
||||||
try:
|
|
||||||
printf("Poll detected")
|
|
||||||
do_poll()
|
|
||||||
printf("Poll succeeded")
|
|
||||||
except Exception as e:
|
|
||||||
printf(f"try_play - 1 - Poll aborted {e}")
|
|
||||||
|
|
||||||
elif "rqQuestionState" in driver.page_source:
|
|
||||||
try:
|
|
||||||
number = driver.page_source.count("rqAnswerOption")
|
|
||||||
printf(f"recovery détecté. quiz : {number}")
|
|
||||||
play(number - 1)
|
|
||||||
except Exception as e:
|
|
||||||
printf(f"try_play - 2 - {e}")
|
|
||||||
|
|
||||||
elif search("([0-9]) de ([0-9]) finalisée", driver.page_source):
|
|
||||||
printf("fidélité")
|
|
||||||
fidelity()
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
printf(f"rien à faire sur la page {nom}")
|
printf(f"Nothing to do on page `{nom}`")
|
||||||
custom_sleep(uniform(3, 5))
|
custom_sleep(uniform(3, 5))
|
||||||
|
|
||||||
|
|
||||||
# Login with password or with cookies.
|
# Login with password or with cookies.
|
||||||
# The driver should be in the same state on both case
|
# The driver should be in the same state on both case
|
||||||
def pwd_login(ldriver):
|
def login_part_1(ldriver, cred: UserCredentials):
|
||||||
printf("pwd_login : start")
|
printf("pwd_login : start")
|
||||||
ldriver.get("https://login.live.com")
|
ldriver.get("https://login.live.com")
|
||||||
wait_until_visible(By.ID, "i0116", browser=ldriver)
|
wait_until_visible(By.ID, "i0116", browser=ldriver)
|
||||||
mail_elem = ldriver.find_element(By.ID, "i0116")
|
mail_elem = ldriver.find_element(By.ID, "i0116")
|
||||||
send_keys_wait(mail_elem, g._mail)
|
send_keys_wait(mail_elem, cred.get_mail())
|
||||||
mail_elem.send_keys(Keys.ENTER)
|
mail_elem.send_keys(Keys.ENTER)
|
||||||
wait_until_visible(By.ID, "i0118", browser=ldriver)
|
wait_until_visible(By.ID, "i0118", browser=ldriver)
|
||||||
pwd_elem = ldriver.find_element(By.ID, "i0118")
|
pwd_elem = ldriver.find_element(By.ID, "i0118")
|
||||||
send_keys_wait(pwd_elem, g._password)
|
send_keys_wait(pwd_elem, cred.get_password())
|
||||||
pwd_elem.send_keys(Keys.ENTER)
|
pwd_elem.send_keys(Keys.ENTER)
|
||||||
custom_sleep(2)
|
custom_sleep(2)
|
||||||
# 2FA
|
# 2FA
|
||||||
@ -432,71 +420,55 @@ def pwd_login(ldriver):
|
|||||||
log_error(e)
|
log_error(e)
|
||||||
|
|
||||||
|
|
||||||
def cookie_login(ldriver):
|
|
||||||
printf("cookies_login : start")
|
|
||||||
ldriver.get("https://login.live.com")
|
|
||||||
try:
|
|
||||||
load_cookies(ldriver)
|
|
||||||
except FileNotFoundError:
|
|
||||||
printf("No cookies file Found.")
|
|
||||||
return (False)
|
|
||||||
except Exception as e:
|
|
||||||
# log_error(f"Error performing cookies login. Trying with password instead. \n{str(e)}", driver)
|
|
||||||
print("error with cookies login. IDK why (yet)")
|
|
||||||
return (False)
|
|
||||||
try:
|
|
||||||
ldriver.refresh()
|
|
||||||
except Exception as e:
|
|
||||||
printf(format_error(e))
|
|
||||||
printf("FIX YOUR SITE MS.......")
|
|
||||||
|
|
||||||
return (True)
|
|
||||||
|
|
||||||
|
|
||||||
# Accept all cookies question, and check if the account is locked
|
# Accept all cookies question, and check if the account is locked
|
||||||
def login_part_2(ldriver, cookies=False):
|
def login_part_2(ldriver):
|
||||||
custom_sleep(5)
|
custom_sleep(5)
|
||||||
if ('Abuse' in ldriver.current_url):
|
|
||||||
|
if 'Abuse' in ldriver.current_url:
|
||||||
raise Banned()
|
raise Banned()
|
||||||
if ('identity' in ldriver.current_url):
|
|
||||||
|
if 'identity' in ldriver.current_url:
|
||||||
raise Identity()
|
raise Identity()
|
||||||
if ('notice' in ldriver.current_url):
|
|
||||||
|
if 'notice' in ldriver.current_url:
|
||||||
ldriver.find_element(By.ID, "id__0").click()
|
ldriver.find_element(By.ID, "id__0").click()
|
||||||
if ("proof" in ldriver.current_url):
|
|
||||||
|
if "proof" in ldriver.current_url:
|
||||||
ldriver.find_element(By.ID, "iLooksGood")
|
ldriver.find_element(By.ID, "iLooksGood")
|
||||||
if cookies:
|
|
||||||
save_cookies(ldriver)
|
for elm_id in ["iNext", "KmsiCheckboxField", "id__0", "iLooksGood", "idSIButton9", "iCancel"]:
|
||||||
for id in ["iNext", "KmsiCheckboxField", "id__0", "iLooksGood", "idSIButton9", "iCancel"]:
|
|
||||||
if get_domain(ldriver) == "account.microsoft.com":
|
if get_domain(ldriver) == "account.microsoft.com":
|
||||||
break
|
break
|
||||||
try:
|
try:
|
||||||
ldriver.find_element(By.ID, id).click()
|
ldriver.find_element(By.ID, elm_id).click()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
wait_until_visible(By.CSS_SELECTOR, '[data-bi-id="sh-sharedshell-home"]', 20, ldriver)
|
wait_until_visible(By.CSS_SELECTOR, '[data-bi-id="sh-sharedshell-home"]', 20, ldriver)
|
||||||
|
|
||||||
|
|
||||||
# login() tries to login to your Microsoft account.
|
# login() tries to login to your Microsoft account.
|
||||||
# it uses global variable g._mail and g._password to login
|
# it uses global variable g._mail and g._password to login
|
||||||
def login(ldriver):
|
def login(ldriver, cred: UserCredentials):
|
||||||
try:
|
try:
|
||||||
pwd_login(ldriver)
|
login_part_1(ldriver, cred)
|
||||||
login_part_2(ldriver, 0)
|
login_part_2(ldriver)
|
||||||
ldriver.get("https://rewards.bing.com/")
|
ldriver.get("https://rewards.bing.com/")
|
||||||
except Banned:
|
except Banned:
|
||||||
raise Banned()
|
raise Banned()
|
||||||
except Identity:
|
except Identity:
|
||||||
raise Banned()
|
raise Banned()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
critical("Error not caught during login.")
|
||||||
log_error(e)
|
log_error(e)
|
||||||
ldriver.quit()
|
ldriver.quit()
|
||||||
return (False)
|
return False
|
||||||
|
|
||||||
|
|
||||||
# Makes 30 search as PC Edge
|
# Makes 30 search as PC Edge
|
||||||
def bing_pc_search(override=randint(35, 40)):
|
def bing_pc_search(override=randint(35, 40)):
|
||||||
mot = choice(Liste_de_mot).replace(" ", "+")
|
mot = choice(Liste_de_mot).replace(" ", "+")
|
||||||
driver.get(f"https://www.bing.com/search?q={mot}") # {choice(Liste_de_mot)}')
|
driver.get(f"https://www.bing.com/search?q={mot}")
|
||||||
custom_sleep(uniform(1, 2))
|
custom_sleep(uniform(1, 2))
|
||||||
rgpd_popup(driver)
|
rgpd_popup(driver)
|
||||||
send_keys_wait(
|
send_keys_wait(
|
||||||
@ -510,7 +482,7 @@ def bing_pc_search(override=randint(35, 40)):
|
|||||||
send_keys_wait(driver.find_element(By.ID, "sb_form_q"), word)
|
send_keys_wait(driver.find_element(By.ID, "sb_form_q"), word)
|
||||||
driver.find_element(By.ID, "sb_form_q").send_keys(Keys.ENTER)
|
driver.find_element(By.ID, "sb_form_q").send_keys(Keys.ENTER)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
printf(e)
|
error(e)
|
||||||
sleep(10)
|
sleep(10)
|
||||||
driver.get(f'https://www.bing.com/search?q={word}')
|
driver.get(f'https://www.bing.com/search?q={word}')
|
||||||
sleep(3)
|
sleep(3)
|
||||||
@ -520,82 +492,32 @@ def bing_pc_search(override=randint(35, 40)):
|
|||||||
try:
|
try:
|
||||||
driver.find_element(By.ID, "sb_form_q").clear()
|
driver.find_element(By.ID, "sb_form_q").clear()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
printf(e)
|
error(e)
|
||||||
try:
|
try:
|
||||||
driver.get('https://www.bing.com/search?q=plans')
|
driver.get('https://www.bing.com/search?q=plans')
|
||||||
driver.find_element(By.ID, "sb_form_q").clear()
|
driver.find_element(By.ID, "sb_form_q").clear()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log_error(f"clear la barre de recherche - {format_error(e)}")
|
log_error(f"clear la barre de recherche - {format_error(e)}") # what is this message ??? todo
|
||||||
|
|
||||||
|
|
||||||
# Unban an account, called with -u parameter. You will need a phone number
|
|
||||||
def unban() -> None:
|
|
||||||
driver.find_element(By.ID, "StartAction").click()
|
|
||||||
custom_sleep(2)
|
|
||||||
txt = driver.page_source
|
|
||||||
uuid0 = findall('wlspispHIPCountrySelect([a-z0-9]+)', txt)[0]
|
|
||||||
uuid1 = findall('wlspispHIPPhoneInput([a-z0-9]+)', txt)[0]
|
|
||||||
uuid2 = findall('wlspispHipSendCode([a-z0-9]+)', txt)[0]
|
|
||||||
uuid3 = findall('wlspispSolutionElement([a-z0-9]+)', txt)[0]
|
|
||||||
country_code_select = Select(driver.find_element(By.ID, "wlspispHIPCountrySelect" + uuid0))
|
|
||||||
country_code_input = input("enter Country code (FR, ...) ")
|
|
||||||
country_code_select.select_by_value(country_code_input)
|
|
||||||
wait_until_visible(By.ID, "wlspispHIPPhoneInput" + uuid1, browser=driver)
|
|
||||||
phone_input = input("phone number : +33")
|
|
||||||
phone_elem = driver.find_element(By.ID, "wlspispHIPPhoneInput" + uuid1)
|
|
||||||
phone_elem.send_keys(phone_input)
|
|
||||||
wait_until_visible(By.ID, "wlspispHipSendCode" + uuid2, browser=driver)
|
|
||||||
send_sms_elem = driver.find_element(By.ID, "wlspispHipSendCode" + uuid2)
|
|
||||||
send_sms_elem.click()
|
|
||||||
wait_until_visible(By.ID, "wlspispSolutionElement" + uuid3, browser=driver)
|
|
||||||
sms_code_elem = driver.find_element(By.ID, "wlspispSolutionElement" + uuid3)
|
|
||||||
sms_code_input = input("entrez le contenu du msg : ")
|
|
||||||
sms_code_elem.send_keys(sms_code_input)
|
|
||||||
send_box = driver.find_element(By.ID, "ProofAction")
|
|
||||||
send_box.click()
|
|
||||||
wait_until_visible(By.ID, "FinishAction", browser=driver)
|
|
||||||
end_elem = driver.find_element(By.ID, "FinishAction")
|
|
||||||
end_elem.click()
|
|
||||||
|
|
||||||
|
|
||||||
# Sends points to database, discord and whatever service you want
|
# Sends points to database, discord and whatever service you want
|
||||||
|
# todo: refactor
|
||||||
def log_points(account="unknown"):
|
def log_points(account="unknown"):
|
||||||
def get_points():
|
def get_points():
|
||||||
driver.get("https://rewards.bing.com")
|
driver.get("https://rewards.bing.com")
|
||||||
custom_sleep(1)
|
custom_sleep(1)
|
||||||
if "/proofs/" in driver.current_url:
|
|
||||||
webhookFailure.send(f"Is /proof Useful in logpoints?", username="Dev tests",
|
|
||||||
avatar_url="https://cdn.discordapp.com/attachments/793934298977009677/1144560898879541268/image.png")
|
|
||||||
for id in ["KmsiCheckboxField", "iLooksGood", "idSIButton9", "iCancel"]:
|
|
||||||
try:
|
|
||||||
driver.find_element(By.ID, id).click()
|
|
||||||
except Exception as e:
|
|
||||||
pass
|
|
||||||
wait_until_visible(By.CSS_SELECTOR, 'span[mee-element-ready="$ctrl.loadCounterAnimation()"]', browser=driver)
|
wait_until_visible(By.CSS_SELECTOR, 'span[mee-element-ready="$ctrl.loadCounterAnimation()"]', browser=driver)
|
||||||
try:
|
try:
|
||||||
point = search('availablePoints\":([\d]+)', driver.page_source)[1]
|
point = search('availablePoints\":([\d]+)', driver.page_source)[1]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
sleep(5)
|
|
||||||
log_error(
|
log_error(
|
||||||
f"Dev error, checking why it doesn't work (waited a bit, is this still white ?) {format_error(e)}",
|
f"Dev error, checking why it doesn't work (waited a bit, is this still white ?) {format_error(e)}",
|
||||||
driver, True)
|
driver)
|
||||||
driver.refresh()
|
error("Can't get points.")
|
||||||
sleep(5)
|
return -1
|
||||||
point = search('availablePoints\":([\d]+)', driver.page_source)[1]
|
return point
|
||||||
return (point)
|
|
||||||
|
|
||||||
for _ in range(3):
|
|
||||||
try:
|
|
||||||
points = get_points()
|
points = get_points()
|
||||||
break
|
|
||||||
except Exception as e:
|
|
||||||
custom_sleep(300)
|
|
||||||
log_error(e)
|
|
||||||
points = None
|
|
||||||
|
|
||||||
if not points:
|
|
||||||
log_error(f"impossible d'avoir les points")
|
|
||||||
|
|
||||||
custom_sleep(uniform(3, 20))
|
custom_sleep(uniform(3, 20))
|
||||||
account_name = account.split("@")[0]
|
account_name = account.split("@")[0]
|
||||||
|
|
||||||
@ -615,6 +537,7 @@ def log_points(account="unknown"):
|
|||||||
log_error(e)
|
log_error(e)
|
||||||
|
|
||||||
|
|
||||||
|
# todo: refactor and check if it works at all
|
||||||
def fidelity():
|
def fidelity():
|
||||||
def sub_fidelity():
|
def sub_fidelity():
|
||||||
try:
|
try:
|
||||||
@ -690,17 +613,18 @@ def mobile_alert_popup():
|
|||||||
try:
|
try:
|
||||||
alert = mobile_driver.switch_to.alert
|
alert = mobile_driver.switch_to.alert
|
||||||
alert.dismiss()
|
alert.dismiss()
|
||||||
except exceptions.NoAlertPresentException as e:
|
except exceptions.NoAlertPresentException:
|
||||||
pass
|
pass
|
||||||
except Exception as e:
|
except Exception as err:
|
||||||
log_error(e, mobile_driver)
|
log_error(err, mobile_driver)
|
||||||
|
|
||||||
|
|
||||||
def bing_mobile_search(override=randint(22, 25)):
|
# todo: be coherent with pc search regarding error management
|
||||||
|
def bing_mobile_search(cred: UserCredentials, override=randint(22, 25)):
|
||||||
global mobile_driver
|
global mobile_driver
|
||||||
mobile_driver = create_driver(mobile=True)
|
mobile_driver = create_driver(mobile=True)
|
||||||
try:
|
try:
|
||||||
login(mobile_driver)
|
login(mobile_driver, cred)
|
||||||
mot = choice(Liste_de_mot).replace(" ", "+")
|
mot = choice(Liste_de_mot).replace(" ", "+")
|
||||||
mobile_driver.get(f"https://www.bing.com/search?q={mot}")
|
mobile_driver.get(f"https://www.bing.com/search?q={mot}")
|
||||||
custom_sleep(uniform(1, 2))
|
custom_sleep(uniform(1, 2))
|
||||||
@ -714,145 +638,77 @@ def bing_mobile_search(override=randint(22, 25)):
|
|||||||
custom_sleep(uniform(3, 7))
|
custom_sleep(uniform(3, 7))
|
||||||
mobile_alert_popup() # check for alert (asking for position or for allowing notifications)
|
mobile_alert_popup() # check for alert (asking for position or for allowing notifications)
|
||||||
mobile_driver.find_element(By.ID, "sb_form_q").clear()
|
mobile_driver.find_element(By.ID, "sb_form_q").clear()
|
||||||
except Exception as e:
|
except Exception as err:
|
||||||
printf(e)
|
error(err)
|
||||||
mobile_driver.refresh()
|
mobile_driver.refresh()
|
||||||
custom_sleep(30)
|
custom_sleep(30)
|
||||||
i -= 1
|
i -= 1
|
||||||
mobile_driver.quit()
|
mobile_driver.quit()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as err:
|
||||||
log_error(e, mobile_driver)
|
log_error(err, mobile_driver)
|
||||||
mobile_driver.quit()
|
mobile_driver.quit()
|
||||||
|
|
||||||
|
|
||||||
def daily_routine(custom=False):
|
def daily_routine(cred: UserCredentials, custom=False):
|
||||||
try:
|
try:
|
||||||
if not custom: # custom already login
|
if not custom: # custom already is logged in
|
||||||
login(driver)
|
login(driver, cred)
|
||||||
except Banned:
|
except Banned:
|
||||||
log_error("This account is locked. Fix that. (-U ?)", driver)
|
log_error("This account is locked.", driver)
|
||||||
return ()
|
return
|
||||||
except Identity:
|
except Identity:
|
||||||
log_error("This account has an issue. Fix that.", driver)
|
log_error("This account has an issue.", driver)
|
||||||
return ()
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
all_cards()
|
all_cards()
|
||||||
except Banned:
|
except Banned:
|
||||||
log_error("banned", driver)
|
log_error("banned", driver)
|
||||||
return ("BANNED")
|
raise Banned
|
||||||
except Exception as e:
|
except Exception as err:
|
||||||
log_error(e)
|
log_error(err)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
fidelity()
|
fidelity()
|
||||||
except Exception as e:
|
except Exception as err:
|
||||||
log_error(e)
|
log_error(err)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
bing_pc_search()
|
bing_pc_search()
|
||||||
except Exception as e:
|
except Exception as err:
|
||||||
log_error(e)
|
log_error(err)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
bing_mobile_search()
|
bing_mobile_search(cred)
|
||||||
except Exception as e:
|
except Exception as err:
|
||||||
log_error(e)
|
log_error(err)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
log_points(g._mail)
|
log_points(cred.get_mail())
|
||||||
except Exception as e:
|
except Exception as err:
|
||||||
log_error(e)
|
log_error(err)
|
||||||
|
|
||||||
|
|
||||||
def dev():
|
def json_start(json_entry, cred: UserCredentials):
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def CustomStart():
|
|
||||||
if not g.islinux:
|
|
||||||
raise NameError(
|
|
||||||
'You need to be on linux to do that, due to the utilisation of a module named enquieries, sorry.')
|
|
||||||
global driver
|
|
||||||
|
|
||||||
system("clear") # clear from previous command to allow a clean choice
|
|
||||||
actions = ["tout", "daily", "pc", "mobile", "log_points", "fidelity", "dev"]
|
|
||||||
Actions = enquiries.choose("quels Actions ?", actions, multi=True)
|
|
||||||
liste = select_accounts()
|
|
||||||
g.start_time = time() # Reset timer to the start of the actions
|
|
||||||
|
|
||||||
for cred in liste:
|
|
||||||
g._mail = cred[0]
|
|
||||||
g._password = cred[1]
|
|
||||||
if len(cred) == 3:
|
|
||||||
g._otp = TOTP(cred[2])
|
|
||||||
|
|
||||||
driver = create_driver()
|
|
||||||
driver.implicitly_wait(3)
|
|
||||||
if login(driver) != "STOP":
|
|
||||||
if "tout" in Actions:
|
|
||||||
daily_routine(True)
|
|
||||||
if "daily" in Actions:
|
|
||||||
# input("0")
|
|
||||||
try:
|
|
||||||
all_cards()
|
|
||||||
except Exception as e:
|
|
||||||
log_error(e)
|
|
||||||
if "pc" in Actions:
|
|
||||||
try:
|
|
||||||
bing_pc_search()
|
|
||||||
except Exception as e:
|
|
||||||
log_error(e)
|
|
||||||
if "mobile" in Actions:
|
|
||||||
try:
|
|
||||||
bing_mobile_search()
|
|
||||||
except Exception as e:
|
|
||||||
log_error(e)
|
|
||||||
if "fidelity" in Actions:
|
|
||||||
try:
|
|
||||||
fidelity()
|
|
||||||
except Exception as e:
|
|
||||||
log_error(e)
|
|
||||||
if "dev" in Actions:
|
|
||||||
try:
|
|
||||||
dev()
|
|
||||||
except Exception as e:
|
|
||||||
printf(e)
|
|
||||||
break
|
|
||||||
if not "tout" in Actions:
|
|
||||||
try:
|
|
||||||
log_points(g._mail)
|
|
||||||
except Exception as e:
|
|
||||||
printf(f"CustomStart {e}")
|
|
||||||
driver.quit()
|
|
||||||
|
|
||||||
|
|
||||||
def very_custom_start(json):
|
|
||||||
global driver
|
global driver
|
||||||
display = SmartDisplay(backend="xvnc", size=(1920, 1080), rfbport=2345, color_depth=24)
|
display = SmartDisplay(backend="xvnc", size=(1920, 1080), rfbport=2345, color_depth=24)
|
||||||
display.start()
|
display.start()
|
||||||
for i in range(5):
|
|
||||||
cred = g._cred[i]
|
|
||||||
g._mail = cred[0]
|
|
||||||
g._password = cred[1]
|
|
||||||
if cred[2] != '':
|
|
||||||
g._otp = TOTP(cred[2])
|
|
||||||
|
|
||||||
|
for i in range(5):
|
||||||
start = False
|
start = False
|
||||||
for j in ["unban", "tout", "pc", "mobile", "daily"]:
|
for j in ["unban", "tout", "pc", "mobile", "daily"]:
|
||||||
try:
|
try:
|
||||||
if str(i) in json[j]:
|
if str(i) in json_entry[j]:
|
||||||
start = True
|
start = True
|
||||||
print(f"{g._mail} : {j}")
|
info(f"{cred.get_mail()} : {j}")
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
# print(f"none is set to \"{j}\"")
|
|
||||||
if start:
|
if start:
|
||||||
driver = create_driver()
|
driver = create_driver()
|
||||||
try:
|
try:
|
||||||
if str(i) in json["unban"]:
|
if str(i) in json_entry["unban"]:
|
||||||
pwd_login(driver) # TODO : define only the first part of login
|
login_part_1(driver, cred)
|
||||||
print("\nGO TO example.com TO PROCEED or wait 1200 secs.")
|
print("\nGO TO example.com TO PROCEED or wait 1200 secs.")
|
||||||
for _ in range(1200):
|
for _ in range(1200):
|
||||||
sleep(1)
|
sleep(1)
|
||||||
@ -860,18 +716,18 @@ def very_custom_start(json):
|
|||||||
print("proceeding")
|
print("proceeding")
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
login(driver)
|
login(driver, cred)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
login(driver)
|
login(driver, cred)
|
||||||
try:
|
try:
|
||||||
if str(i) in json["tout"]:
|
if str(i) in json_entry["tout"]:
|
||||||
daily_routine(True)
|
daily_routine(cred)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
# print("none is set to \"tout\"")
|
# print("none is set to \"tout\"")
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
if str(i) in json["daily"]:
|
if str(i) in json_entry["daily"]:
|
||||||
try:
|
try:
|
||||||
all_cards()
|
all_cards()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -880,87 +736,71 @@ def very_custom_start(json):
|
|||||||
pass
|
pass
|
||||||
# print("none is set to \"daily\"")
|
# print("none is set to \"daily\"")
|
||||||
try:
|
try:
|
||||||
if str(i) in json["pc"]:
|
if str(i) in json_entry["pc"]:
|
||||||
try:
|
try:
|
||||||
bing_pc_search()
|
bing_pc_search()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log_error(e)
|
log_error(e)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
# print("none is set to \"pc\"")
|
|
||||||
try:
|
try:
|
||||||
if str(i) in json["mobile"]:
|
if str(i) in json_entry["mobile"]:
|
||||||
try:
|
try:
|
||||||
bing_mobile_search()
|
bing_mobile_search(cred)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log_error(e)
|
log_error(e)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
# print("none is set to \"mobile\"")
|
|
||||||
try:
|
try:
|
||||||
log_points(g._mail)
|
log_points(g._mail)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
printf(f"CustomStart {e}")
|
printf(f"CustomStart {e}")
|
||||||
|
|
||||||
driver.close()
|
driver.close()
|
||||||
|
cred.next_account()
|
||||||
display.stop()
|
display.stop()
|
||||||
|
|
||||||
|
|
||||||
if g.very_custom:
|
c = Config(args)
|
||||||
dict_data = json.loads(g.very_custom.replace("'", "\""))
|
|
||||||
very_custom_start(dict_data)
|
if g.json_start:
|
||||||
|
dict_data = json.loads(g.json_start.replace("'", "\""))
|
||||||
|
json_start(dict_data, c.UserCredentials)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
if g.vnc_enabled or g.dev:
|
if g.vnc_enabled or g.dev:
|
||||||
display = SmartDisplay(backend="xvnc", size=(1920, 1080), rfbport=g.vnc_port, color_depth=24)
|
display = SmartDisplay(backend="xvnc", size=(1920, 1080), rfbport=g.vnc_port, color_depth=24)
|
||||||
else:
|
else:
|
||||||
display = SmartDisplay(size=(1920, 1080))
|
display = SmartDisplay(size=(1920, 1080))
|
||||||
display.start()
|
display.start()
|
||||||
|
|
||||||
if g.dev:
|
|
||||||
driver = create_driver()
|
|
||||||
# input("kill ?")
|
|
||||||
driver.quit()
|
|
||||||
elif g.custom_start:
|
|
||||||
CustomStart()
|
|
||||||
elif g.unban:
|
|
||||||
g._mail, g._password = select_accounts(False)[0]
|
|
||||||
driver = create_driver()
|
|
||||||
try:
|
|
||||||
login(driver)
|
|
||||||
except Banned:
|
|
||||||
unban()
|
|
||||||
driver.quit()
|
|
||||||
else:
|
|
||||||
if g.update_version != "None":
|
if g.update_version != "None":
|
||||||
if g.discord_enabled_error:
|
if g.discord_enabled_error:
|
||||||
webhookFailure.send(f"Updated to {g.update_version}", username="UPDATE",
|
webhookFailure.send(f"Updated to {g.update_version}", username="UPDATE",
|
||||||
avatar_url="https://cdn-icons-png.flaticon.com/512/1688/1688988.png")
|
avatar_url="https://cdn-icons-png.flaticon.com/512/1688/1688988.png")
|
||||||
for cred in g._cred:
|
|
||||||
if cred[0] != "":
|
while c.UserCredentials.is_valid():
|
||||||
g._mail = cred[0]
|
|
||||||
g._password = cred[1]
|
|
||||||
if cred[2] != '':
|
|
||||||
g._otp = TOTP(cred[2])
|
|
||||||
custom_sleep(1)
|
custom_sleep(1)
|
||||||
printf("Début du driver.")
|
info("Starting driver.")
|
||||||
driver = create_driver()
|
driver = create_driver()
|
||||||
printf("Driver demarré.")
|
info("Driver started.")
|
||||||
driver.implicitly_wait(3)
|
driver.implicitly_wait(3)
|
||||||
try:
|
try:
|
||||||
attente = uniform(1200, 3600)
|
wait_time = uniform(1200, 3600)
|
||||||
printf(f"Attente de {round(attente / 60)} min avant de démarrer")
|
info(f"Waiting for {round(wait_time / 60)}min before starting")
|
||||||
daily_routine()
|
daily_routine(c.UserCredentials)
|
||||||
driver.quit()
|
driver.quit()
|
||||||
custom_sleep(attente)
|
custom_sleep(wait_time)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
printf("Canceled. Closing driver and display.")
|
critical("Canceled by user. Closing driver and display.")
|
||||||
driver.quit()
|
driver.quit()
|
||||||
display.stop()
|
display.stop()
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log_error(f"Error not catched. Skipping this account. " + format_error(e), driver)
|
log_error(f"Error not caught. Skipping this account. " + format_error(e), driver)
|
||||||
printf(f"Error not catched. Skipping this account. {e}")
|
critical(f"Error not caught. Skipping this account. {e}")
|
||||||
driver.quit()
|
driver.quit()
|
||||||
|
|
||||||
|
c.UserCredentials.next_account()
|
||||||
|
|
||||||
display.stop()
|
display.stop()
|
||||||
|
43
V7/V7.py
43
V7/V7.py
@ -1,43 +0,0 @@
|
|||||||
from playwright.sync_api import sync_playwright, expect, Page, BrowserContext
|
|
||||||
from playwright_stealth import stealth_sync
|
|
||||||
from pyvirtualdisplay.smartdisplay import SmartDisplay
|
|
||||||
|
|
||||||
from actions.cards import daily_cards, more_cards, all_cards
|
|
||||||
from actions.login import login
|
|
||||||
from actions.websearch import pc_search
|
|
||||||
from tools.browser_setup import create_display, start_browser
|
|
||||||
from tools.config import load_parameters, check_config
|
|
||||||
from tools.logger import *
|
|
||||||
import sys
|
|
||||||
import json
|
|
||||||
|
|
||||||
|
|
||||||
def routine(mail: str, pwd: str, vnc: bool = False) -> None:
|
|
||||||
name = mail.split("@")[0]
|
|
||||||
# display = create_display(vnc)
|
|
||||||
# display.start()
|
|
||||||
page, browser = start_browser(name)
|
|
||||||
login(page, mail, pwd)
|
|
||||||
all_cards(page)
|
|
||||||
pc_search(page)
|
|
||||||
# display.stop()
|
|
||||||
browser.close()
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
data = load_parameters()
|
|
||||||
check_config(data)
|
|
||||||
|
|
||||||
|
|
||||||
# routine("EMAIL", "PWD", True)
|
|
||||||
# parse_file({"accounts": {"nb": 1, 0: {"mail": "piair338@gmail.com", "pwd": "<PASSWORD>"}}})
|
|
||||||
"""
|
|
||||||
TODO :
|
|
||||||
Fidelity management.
|
|
||||||
Daily search mobile
|
|
||||||
start -> with json config
|
|
||||||
-> allow claiming
|
|
||||||
-> default mode
|
|
||||||
--vnc-- Should work, but not tested with WSL.
|
|
||||||
remove unused imports
|
|
||||||
"""
|
|
@ -1,61 +0,0 @@
|
|||||||
from playwright.sync_api import sync_playwright, expect, Page, BrowserContext
|
|
||||||
from playwright_stealth import stealth_sync
|
|
||||||
|
|
||||||
from actions.quiz import play
|
|
||||||
from tools.logger import *
|
|
||||||
from tools.logger import *
|
|
||||||
|
|
||||||
|
|
||||||
def all_cards(page: Page):
|
|
||||||
# input("1")
|
|
||||||
page.goto("https://rewards.bing.com")
|
|
||||||
page.wait_for_load_state('load')
|
|
||||||
daily_cards(page)
|
|
||||||
more_cards(page)
|
|
||||||
|
|
||||||
|
|
||||||
def daily_cards(page: Page):
|
|
||||||
for i in range(1, 4):
|
|
||||||
card = page.locator(f'#daily-sets > mee-card-group:nth-child(7) > div > mee-card:nth-child({i}) > div')
|
|
||||||
if "mee-icon-AddMedium" not in card.inner_html():
|
|
||||||
info(f'Daily Card {i} : {"Validated" if "mee-icon-AddMedium" not in card.inner_html() else "Failure"}')
|
|
||||||
continue
|
|
||||||
with page.expect_popup() as page1_info:
|
|
||||||
card.click()
|
|
||||||
page1 = page1_info.value
|
|
||||||
stealth_sync(page1)
|
|
||||||
page1.wait_for_load_state('load')
|
|
||||||
try:
|
|
||||||
selector = page1.get_by_role("button", name="Accepter")
|
|
||||||
expect(selector).to_be_visible(timeout=10_000)
|
|
||||||
selector.click()
|
|
||||||
except AssertionError as e:
|
|
||||||
pass # The RGPD button should not be there in the first place
|
|
||||||
play(page1)
|
|
||||||
page1.close()
|
|
||||||
page.reload()
|
|
||||||
info(f'Daily Card {i} : {"Validated" if "mee-icon-AddMedium" not in card.inner_html() else "Failure"}')
|
|
||||||
|
|
||||||
|
|
||||||
def more_cards(page: Page):
|
|
||||||
c = 1
|
|
||||||
while c < 15: # todo I don't really know why it stops without raising any errors, but I guess it's fine
|
|
||||||
card = page.locator(f"#more-activities > div > mee-card:nth-child({c})")
|
|
||||||
|
|
||||||
try:
|
|
||||||
expect(card).to_be_visible(timeout=10_000)
|
|
||||||
except Exception as e: # The card probably does not exist
|
|
||||||
debug(e)
|
|
||||||
break
|
|
||||||
if "mee-icon-AddMedium" in card.inner_html():
|
|
||||||
info(f"Playing more cards {c}.")
|
|
||||||
with page.expect_popup() as page1_info:
|
|
||||||
card.click()
|
|
||||||
page1 = page1_info.value
|
|
||||||
stealth_sync(page1)
|
|
||||||
page1.wait_for_load_state('load')
|
|
||||||
play(page1)
|
|
||||||
page1.close()
|
|
||||||
page.reload()
|
|
||||||
info(f'More Card {c} : {"Validated" if "mee-icon-AddMedium" not in card.inner_html() else "Failure"}')
|
|
||||||
c += 1
|
|
@ -1,10 +0,0 @@
|
|||||||
from playwright.sync_api import Playwright, sync_playwright, expect, Page
|
|
||||||
from playwright_stealth import stealth_sync
|
|
||||||
from logging import *
|
|
||||||
|
|
||||||
|
|
||||||
def check_logged_in(page: Page):
|
|
||||||
if "pas connecté à Microsoft Rewards" in page.content():
|
|
||||||
page.locator('css=[onclick="setsrchusr()"]').click()
|
|
||||||
page.wait_for_load_state('load')
|
|
||||||
info('Fixed logging in in card.')
|
|
@ -1,30 +0,0 @@
|
|||||||
from playwright.sync_api import Playwright, sync_playwright, expect, Page
|
|
||||||
from logging import *
|
|
||||||
|
|
||||||
|
|
||||||
def login(page: Page, mail: str, pwd: str) -> None:
|
|
||||||
page.goto("https://rewards.bing.com")
|
|
||||||
page.wait_for_load_state('load')
|
|
||||||
if page.url == "https://rewards.bing.com/":
|
|
||||||
info("Logged in via cookies")
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
info("logging in")
|
|
||||||
page.get_by_placeholder("Email, phone, or Skype").click()
|
|
||||||
page.get_by_placeholder("Email, phone, or Skype").fill(mail)
|
|
||||||
page.get_by_placeholder("Email, phone, or Skype").press("Enter")
|
|
||||||
page.get_by_placeholder("Password").click()
|
|
||||||
page.get_by_placeholder("Password").fill(pwd)
|
|
||||||
page.get_by_placeholder("Password").press("Enter")
|
|
||||||
page.get_by_label("Don't show this again").check()
|
|
||||||
page.get_by_role("button", name="Yes").click()
|
|
||||||
page.wait_for_url("https://rewards.bing.com/")
|
|
||||||
page.wait_for_load_state('load')
|
|
||||||
page.goto("https://bing.com")
|
|
||||||
page.get_by_role("link", name="Sign in").click()
|
|
||||||
page.get_by_role("link", name="Accept").click()
|
|
||||||
page.wait_for_load_state('load')
|
|
||||||
page.wait_for_timeout(3000)
|
|
||||||
page.goto("https://rewards.bing.com")
|
|
||||||
page.wait_for_load_state('load')
|
|
||||||
info("Logged in via password.")
|
|
@ -1,120 +0,0 @@
|
|||||||
from random import choice, shuffle
|
|
||||||
|
|
||||||
from playwright.sync_api import Playwright, sync_playwright, expect, Page
|
|
||||||
from playwright_stealth import stealth_sync
|
|
||||||
from logging import *
|
|
||||||
from re import findall, search
|
|
||||||
from actions.checks import check_logged_in
|
|
||||||
|
|
||||||
|
|
||||||
def play(page: Page):
|
|
||||||
check_logged_in(page)
|
|
||||||
quiz_type = detect_quiz_type(page)
|
|
||||||
match quiz_type:
|
|
||||||
case 8 | 9:
|
|
||||||
info('Detected quiz_8.')
|
|
||||||
play_quiz_8(page)
|
|
||||||
case 5 | 4:
|
|
||||||
info('Detected quiz_4.')
|
|
||||||
play_quiz_4(page)
|
|
||||||
case 3 | 2:
|
|
||||||
info('Detected quiz_2.')
|
|
||||||
play_quiz_2(page)
|
|
||||||
case 1:
|
|
||||||
info('Detected poll.')
|
|
||||||
play_poll(page)
|
|
||||||
case 0:
|
|
||||||
info('Detected empty page.')
|
|
||||||
|
|
||||||
|
|
||||||
def detect_quiz_type(page: Page) -> int:
|
|
||||||
info("Detecting quiz type.")
|
|
||||||
if "bt_PollRadio" in page.content():
|
|
||||||
return 1
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
# RGPD
|
|
||||||
selector = page.locator("#rqStartQuiz")
|
|
||||||
expect(selector).to_be_visible(timeout=10_000)
|
|
||||||
selector.click()
|
|
||||||
return page.content().count("rqAnswerOption") - 1
|
|
||||||
except AssertionError as e:
|
|
||||||
|
|
||||||
if "rqQuestionState" in page.content():
|
|
||||||
# The quiz is already started
|
|
||||||
warning("Detected via recovery mode.")
|
|
||||||
return page.content().count("rqAnswerOption") - 1
|
|
||||||
return 0
|
|
||||||
|
|
||||||
|
|
||||||
def play_quiz_8(page: Page):
|
|
||||||
info("Playing quiz 8.")
|
|
||||||
num_question = len(findall("<span id=\"rqQuestionState.\" class=\"emptyCircle\"></span>", page.content())) + 1
|
|
||||||
info(f"Looping on {num_question} questions.")
|
|
||||||
|
|
||||||
counter = 0
|
|
||||||
# rgpd_popup(driver)
|
|
||||||
for _ in range(num_question):
|
|
||||||
correct_answers = []
|
|
||||||
for i in range(1, 9):
|
|
||||||
|
|
||||||
element = page.locator(f'#rqAnswerOption{i - 1}')
|
|
||||||
# todo can probably be optimised using filter and has_text
|
|
||||||
if 'iscorrectoption="True"' in element.evaluate("el => el.outerHTML"):
|
|
||||||
correct_answers.append(f'#rqAnswerOption{i - 1}')
|
|
||||||
shuffle(correct_answers)
|
|
||||||
|
|
||||||
for answer_id in correct_answers:
|
|
||||||
page.locator(answer_id).click()
|
|
||||||
page.wait_for_timeout(1000)
|
|
||||||
page.wait_for_timeout(3000) # todo check if there is a better method than hardcoded timout
|
|
||||||
page.wait_for_timeout(3000) # todo check if there is a better method than hardcoded timout
|
|
||||||
|
|
||||||
|
|
||||||
def play_quiz_4(page: Page):
|
|
||||||
info("Playing quiz 4.")
|
|
||||||
num_question = len(findall("<span id=\"rqQuestionState.\" class=\"emptyCircle\"></span>", page.content())) + 1
|
|
||||||
info(f"Looping on {num_question} questions.")
|
|
||||||
|
|
||||||
for i in range(num_question):
|
|
||||||
txt = page.content()
|
|
||||||
answer_option = search('correctAnswer":"([^"]+)', txt)[1]
|
|
||||||
answer_option = answer_option.replace("\\u0027", "'") # replace Unicode weird symbols
|
|
||||||
page.locator(f'css=[data-option="{answer_option}"]').click()
|
|
||||||
info(f'Validated answer n°{i + 1}.')
|
|
||||||
page.wait_for_load_state('load')
|
|
||||||
debug(f'Next page loaded.')
|
|
||||||
info("Quiz 4 successful.")
|
|
||||||
|
|
||||||
|
|
||||||
def play_quiz_2(page: Page):
|
|
||||||
info("Playing quiz 2.")
|
|
||||||
for j in range(10): # todo de-hardcode the value
|
|
||||||
js_function = """
|
|
||||||
function get_correct_answer(){
|
|
||||||
function br(n) { for (var r, t = 0, i = 0; i < n.length; i++)t += n.charCodeAt(i); return r = parseInt(_G.IG.substr(_G.IG.length - 2), 16), t += r, t.toString() } // Ms check function
|
|
||||||
function namedRAValue() { //allow calls to getRAvalue
|
|
||||||
return _w.getRAValue()
|
|
||||||
};
|
|
||||||
if (br(document.getElementById("rqAnswerOption0").attributes["data-option"].value) == namedRAValue()){
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return(1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return(get_correct_answer())
|
|
||||||
"""
|
|
||||||
correct_answer_value = page.evaluate(js_function)
|
|
||||||
page.locator(f"#rqAnswerOption{correct_answer_value}").click()
|
|
||||||
page.wait_for_timeout(2000)
|
|
||||||
info("Quiz 2 successful.")
|
|
||||||
page.wait_for_timeout(3000) # todo check if there is a better method than hardcoded timout
|
|
||||||
|
|
||||||
|
|
||||||
def play_poll(page: Page):
|
|
||||||
info("Playing poll.")
|
|
||||||
answer_elem = page.locator(f"#btoption{choice([0, 1])}")
|
|
||||||
answer_elem.click()
|
|
||||||
info("Poll successful.")
|
|
||||||
page.wait_for_timeout(3000) # todo check if there is a better method than hardcoded timout
|
|
@ -1,25 +0,0 @@
|
|||||||
from random import choice
|
|
||||||
|
|
||||||
from playwright.sync_api import sync_playwright, expect, Page
|
|
||||||
from playwright_stealth import stealth_sync
|
|
||||||
|
|
||||||
h = open("../user_data/french", "r", encoding="utf-8")
|
|
||||||
lines = h.readlines()
|
|
||||||
if len(lines) < 3:
|
|
||||||
Liste_de_mot = list(lines[0].split(","))
|
|
||||||
else:
|
|
||||||
Liste_de_mot = [x.replace('\n', "") for x in lines]
|
|
||||||
h.close()
|
|
||||||
|
|
||||||
|
|
||||||
def pc_search(page: Page) -> None:
|
|
||||||
mot = choice(Liste_de_mot).replace(" ", "+")
|
|
||||||
page.goto(f"https://www.bing.com/search?q={mot}")
|
|
||||||
|
|
||||||
for _ in range(35): # todo de-hardcode this variable
|
|
||||||
word = choice(Liste_de_mot)
|
|
||||||
page.get_by_label("Enter your search here -").click()
|
|
||||||
page.get_by_label("Enter your search here -").fill(word)
|
|
||||||
page.get_by_label("Enter your search here -").press("Enter")
|
|
||||||
page.wait_for_load_state("load")
|
|
||||||
page.wait_for_timeout(3000) # todo check if there is a better method than hardcoded timout
|
|
@ -1,14 +0,0 @@
|
|||||||
{
|
|
||||||
"accounts": {
|
|
||||||
"nb": 1,
|
|
||||||
"0": {
|
|
||||||
"mail": "piair338@gmail.com",
|
|
||||||
"pwd": "uéuéué"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"config": {
|
|
||||||
"vnc_enabled": "False",
|
|
||||||
"vnc_port": 2345,
|
|
||||||
"claim": "False"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
playwright
|
|
||||||
pyvirtualdisplay
|
|
||||||
playwright_stealth
|
|
||||||
pillow
|
|
@ -1,18 +0,0 @@
|
|||||||
from playwright.sync_api import sync_playwright, expect, Page, BrowserContext
|
|
||||||
from playwright_stealth import stealth_sync
|
|
||||||
from pyvirtualdisplay.smartdisplay import SmartDisplay
|
|
||||||
|
|
||||||
|
|
||||||
def create_display(vnc=False) -> SmartDisplay:
|
|
||||||
if vnc:
|
|
||||||
return SmartDisplay(backend="xvnc", size=(1920, 1080), rfbport=2345, color_depth=24)
|
|
||||||
return SmartDisplay(size=(1920, 1080))
|
|
||||||
|
|
||||||
|
|
||||||
def start_browser(name: str) -> (Page, BrowserContext):
|
|
||||||
p = sync_playwright().start()
|
|
||||||
browser = p.firefox.launch_persistent_context(f"./data/{name}/", headless=False, args=["--start-maximised"],
|
|
||||||
no_viewport=True)
|
|
||||||
page = browser.new_page()
|
|
||||||
stealth_sync(page)
|
|
||||||
return page, browser
|
|
@ -1,47 +0,0 @@
|
|||||||
from playwright.sync_api import sync_playwright, expect, Page, BrowserContext
|
|
||||||
from playwright_stealth import stealth_sync
|
|
||||||
from pyvirtualdisplay.smartdisplay import SmartDisplay
|
|
||||||
|
|
||||||
from actions.cards import daily_cards, more_cards, all_cards
|
|
||||||
from actions.login import login
|
|
||||||
from actions.websearch import pc_search
|
|
||||||
from tools.browser_setup import create_display, start_browser
|
|
||||||
from tools.logger import *
|
|
||||||
import sys
|
|
||||||
import json
|
|
||||||
|
|
||||||
|
|
||||||
def check_config(data: dict) -> None:
|
|
||||||
info("Checking config file.")
|
|
||||||
try:
|
|
||||||
assert data["accounts"]["nb"] != 0, "No accounts found in the file"
|
|
||||||
for i in range(data["accounts"]["nb"]):
|
|
||||||
assert data["accounts"][str(i)]["mail"] != "", f"Account {i} has no mail."
|
|
||||||
assert data["accounts"][str(i)]["pwd"] != "", f"Account {i} has no password."
|
|
||||||
assert data["config"]["vnc_enabled"] in ["True", "False"], f"vnc_enable should be either True or False."
|
|
||||||
assert data["config"]["claim"] in ["True", "False"], f"claim should be either True or False."
|
|
||||||
assert 1024 < data["config"]["vnc_port"] < 65535, f"vnc_port should be a valid port."
|
|
||||||
assert data["config"]["vnc_port"] not in [1234], f"vnc_port should be different than the webserver's ports."
|
|
||||||
except AssertionError as e:
|
|
||||||
critical(e)
|
|
||||||
exit(1)
|
|
||||||
except KeyError as e:
|
|
||||||
critical(f"Malformed config file. Missing {e}. Refer to the example config file.")
|
|
||||||
exit(1)
|
|
||||||
info("Successfully Checked config.")
|
|
||||||
|
|
||||||
|
|
||||||
def load_parameters() -> dict:
|
|
||||||
parameters = sys.argv
|
|
||||||
if len(parameters) == 1:
|
|
||||||
critical("Started with no parameters. Please provide at least a config file.")
|
|
||||||
exit(1)
|
|
||||||
if len(parameters) > 2:
|
|
||||||
warning("Started with multiple parameters. Some will be ignored")
|
|
||||||
try:
|
|
||||||
with open(parameters[1], "r") as f:
|
|
||||||
data = json.load(f)
|
|
||||||
return data
|
|
||||||
except FileNotFoundError:
|
|
||||||
critical("Could not open the config file.")
|
|
||||||
exit(1)
|
|
15
modules/Classes/Config.py
Normal file
15
modules/Classes/Config.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import json
|
||||||
|
|
||||||
|
from modules.Classes.UserCredentials import UserCredentials
|
||||||
|
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
def __init__(self, args):
|
||||||
|
self.args = args
|
||||||
|
self.UserCredentials = UserCredentials()
|
||||||
|
|
||||||
|
with open("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile:
|
||||||
|
configs = json.load(inFile)
|
||||||
|
for i in configs[str(args.config)]["accounts"]:
|
||||||
|
d = configs[str(args.config)]["accounts"][i]
|
||||||
|
self.UserCredentials.add(d["mail"], d["pwd"], d["2fa"])
|
39
modules/Classes/UserCredentials.py
Normal file
39
modules/Classes/UserCredentials.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
import json
|
||||||
|
from modules.Tools.logger import debug, warning
|
||||||
|
|
||||||
|
|
||||||
|
class UserCredentials:
|
||||||
|
def __init__(self):
|
||||||
|
self.data = {}
|
||||||
|
self.current = 0
|
||||||
|
self.total = 0
|
||||||
|
|
||||||
|
def add(self, username: str, password: str, tfa: str = None):
|
||||||
|
debug(f"adding account with data : Username: {username}, Password: {password}, 2FA: {'None' if tfa == '' else tfa}")
|
||||||
|
self.data[self.total] = {
|
||||||
|
"username": username,
|
||||||
|
"password": password,
|
||||||
|
"2fa": None if tfa == '' else tfa
|
||||||
|
}
|
||||||
|
self.total += 1
|
||||||
|
|
||||||
|
def tfa_enable(self):
|
||||||
|
return self.data[self.current]["2fa"] is not None
|
||||||
|
|
||||||
|
def get_mail(self):
|
||||||
|
return self.data[self.current]["username"]
|
||||||
|
|
||||||
|
def get_password(self):
|
||||||
|
return self.data[self.current]["password"]
|
||||||
|
|
||||||
|
def get_tfa(self):
|
||||||
|
if not self.tfa_enable():
|
||||||
|
warning("Warning: TFA is not enabled. Calling get_tfa is an expected behaviour.")
|
||||||
|
return self.data[self.current]["tfa"]
|
||||||
|
|
||||||
|
def next_account(self):
|
||||||
|
self.current += 1
|
||||||
|
debug(f"New credentials: {self.data[self.current]}")
|
||||||
|
|
||||||
|
def is_valid(self):
|
||||||
|
return self.current < self.total
|
@ -30,7 +30,7 @@ class ColoredFormatter(logging.Formatter):
|
|||||||
|
|
||||||
# Set up the root logger
|
# Set up the root logger
|
||||||
root_logger = logging.getLogger()
|
root_logger = logging.getLogger()
|
||||||
root_logger.setLevel(logging.INFO)
|
root_logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
# Create a console handler and set the formatter
|
# Create a console handler and set the formatter
|
||||||
ch = logging.StreamHandler()
|
ch = logging.StreamHandler()
|
@ -4,45 +4,14 @@ from modules.imports import *
|
|||||||
import modules.globals as g
|
import modules.globals as g
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
||||||
class FakeWebHook:
|
class FakeWebHook:
|
||||||
def send(self, text="", username='', avatar_url='', embed="", file=""):
|
def send(self, text="", username='', avatar_url='', embed="", file=""):
|
||||||
print(text)
|
print(text)
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
|
||||||
parser.add_argument(
|
|
||||||
"-o",
|
|
||||||
"--override",
|
|
||||||
help="override",
|
|
||||||
dest="override",
|
|
||||||
action="store_true"
|
|
||||||
)
|
|
||||||
|
|
||||||
parser.add_argument(
|
|
||||||
"-u",
|
|
||||||
"--unban",
|
|
||||||
help="unban an account",
|
|
||||||
dest="unban",
|
|
||||||
action="store_true"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
parser.add_argument(
|
|
||||||
"-fl",
|
|
||||||
"--fulllog",
|
|
||||||
dest="fulllog",
|
|
||||||
help="enable full logging in discord",
|
|
||||||
action="store_true",
|
|
||||||
)
|
|
||||||
|
|
||||||
parser.add_argument(
|
|
||||||
"-d",
|
|
||||||
"--dev",
|
|
||||||
dest="dev",
|
|
||||||
help="enable dev mode",
|
|
||||||
action="store_true",
|
|
||||||
)
|
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-c",
|
"-c",
|
||||||
"--config",
|
"--config",
|
||||||
@ -50,7 +19,6 @@ parser.add_argument(
|
|||||||
default=""
|
default=""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-v",
|
"-v",
|
||||||
"--vnc",
|
"--vnc",
|
||||||
@ -66,8 +34,8 @@ parser.add_argument(
|
|||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--very-custom",
|
"--json",
|
||||||
help="Choose a specific config file",
|
help="input json to start the bot with custom parameters",
|
||||||
default=""
|
default=""
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -80,31 +48,21 @@ with open("/app/MsRewards-Reborn/user_data/proxy.json", "r") as inFile:
|
|||||||
with open("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile:
|
with open("/app/MsRewards-Reborn/user_data/configs.json", "r") as inFile:
|
||||||
config = json.load(inFile)
|
config = json.load(inFile)
|
||||||
|
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
g.custom_start = args.override
|
g.json_start = args.json
|
||||||
g.unban = args.unban
|
|
||||||
g.full_log = args.fulllog
|
|
||||||
g.dev = args.dev
|
|
||||||
g.very_custom = args.very_custom
|
|
||||||
|
|
||||||
if g.custom_start :
|
|
||||||
g.log = True
|
|
||||||
|
|
||||||
g.vnc_enabled = args.vnc != "None"
|
g.vnc_enabled = args.vnc != "None"
|
||||||
g.vnc_port = args.vnc
|
g.vnc_port = args.vnc
|
||||||
g.update_version = args.update_version
|
g.update_version = args.update_version
|
||||||
# global variables used later in the code
|
# global variables used later in the code
|
||||||
g.islinux = platform == "linux" # if the computer running this program is Linux, it allow more things
|
|
||||||
g.start_time = time()
|
|
||||||
|
|
||||||
|
g.start_time = time()
|
||||||
|
|
||||||
# path configurations
|
# path configurations
|
||||||
g.mot_path = "/usr/share/dict/french"
|
g.mot_path = "/usr/share/dict/french"
|
||||||
g.credential_path = "/app/MsRewards-Reborn/user_data/login.csv"
|
g.credential_path = "/app/MsRewards-Reborn/user_data/login.csv"
|
||||||
|
|
||||||
|
|
||||||
discord_conf = config[args.config]["discord"]
|
discord_conf = config[args.config]["discord"]
|
||||||
|
|
||||||
# discord configuration
|
# discord configuration
|
||||||
@ -115,7 +73,7 @@ g.discord_enabled_success = discord[discord_conf]["successT"] == "True"
|
|||||||
|
|
||||||
g.avatar_url = settings["avatarlink"]
|
g.avatar_url = settings["avatarlink"]
|
||||||
|
|
||||||
if not g.very_custom :
|
if not g.json_start:
|
||||||
if g.discord_enabled_error:
|
if g.discord_enabled_error:
|
||||||
webhookFailure = Webhook.from_url(g.discord_error_link, adapter=RequestsWebhookAdapter())
|
webhookFailure = Webhook.from_url(g.discord_error_link, adapter=RequestsWebhookAdapter())
|
||||||
if g.discord_enabled_success:
|
if g.discord_enabled_success:
|
||||||
@ -123,6 +81,8 @@ if not g.very_custom :
|
|||||||
else:
|
else:
|
||||||
webhookFailure = FakeWebHook()
|
webhookFailure = FakeWebHook()
|
||||||
webhookSuccess = FakeWebHook()
|
webhookSuccess = FakeWebHook()
|
||||||
|
|
||||||
|
|
||||||
# base settings
|
# base settings
|
||||||
g.discord_embed = False # send new point value in an embed, fixed for now
|
g.discord_embed = False # send new point value in an embed, fixed for now
|
||||||
g.headless = False
|
g.headless = False
|
||||||
@ -134,20 +94,14 @@ if g.proxy_enabled :
|
|||||||
g.proxy_port = proxy[config[args.config]["proxy"]]["port"]
|
g.proxy_port = proxy[config[args.config]["proxy"]]["port"]
|
||||||
|
|
||||||
|
|
||||||
g.fast = False
|
|
||||||
|
|
||||||
# list of words
|
# list of words
|
||||||
h = open(g.mot_path, "r", encoding="utf-8")
|
with open(g.mot_path, "r", encoding="utf-8") as h:
|
||||||
lines = h.readlines()
|
lines = h.readlines()
|
||||||
if len(lines) < 3:
|
if len(lines) < 3:
|
||||||
Liste_de_mot = list(lines[0].split(","))
|
Liste_de_mot = list(lines[0].split(","))
|
||||||
else:
|
else:
|
||||||
Liste_de_mot = [x.replace('\n', "") for x in lines]
|
Liste_de_mot = [x.replace('\n', "") for x in lines]
|
||||||
h.close()
|
|
||||||
|
|
||||||
|
|
||||||
Credentials = [ (config[args.config]['accounts'][x]["mail"],config[args.config]['accounts'][x]["pwd"],config[args.config]['accounts'][x]["2fa"]) for x in config[args.config]['accounts']]
|
|
||||||
g._cred = Credentials
|
|
||||||
|
|
||||||
if g.proxy_enabled:
|
if g.proxy_enabled:
|
||||||
setup_proxy(g.proxy_address, g.proxy_port)
|
setup_proxy(g.proxy_address, g.proxy_port)
|
||||||
|
@ -8,7 +8,7 @@ def set_language(ldriver):
|
|||||||
ldriver.get("chrome://settings/languages")
|
ldriver.get("chrome://settings/languages")
|
||||||
action = ActionChains(ldriver)
|
action = ActionChains(ldriver)
|
||||||
action.reset_actions()
|
action.reset_actions()
|
||||||
# select langage
|
# select language
|
||||||
x_coord = 1200
|
x_coord = 1200
|
||||||
y_coord = 150
|
y_coord = 150
|
||||||
action.move_by_offset(x_coord, y_coord).click().perform()
|
action.move_by_offset(x_coord, y_coord).click().perform()
|
||||||
|
@ -1,18 +1,11 @@
|
|||||||
driver = None
|
driver = None
|
||||||
_mail = '_mail temp'
|
|
||||||
_password = '_password temp'
|
|
||||||
_otp = '_otp temp'
|
|
||||||
display = None
|
display = None
|
||||||
_cred = []
|
|
||||||
custom_start = False
|
|
||||||
unban = False
|
|
||||||
log = False
|
log = False
|
||||||
full_log = False
|
full_log = False
|
||||||
vnc_enabled = False
|
vnc_enabled = False
|
||||||
vnc_port = 2345
|
vnc_port = 2345
|
||||||
points_file = "/"
|
points_file = "/"
|
||||||
update_version = False
|
update_version = False
|
||||||
islinux = True
|
|
||||||
start_time = 0
|
start_time = 0
|
||||||
mot_path = "/"
|
mot_path = "/"
|
||||||
credential_path = "/"
|
credential_path = "/"
|
||||||
@ -32,8 +25,6 @@ sql_usr = "None"
|
|||||||
sql_pwd = "azerty"
|
sql_pwd = "azerty"
|
||||||
sql_host = "https://example.com"
|
sql_host = "https://example.com"
|
||||||
sql_database = "MsRewards"
|
sql_database = "MsRewards"
|
||||||
dev = False
|
|
||||||
norvege = False
|
norvege = False
|
||||||
database_error_override = False
|
database_error_override = False
|
||||||
fast = False
|
json_start = ""
|
||||||
very_custom=""
|
|
Loading…
Reference in New Issue
Block a user