je suis ptet en train de tout refaire mais chut

This commit is contained in:
piair 2024-01-17 17:22:26 +01:00
parent 7d81eb642e
commit d5ec96f1e8
8 changed files with 346205 additions and 176 deletions

314
V6.py
View File

@ -8,7 +8,6 @@ from modules.driver_tools import *
from modules.cards import * from modules.cards import *
import modules.globals as g import modules.globals as g
driver = g.driver driver = g.driver
display = g.display display = g.display
@ -28,7 +27,7 @@ def firefox_driver(mobile=False, headless=False):
chrome_options = webdriver.ChromeOptions() chrome_options = webdriver.ChromeOptions()
if mobile: if mobile:
chrome_options.add_argument(f"--user-agent={MOBILE_USER_AGENT}") chrome_options.add_argument(f"--user-agent={MOBILE_USER_AGENT}")
else : else:
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:
@ -36,26 +35,26 @@ def firefox_driver(mobile=False, headless=False):
chrome_options.add_argument(f'--proxy-server={PROXY}') 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, ldriver=driver, log=g.full_log): def log_error(error, ldriver=driver, log=g.full_log):
global driver global driver
if ldriver is None: if ldriver is None:
ldriver = driver ldriver = driver
if type(error) != str : if type(error) != str:
error = format_error(error) error = format_error(error)
printf(f"\n\n\033[93m Erreur : {str(error)} \033[0m\n\n") printf(f"\n\n\033[93m Erreur : {str(error)} \033[0m\n\n")
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:
f.write(ldriver.page_source) f.write(ldriver.page_source)
except : except:
f.write("the driver has closed or crashed. Can't access page content") f.write("the driver has closed or crashed. Can't access page content")
try : try:
img = display.waitgrab() img = display.waitgrab()
img.save("screenshot.png") img.save("screenshot.png")
except : except:
ldriver.save_screenshot("screenshot.png") ldriver.save_screenshot("screenshot.png")
if not log: if not log:
embed = Embed( embed = Embed(
@ -72,8 +71,8 @@ def log_error(error, ldriver=driver, log=g.full_log):
file = File("screenshot.png") file = File("screenshot.png")
embed.set_image(url="attachment://screenshot.png") embed.set_image(url="attachment://screenshot.png")
embed.set_footer(text=g._mail) embed.set_footer(text=g._mail)
webhookFailure.send(embed=embed, username="error", file=file, avatar_url = g.avatar_url) webhookFailure.send(embed=embed, username="error", file=file, avatar_url=g.avatar_url)
webhookFailure.send(username="error", file=File("page.html"), avatar_url = g.avatar_url) webhookFailure.send(username="error", file=File("page.html"), avatar_url=g.avatar_url)
# 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
@ -83,7 +82,6 @@ def close_tab(tab, SwitchTo=0) -> None:
driver.switch_to.window(driver.window_handles[SwitchTo]) driver.switch_to.window(driver.window_handles[SwitchTo])
# 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:
@ -124,7 +122,7 @@ def play_quiz2(override=10) -> None:
def play_quiz8(): def play_quiz8():
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}") printf(f"play_quiz8 : start, override : {override}")
try: try:
counter = 0 counter = 0
@ -132,29 +130,29 @@ def play_quiz8():
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):
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)) printf(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 counter += 1
if g.log : if g.log:
progressBar(counter, 16, name="Quiz 8") 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()
sleep(1) sleep(1)
except exceptions.NoSuchElementException : except exceptions.NoSuchElementException:
driver.refresh() driver.refresh()
sleep(10) sleep(10)
answer_elem = driver.find_element(By.ID, answer_id) answer_elem = driver.find_element(By.ID, answer_id)
answer_elem.click() answer_elem.click()
except ElementClickInterceptedException : except ElementClickInterceptedException:
rgpd_popup(driver) rgpd_popup(driver)
correct_answers.append(answer_id) correct_answers.append(answer_id)
@ -196,7 +194,7 @@ def do_poll():
printf("do_poll : start") printf("do_poll : start")
try: 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])}")
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)
@ -208,30 +206,30 @@ def do_poll():
def all_cards(): def all_cards():
#input("1") # 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")
custom_sleep(2) custom_sleep(2)
try : try:
promo() promo()
except Exception as e: except Exception as e:
printf("no promo card") printf("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()
driver.refresh() driver.refresh()
liste = driver.find_elements(By.CLASS_NAME, "c-card-content") liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
if(len(liste) < 10): if (len(liste) < 10):
log_error("Less than 10 cards. Most likely an error with login.", driver) log_error("Less than 10 cards. Most likely an error with login.", driver)
return("PAS ASSEZ DE CARTES") return ("PAS ASSEZ DE CARTES")
if (len(liste) < 20): # most likely not in france if (len(liste) < 20): # most likely not in france
printf("moins de 20 cartes. Probablement pas en France.") printf("moins de 20 cartes. Probablement pas en France.")
for i in range(len(liste)): for i in range(len(liste)):
printf(f"carte {i}") printf(f"carte {i}")
try : try:
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML")) checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
except StaleElementReferenceException : except StaleElementReferenceException:
driver.refresh() driver.refresh()
liste = driver.find_elements(By.CLASS_NAME, "c-card-content") liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
printf(f"staled, {len(liste)}") printf(f"staled, {len(liste)}")
@ -240,32 +238,32 @@ def all_cards():
driver.get("https://rewards.bing.com") driver.get("https://rewards.bing.com")
custom_sleep(10) custom_sleep(10)
liste = driver.find_elements(By.CLASS_NAME, "c-card-content") liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
try : try:
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML")) checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
except IndexError : except IndexError:
if i == len(liste) & i > 15 : if i == len(liste) & i > 15:
checked = False checked = False
#input("2") # input("2")
if checked: if checked:
custom_sleep(1.5) custom_sleep(1.5)
driver.execute_script("arguments[0].scrollIntoView();", liste[i]) driver.execute_script("arguments[0].scrollIntoView();", liste[i])
custom_sleep(1.5) custom_sleep(1.5)
#input("3") # input("3")
liste[i].click() liste[i].click()
#input("4") # input("4")
if len(driver.window_handles) > 1 : if len(driver.window_handles) > 1:
driver.switch_to.window(driver.window_handles[1]) driver.switch_to.window(driver.window_handles[1])
#input("5") # input("5")
try_play(driver.title) try_play(driver.title)
close_tab(driver.window_handles[1]) close_tab(driver.window_handles[1])
try : try:
driver.refresh() driver.refresh()
liste = driver.find_elements(By.CLASS_NAME, "c-card-content") liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
if ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML")) : if ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML")):
printf(f"carte {i} not okay. Retrying.") printf(f"carte {i} not okay. Retrying.")
try : try:
liste[i].click() liste[i].click()
except : except:
log_error("problème inconnu ? sauf si c'est un element obscure...", driver) log_error("problème inconnu ? sauf si c'est un element obscure...", driver)
driver.get("https://rewards.bing.com") driver.get("https://rewards.bing.com")
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML")) checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
@ -282,16 +280,16 @@ def all_cards():
log_error(f"Cart completion - log - 3 - after 10 sec", driver) log_error(f"Cart completion - log - 3 - after 10 sec", driver)
try: try:
try_play(driver.title) # go back to the main page try_play(driver.title) # go back to the main page
try : try:
close_tab(driver.window_handles[1]) close_tab(driver.window_handles[1])
except: except:
pass pass
except : except:
driver.get("https://rewards.bing.com") driver.get("https://rewards.bing.com")
except : except:
pass pass
else : else:
try : try:
welcome_tour(liste[i], driver) welcome_tour(liste[i], driver)
except Exception as e: except Exception as e:
printf("no new windows" + format_error(e)) printf("no new windows" + format_error(e))
@ -305,29 +303,30 @@ def promo():
wait_until_visible(By.ID, "promo-item", 5, driver) wait_until_visible(By.ID, "promo-item", 5, driver)
if not elm: if not elm:
break break
if i > 3 : if i > 3:
log_error("plus de 3 promo cards, probablement une pa skipable", driver) log_error("plus de 3 promo cards, probablement une pa skipable", driver)
try : try:
driver.find_element(By.CSS_SELECTOR, 'i[class="mee-icon pull-left icon mee-icon-Cancel ng-scope"]').click() driver.find_element(By.CSS_SELECTOR,
'i[class="mee-icon pull-left icon mee-icon-Cancel ng-scope"]').click()
except Exception as e: except Exception as e:
log_error(f"can't click to close : {e}") log_error(f"can't click to close : {e}")
return() return ()
try : try:
elm.click() elm.click()
except Exception as e: except Exception as e:
#log_error(e, driver) # log_error(e, driver)
driver.execute_script("arguments[0].click();", elm) driver.execute_script("arguments[0].click();", elm)
#log_error(e, driver) # log_error(e, driver)
printf(f"that should't be there (promo), but the workarround seemed to work {e}") printf(f"that should't be there (promo), but the workarround seemed to work {e}")
custom_sleep(3) custom_sleep(3)
if len(driver.window_handles) > 1 : if len(driver.window_handles) > 1:
driver.switch_to.window(driver.window_handles[len(driver.window_handles)-1]) driver.switch_to.window(driver.window_handles[len(driver.window_handles) - 1])
try_play(driver.title) try_play(driver.title)
close_tab(driver.window_handles[1]) close_tab(driver.window_handles[1])
else : else:
try : try:
spotify(driver) spotify(driver)
except : except:
printf("no new windows", driver) printf("no new windows", driver)
driver.get("https://rewards.bing.com") driver.get("https://rewards.bing.com")
driver.refresh() driver.refresh()
@ -337,6 +336,7 @@ def promo():
# Find out which type of action to do # Find out which type of action to do
def try_play(nom="inconnu"): 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 == 8 or number == 9:
try: try:
@ -383,8 +383,8 @@ def try_play(nom="inconnu"):
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 : else:
raise(NameError("going to next part")) raise (NameError("going to next part"))
except Exception as e: # if there is no start button, an error is thrown except Exception as e: # if there is no start button, an error is thrown
if "bt_PollRadio" in driver.page_source: if "bt_PollRadio" in driver.page_source:
try: try:
@ -398,7 +398,7 @@ def try_play(nom="inconnu"):
try: try:
number = driver.page_source.count("rqAnswerOption") number = driver.page_source.count("rqAnswerOption")
printf(f"recovery détecté. quiz : {number}") printf(f"recovery détecté. quiz : {number}")
play(number-1) play(number - 1)
except Exception as e: except Exception as e:
printf(f"try_play - 2 - {e}") printf(f"try_play - 2 - {e}")
@ -416,57 +416,57 @@ def try_play(nom="inconnu"):
def pwd_login(ldriver): def pwd_login(ldriver):
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, g._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, g._password)
pwd_elem.send_keys(Keys.ENTER) pwd_elem.send_keys(Keys.ENTER)
custom_sleep(2) custom_sleep(2)
# 2FA # 2FA
if "Entrez le code de sécurité" in ldriver.page_source : if "Entrez le code de sécurité" in ldriver.page_source:
try : try:
a2f_elem = ldriver.find_element(By.ID, "idTxtBx_SAOTCC_OTC") a2f_elem = ldriver.find_element(By.ID, "idTxtBx_SAOTCC_OTC")
a2f_elem.send_keys(g._otp.now()) a2f_elem.send_keys(g._otp.now())
a2f_elem.send_keys(Keys.ENTER) a2f_elem.send_keys(Keys.ENTER)
except Exception as e : except Exception as e:
log_error(e) log_error(e)
def cookie_login(ldriver): def cookie_login(ldriver):
printf("cookies_login : start") printf("cookies_login : start")
ldriver.get("https://login.live.com") ldriver.get("https://login.live.com")
try : try:
load_cookies(ldriver) load_cookies(ldriver)
except FileNotFoundError : except FileNotFoundError:
printf("No cookies file Found.") printf("No cookies file Found.")
return(False) return (False)
except Exception as e: except Exception as e:
#log_error(f"Error performing cookies login. Trying with password instead. \n{str(e)}", driver) # log_error(f"Error performing cookies login. Trying with password instead. \n{str(e)}", driver)
print("error with cookies login. IDK why (yet)") print("error with cookies login. IDK why (yet)")
return(False) return (False)
try : try:
ldriver.refresh() ldriver.refresh()
except Exception as e: except Exception as e:
printf(format_error(e)) printf(format_error(e))
printf("FIX YOUR SITE MS.......") printf("FIX YOUR SITE MS.......")
return(True) 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, cookies=False):
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: if cookies:
save_cookies(ldriver) save_cookies(ldriver)
for id in ["iNext", "KmsiCheckboxField", "id__0", "iLooksGood", "idSIButton9", "iCancel"]: for id in ["iNext", "KmsiCheckboxField", "id__0", "iLooksGood", "idSIButton9", "iCancel"]:
@ -479,11 +479,10 @@ def login_part_2(ldriver, cookies = False):
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):
try : try:
pwd_login(ldriver) pwd_login(ldriver)
login_part_2(ldriver, 0) login_part_2(ldriver, 0)
ldriver.get("https://rewards.bing.com/") ldriver.get("https://rewards.bing.com/")
@ -494,12 +493,12 @@ def login(ldriver):
except Exception as e: except Exception as e:
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}") # {choice(Liste_de_mot)}')
custom_sleep(uniform(1, 2)) custom_sleep(uniform(1, 2))
rgpd_popup(driver) rgpd_popup(driver)
@ -513,7 +512,7 @@ def bing_pc_search(override=randint(35, 40)):
try: try:
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) printf(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}')
@ -568,25 +567,28 @@ def log_points(account="unknown"):
driver.get("https://rewards.bing.com") driver.get("https://rewards.bing.com")
custom_sleep(1) custom_sleep(1)
if "/proofs/" in driver.current_url: 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") webhookFailure.send(f"Is /proof Useful in logpoints?", username="Dev tests",
for id in ["KmsiCheckboxField","iLooksGood", "idSIButton9", "iCancel"]: avatar_url="https://cdn.discordapp.com/attachments/793934298977009677/1144560898879541268/image.png")
for id in ["KmsiCheckboxField", "iLooksGood", "idSIButton9", "iCancel"]:
try: try:
driver.find_element(By.ID, id).click() driver.find_element(By.ID, id).click()
except Exception as e: except Exception as e:
pass 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) sleep(5)
log_error(f"Dev error, checking why it doesn't work (waited a bit, is this still white ?) {format_error(e)}", driver, True) log_error(
f"Dev error, checking why it doesn't work (waited a bit, is this still white ?) {format_error(e)}",
driver, True)
driver.refresh() driver.refresh()
sleep(5) sleep(5)
point = search('availablePoints\":([\d]+)', driver.page_source)[1] point = search('availablePoints\":([\d]+)', driver.page_source)[1]
return(point) return (point)
for _ in range (3): for _ in range(3):
try : try:
points = get_points() points = get_points()
break break
except Exception as e: except Exception as e:
@ -594,7 +596,7 @@ def log_points(account="unknown"):
log_error(e) log_error(e)
points = None points = None
if not points : if not points:
log_error(f"impossible d'avoir les points") log_error(f"impossible d'avoir les points")
custom_sleep(uniform(3, 20)) custom_sleep(uniform(3, 20))
@ -610,7 +612,7 @@ def log_points(account="unknown"):
else: else:
webhookSuccess.send(f"{account_name} actuellement à {str(points)} points") webhookSuccess.send(f"{account_name} actuellement à {str(points)} points")
try : try:
add_to_database(account_name, points) add_to_database(account_name, points)
except Exception as e: except Exception as e:
log_error(e) log_error(e)
@ -621,27 +623,29 @@ def fidelity():
try: try:
wait_until_visible(By.CSS_SELECTOR, 'div[class="pull-left spacer-48-bottom punchcard-row"]', browser=driver) wait_until_visible(By.CSS_SELECTOR, 'div[class="pull-left spacer-48-bottom punchcard-row"]', browser=driver)
answer_number = search("([0-9]) of ([0-9]) completed", driver.page_source) answer_number = search("([0-9]) of ([0-9]) completed", driver.page_source)
if answer_number is None : if answer_number is None:
answer_number = search("([0-9])&nbsp;défi\(s\) terminé\(s\) sur ([0-9])", driver.page_source) answer_number = search("([0-9])&nbsp;défi\(s\) terminé\(s\) sur ([0-9])", driver.page_source)
if answer_number is None: if answer_number is None:
answer_number = search("([0-9]) de ([0-9]) finalisé", driver.page_source) answer_number = search("([0-9]) de ([0-9]) finalisé", driver.page_source)
if answer_number is None : if answer_number is None:
answer_number = search("([0-9]) licence\(s\) sur ([0-9]) disponible\(s\)", driver.page_source) answer_number = search("([0-9]) licence\(s\) sur ([0-9]) disponible\(s\)", driver.page_source)
if answer_number is None : if answer_number is None:
answer_number = [0,0,0] answer_number = [0, 0, 0]
for _ in range(int(answer_number[2]) - int(answer_number[1])): for _ in range(int(answer_number[2]) - int(answer_number[1])):
driver.refresh() driver.refresh()
custom_sleep(2) custom_sleep(2)
card_elem = driver.find_element(By.CLASS_NAME, "spacer-48-bottom") card_elem = driver.find_element(By.CLASS_NAME, "spacer-48-bottom")
try : try:
button_text = search('<span class="pull-left margin-right-15">([^<^>]+)</span>',card_elem.get_attribute("innerHTML"))[1] button_text = search('<span class="pull-left margin-right-15">([^<^>]+)</span>',
card_elem.get_attribute("innerHTML"))[1]
bouton_card = driver.find_element(By.XPATH, f'//span[text()="{button_text}"]') bouton_card = driver.find_element(By.XPATH, f'//span[text()="{button_text}"]')
bouton_card.click() bouton_card.click()
except Exception as e1 : except Exception as e1:
try : try:
recover_elem = driver.find_element(By.XPATH,'/html/body/div[1]/div[2]/main/div[2]/div[2]/div[7]/div[3]/div[1]/a') recover_elem = driver.find_element(By.XPATH,
'/html/body/div[1]/div[2]/main/div[2]/div[2]/div[7]/div[3]/div[1]/a')
recover_elem.click() recover_elem.click()
except Exception as e2 : except Exception as e2:
log_error(f"fidélité - double erreur - e1 : {format_error(e1)} - e2 {format_error(e2)}") log_error(f"fidélité - double erreur - e1 : {format_error(e1)} - e2 {format_error(e2)}")
break break
custom_sleep(uniform(3, 5)) custom_sleep(uniform(3, 5))
@ -655,14 +659,16 @@ def fidelity():
printf("fidelity - done") printf("fidelity - done")
except Exception as e: except Exception as e:
log_error(e) log_error(e)
if driver.current_url != "https://rewards.bing.com": if driver.current_url != "https://rewards.bing.com":
driver.get("https://rewards.bing.com") driver.get("https://rewards.bing.com")
try : try:
pause = driver.find_element(By.CSS_SELECTOR, f'[class="c-action-toggle c-glyph f-toggle glyph-pause"]') # mettre le truc en pause pause = driver.find_element(By.CSS_SELECTOR,
f'[class="c-action-toggle c-glyph f-toggle glyph-pause"]') # mettre le truc en pause
pause.click() pause.click()
except Exception as e: except Exception as e:
printf(f"erreur lors du click de pause: probablement pas de cartes {e}") printf(f"erreur lors du click de pause: probablement pas de cartes {e}")
return("no cards") return ("no cards")
cartes = driver.find_elements(By.CSS_SELECTOR, f'[ng-repeat="item in $ctrl.transcludedItems"]') cartes = driver.find_elements(By.CSS_SELECTOR, f'[ng-repeat="item in $ctrl.transcludedItems"]')
nb_cartes = len(cartes) nb_cartes = len(cartes)
checked_list_all = driver.find_elements(By.CSS_SELECTOR, f'[ng-if="$ctrl.complete"]') checked_list_all = driver.find_elements(By.CSS_SELECTOR, f'[ng-if="$ctrl.complete"]')
@ -671,17 +677,18 @@ def fidelity():
checked_txt = checked_list_all[i].get_attribute("innerHTML") checked_txt = checked_list_all[i].get_attribute("innerHTML")
ok = checked_txt.count("StatusCircleOuter checkmark") ok = checked_txt.count("StatusCircleOuter checkmark")
total = checked_txt.count("StatusCircleOuter") total = checked_txt.count("StatusCircleOuter")
if (ok != total) : if (ok != total):
elm = driver.find_elements(By.CLASS_NAME, 'clickable-link')[i] elm = driver.find_elements(By.CLASS_NAME, 'clickable-link')[i]
if not "moviesandtv" in elm.get_attribute("innerHTML"): # not the film card if not "moviesandtv" in elm.get_attribute("innerHTML"): # not the film card
elm.click() elm.click()
driver.switch_to.window(driver.window_handles[len(driver.window_handles)-1]) driver.switch_to.window(driver.window_handles[len(driver.window_handles) - 1])
sub_fidelity() sub_fidelity()
close_tab(driver.window_handles[1]) close_tab(driver.window_handles[1])
custom_sleep(1) custom_sleep(1)
cartes = driver.find_elements(By.CSS_SELECTOR, f'[ng-repeat="item in $ctrl.transcludedItems"]') cartes = driver.find_elements(By.CSS_SELECTOR, f'[ng-repeat="item in $ctrl.transcludedItems"]')
checked_list_all = driver.find_elements(By.CSS_SELECTOR, f'[ng-if="$ctrl.complete"]') checked_list_all = driver.find_elements(By.CSS_SELECTOR, f'[ng-if="$ctrl.complete"]')
def mobile_alert_popup(): def mobile_alert_popup():
try: try:
alert = mobile_driver.switch_to.alert alert = mobile_driver.switch_to.alert
@ -697,13 +704,13 @@ def bing_mobile_search(override=randint(22, 25)):
mobile_driver = firefox_driver(mobile=True) mobile_driver = firefox_driver(mobile=True)
try: try:
login(mobile_driver) login(mobile_driver)
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))
rgpd_popup(mobile_driver) rgpd_popup(mobile_driver)
custom_sleep(uniform(1, 1.5)) custom_sleep(uniform(1, 1.5))
for i in range(override): # 20 for i in range(override): # 20
try : try:
mot = choice(Liste_de_mot) mot = choice(Liste_de_mot)
send_keys_wait(mobile_driver.find_element(By.ID, "sb_form_q"), mot) send_keys_wait(mobile_driver.find_element(By.ID, "sb_form_q"), mot)
mobile_driver.find_element(By.ID, "sb_form_q").send_keys(Keys.ENTER) mobile_driver.find_element(By.ID, "sb_form_q").send_keys(Keys.ENTER)
@ -722,22 +729,22 @@ def bing_mobile_search(override=randint(22, 25)):
mobile_driver.quit() mobile_driver.quit()
def daily_routine(custom = False): def daily_routine(custom=False):
try : try:
if not custom: # custom already login if not custom: # custom already login
login(driver) login(driver)
except Banned : except Banned:
log_error("This account is locked. Fix that. (-U ?)", driver) log_error("This account is locked. Fix that. (-U ?)", driver)
return() return ()
except Identity : except Identity:
log_error("This account has an issue. Fix that.", driver) log_error("This account has an issue. Fix that.", driver)
return() return ()
try: try:
all_cards() all_cards()
except Banned: except Banned:
log_error("banned", driver) log_error("banned", driver)
return("BANNED") return ("BANNED")
except Exception as e: except Exception as e:
log_error(e) log_error(e)
@ -766,14 +773,14 @@ def dev():
pass pass
def CustomStart(): def CustomStart():
if not g.islinux : 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.') raise NameError(
'You need to be on linux to do that, due to the utilisation of a module named enquieries, sorry.')
global driver global driver
system("clear") # clear from previous command to allow a clean choice system("clear") # clear from previous command to allow a clean choice
actions = ["tout", "daily", "pc", "mobile", "log_points","fidelity", "dev"] actions = ["tout", "daily", "pc", "mobile", "log_points", "fidelity", "dev"]
Actions = enquiries.choose("quels Actions ?", actions, multi=True) Actions = enquiries.choose("quels Actions ?", actions, multi=True)
liste = select_accounts() liste = select_accounts()
g.start_time = time() # Reset timer to the start of the actions g.start_time = time() # Reset timer to the start of the actions
@ -790,7 +797,7 @@ def CustomStart():
if "tout" in Actions: if "tout" in Actions:
daily_routine(True) daily_routine(True)
if "daily" in Actions: if "daily" in Actions:
#input("0") # input("0")
try: try:
all_cards() all_cards()
except Exception as e: except Exception as e:
@ -806,9 +813,9 @@ def CustomStart():
except Exception as e: except Exception as e:
log_error(e) log_error(e)
if "fidelity" in Actions: if "fidelity" in Actions:
try : try:
fidelity() fidelity()
except Exception as e : except Exception as e:
log_error(e) log_error(e)
if "dev" in Actions: if "dev" in Actions:
try: try:
@ -823,6 +830,7 @@ def CustomStart():
printf(f"CustomStart {e}") printf(f"CustomStart {e}")
driver.quit() driver.quit()
def very_custom_start(json): 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)
@ -833,16 +841,16 @@ def very_custom_start(json):
g._password = cred[1] g._password = cred[1]
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[j]:
start = True start = True
print(f"{g._mail} : {j}") print(f"{g._mail} : {j}")
except KeyError : except KeyError:
pass pass
#print(f"none is set to \"{j}\"") # print(f"none is set to \"{j}\"")
if start: if start:
driver = firefox_driver() driver = firefox_driver()
try : try:
if str(i) in json["unban"]: if str(i) in json["unban"]:
pwd_login(driver) # TODO : define only the first part of login pwd_login(driver) # TODO : define only the first part of login
print("\nGO TO exmaple.com TO PROCEED or wait 600 secs.") print("\nGO TO exmaple.com TO PROCEED or wait 600 secs.")
@ -851,44 +859,44 @@ def very_custom_start(json):
if driver.current_url == "https://example.com/": if driver.current_url == "https://example.com/":
print("proceeding") print("proceeding")
break break
else : else:
login(driver) login(driver)
except KeyError : except KeyError:
login(driver) login(driver)
try : try:
if str(i) in json["tout"]: if str(i) in json["tout"]:
daily_routine(True) daily_routine(True)
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["daily"]:
try: try:
all_cards() all_cards()
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 \"daily\"") # print("none is set to \"daily\"")
try : try:
if str(i) in json["pc"]: if str(i) in json["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\"") # print("none is set to \"pc\"")
try : try:
if str(i) in json["mobile"]: if str(i) in json["mobile"]:
try: try:
bing_mobile_search() bing_mobile_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 \"mobile\"") # print("none is set to \"mobile\"")
try: try:
log_points(g._mail) log_points(g._mail)
except Exception as e: except Exception as e:
@ -897,29 +905,30 @@ def very_custom_start(json):
driver.close() driver.close()
display.stop() display.stop()
if g.very_custom :
if g.very_custom:
dict_data = json.loads(g.very_custom.replace("'", "\"")) dict_data = json.loads(g.very_custom.replace("'", "\""))
very_custom_start(dict_data) very_custom_start(dict_data)
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()
#webhookFailure.send(f"Starting on this config", username="Check de lancement", avatar_url="https://cdn-icons-png.flaticon.com/512/1688/1688988.png") # webhookFailure.send(f"Starting on this config", username="Check de lancement", avatar_url="https://cdn-icons-png.flaticon.com/512/1688/1688988.png")
if g.dev : if g.dev:
driver = firefox_driver() driver = firefox_driver()
#input("kill ?") # input("kill ?")
driver.quit() driver.quit()
elif g.custom_start: elif g.custom_start:
CustomStart() CustomStart()
elif g.unban: elif g.unban:
g._mail, g._password = select_accounts(False)[0] g._mail, g._password = select_accounts(False)[0]
driver = firefox_driver() driver = firefox_driver()
try : try:
login(driver) login(driver)
except Banned: except Banned:
unban() unban()
@ -927,7 +936,8 @@ else :
else: 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", avatar_url="https://cdn-icons-png.flaticon.com/512/1688/1688988.png") webhookFailure.send(f"Updated to {g.update_version}", username="UPDATE",
avatar_url="https://cdn-icons-png.flaticon.com/512/1688/1688988.png")
for cred in g._cred: for cred in g._cred:
if cred[0] != "": if cred[0] != "":
g._mail = cred[0] g._mail = cred[0]
@ -941,7 +951,7 @@ else :
driver.implicitly_wait(3) driver.implicitly_wait(3)
try: try:
attente = uniform(1200, 3600) attente = uniform(1200, 3600)
printf(f"Attente de {round(attente/60)} min avant de démarrer") printf(f"Attente de {round(attente / 60)} min avant de démarrer")
daily_routine() daily_routine()
driver.quit() driver.quit()
custom_sleep(attente) custom_sleep(attente)

