small things here and there

This commit is contained in:
piair 2024-02-27 01:41:40 +01:00
parent 2cc1fcbc72
commit 31e38b7258

191
V6.py
View File

@ -398,7 +398,7 @@ def try_play(nom="inconnu"):
# 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, cred: UserCredentials): 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)
@ -420,71 +420,55 @@ def pwd_login(ldriver, cred: UserCredentials):
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, cred: Credentials): def login(ldriver, cred: UserCredentials):
try: try:
pwd_login(ldriver, cred) 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(
@ -498,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)
@ -508,52 +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
# 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]
@ -573,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:
@ -648,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))
@ -672,21 +638,21 @@ 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(cred: UserCredentials, 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, cred) login(driver, cred)
except Banned: except Banned:
log_error("This account is locked.", driver) log_error("This account is locked.", driver)
@ -699,55 +665,50 @@ def daily_routine(cred: UserCredentials, custom=False):
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 json_start(json): def json_start(json_entry, cred: UserCredentials):
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
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) 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)
@ -755,18 +716,18 @@ def json_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:
@ -775,7 +736,7 @@ def json_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:
@ -783,9 +744,9 @@ def json_start(json):
except KeyError: except KeyError:
pass pass
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:
@ -794,35 +755,31 @@ def json_start(json):
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("'", "\""))
json_start(dict_data) if g.json_start:
dict_data = json.loads(g.json_start.replace("'", "\""))
json_start(dict_data, c.UserCredentials)
else: else:
c = Config(args)
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.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")
while c.UserCredentials.is_valid(): while c.UserCredentials.is_valid():
g._mail = c.UserCredentials.get_mail()
g._password = c.UserCredentials.get_password()
if c.UserCredentials.tfa_enable():
g._otp = TOTP(c.UserCredentials.get_tfa())
custom_sleep(1) custom_sleep(1)
info("Starting driver.") info("Starting driver.")
driver = create_driver() driver = create_driver()