83
V7/V7.py Normal file
View File

@ -0,0 +1,83 @@
from playwright.sync_api import sync_playwright, expect, Page
from playwright_stealth import stealth_sync
from logging import *
from actions.checks import check_logged_in
from actions.quiz import play_quiz_2, play_quiz_4, play_quiz_8, play_poll, detect_quiz_type, play
from actions.login import login
from actions.websearch import pc_search
basicConfig(encoding='utf-8', level=DEBUG)
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')
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'Carte {i} : {not "mee-icon-AddMedium" in card.inner_html()}')
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:
"mee-icon-AddMedium" in card.inner_html()
except AssertionError as 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'Carte {c} : {not "mee-icon-AddMedium" in card.inner_html()}')
c += 1
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 routine(page: Page) -> None:
all_cards(page)
pc_search(page)
with sync_playwright() as p:
browser = p.firefox.launch_persistent_context("./data/", headless=False)
page = browser.new_page()
stealth_sync(page)
login(page, input("mail ? "), input("password ? "))
all_cards(page)
browser.close()
"""
TODO :
Fidelity management.
Daily search
custom start
vnc
mobile search
"""

10
V7/actions/checks.py Normal file
View File

@ -0,0 +1,10 @@
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.')

30
V7/actions/login.py Normal file
View File

@ -0,0 +1,30 @@
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.")

115
V7/actions/quiz.py Normal file
View File

@ -0,0 +1,115 @@
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
elif "rqQuestionState" in page.content():
# The quiz is already started
return page.content().count("rqAnswerOption") - 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:
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
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.")
def play_poll(page: Page):
info("Playing poll.")
answer_elem = page.locator(f"#btoption{choice([0, 1])}")
answer_elem.click()
info("Poll successful.")

23
V7/actions/websearch.py Normal file
View File

@ -0,0 +1,23 @@
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")

27
V7/logger.py Normal file
View File

@ -0,0 +1,27 @@
from playwright.sync_api import Page
from discord import Colour, Embed, File, RequestsWebhookAdapter, Webhook
class Logger:
def __init__(self, link):
self.wh = Webhook.from_url(link, adapter=RequestsWebhookAdapter())
def error(self, page: Page, error: str):
with open("page.html", "w") as f:
try:
f.write(page.content())
except Exception as e:
f.write(f"the driver has closed or crashed. Can't access page content\n{e}")
embed = Embed(
title="An Error has occurred",
description=str(error),
colour=Colour.red(),
)
try:
page.screenshot(path="screenshot.png")
except Exception as e:
with open("screenshot.png", "w") as f:
f.write(f"Can't take screenshot\n{e}")
file = File("screenshot.png")
embed.set_image(url="attachment://screenshot.png")
self.wh.send(embed=embed, username="error", file=file)

345731
user_data/french Normal file

File diff suppressed because it is too large Load Diff