From c9aa75e61cf1d21daaf88657b0e1b45e6a950c46 Mon Sep 17 00:00:00 2001 From: piair338 Date: Mon, 31 Oct 2022 14:32:39 +0000 Subject: [PATCH] custom error + better code + some things --- V4.py | 157 +++++++++++++++++++++++++++------------------- modules/config.py | 39 ++++++++++-- modules/error.py | 5 ++ modules/tools.py | 1 - 4 files changed, 132 insertions(+), 70 deletions(-) create mode 100644 modules/error.py diff --git a/V4.py b/V4.py index 7522966..30e6dbd 100755 --- a/V4.py +++ b/V4.py @@ -19,6 +19,7 @@ from selenium.common.exceptions import TimeoutException, NoSuchElementException from modules.db import add_to_database from modules.config import * from modules.tools import * +from modules.error import * global driver @@ -126,18 +127,11 @@ def Close(fenetre, SwitchTo=0): #Deal with RGPD popup as well as some random popup like 'are you satisfied' one def RGPD(): - try: - driver.find_element(By.ID, "bnp_btn_accept").click() - except: - pass - try: - driver.find_element(By.ID, "bnp_hfly_cta2").click() - except: - pass - try : - driver.find_element(By.id, "bnp_hfly_close").click() #are you satisfied popup - except : - pass + for i in ["bnp_btn_accept", "bnp_hfly_cta2", "bnp_hfly_close"] : + try: + driver.find_element(By.ID, ).click() + except: + pass """ @@ -373,16 +367,16 @@ it uses global variable _mail and _password to login """ def login(): global driver - def sub_login(): + def sub_login(): printf("sublogin : start") driver.get("https://www.bing.com/rewardsapp/flyout") - try: - driver.find_element(By.CSS_SELECTOR, f'[title="Rejoindre"]').click() # depend of the language of the page - except: - try : - driver.find_element(By.CSS_SELECTOR, f'[title="Join now"]').click() # depend of the language of the page - except : - raise ValueError('already logged in') + for i in [f'[title="Rejoindre"]', f'[title="Join now"]', f'[title="Rejoindre maintenant"]'] : + try: + driver.find_element(By.CSS_SELECTOR, i).click() # depend of the language of the page + break + except: + pass + WaitUntilVisible(By.ID, "i0116", browser = driver) mail = driver.find_element(By.ID, "i0116") @@ -393,6 +387,12 @@ def login(): send_keys_wait(pwd, _password) pwd.send_keys(Keys.ENTER) CustomSleep(5) + + if ('Abuse' in driver.current_url) : + LogError("account suspended", driver, _mail) + raise Banned() + + for i in ["KmsiCheckboxField","iLooksGood", "idSIButton9", "iCancel"]: try: driver.find_element(By.ID, i).click() @@ -413,6 +413,8 @@ def login(): try : sub_login() return (driver.current_window_handle) + except Banned: + raise Banned() except Exception as e: LogError("login - 3 - " + str(e), driver, _mail) driver.close() @@ -464,7 +466,29 @@ def BingPcSearch(override=randint(35, 40)): print("\n\n") - +def unban(): + driver.find_element(By.ID, "StartAction").click() + txt = driver.page_source + uuid1 = findall('wlspispHIPPhoneInput([a-z0-9]+)', txt)[0] + uuid2 = findall('wlspispHipSendCode([a-z0-9]+)', txt)[0] + uuid3 = findall('wlspispSolutionElement([a-z0-9]+)', txt)[0] + phone = input("entrez le numero de téléphone : +33") + WaitUntilVisible(By.ID, "wlspispHIPPhoneInput" + uuid1) + phone_box = driver.find_element(By.ID, "wlspispHIPPhoneInput" + uuid1) + phone_box.send_keys(phone) + WaitUntilVisible(By.ID, "wlspispHipSendCode" + uuid2) + send_link = driver.find_element(By.ID, "wlspispHipSendCode" + uuid2) + send_link.click() + WaitUntilVisible(By.ID, "wlspispSolutionElement" + uuid3) + answer_box = driver.find_element(By.ID, "wlspispSolutionElement" + uuid3) + answer = input("entrez le contenu du msg : ") + answer_box.send_keys(answer) + send_box = driver.find_element(By.ID, "ProofAction") + send_box.click() + WaitUntilVisible(By.ID, "FinishAction") + continue_box = driver.find_element(By.ID, "FinishAction") + continue_box.click() + def TryPlay(nom="inconnu"): RGPD() @@ -699,6 +723,7 @@ def Mlogin(echec): MobileDriver.quit() return True + def MRGPD(): try: MobileDriver.find_element(By.ID, "bnp_btn_accept").click() @@ -709,6 +734,7 @@ def MRGPD(): except Exception as e: pass + def Alerte(): try: alert = MobileDriver.switch_to.alert @@ -760,40 +786,37 @@ def BingMobileSearch(override=randint(22, 25)): def DailyRoutine(custom = False): - if not custom : - MainWindows = login() - else : - MainWindows = "" + try : + login() + except Banned : + LogError("THIS ACCOUND IS BANNED. FIX THIS ISSUE WITH -U", driver, mail) + return() + + try: + AllCard() + except Exception as e: + LogError(f"DailyRoutine - AllCard - \n{e}", driver, _mail) + + try: + BingPcSearch() + except Exception as e: + LogError(f"DailyRoutine - BingPcSearch - \n{e}", driver, _mail) + + try: + Fidelite() + except Exception as e: + LogError(f"DailyRoutine - Fidelité - \n{e}", driver, _mail) - if MainWindows != "STOP" : - try: - AllCard() - except Exception as e: - LogError(f"DailyRoutine - AllCard - \n{e}", driver, _mail) + try: + BingMobileSearch() + except Exception as e: + LogError(f"DailyRoutine - BingMobileSearch - \n{e}", driver, _mail) - try: - BingPcSearch() - except Exception as e: - LogError(f"DailyRoutine - BingPcSearch - \n{e}", driver, _mail) - CustomSleep(uniform(3, 20)) + try: + LogPoint(_mail) + except Exception as e: + LogError(f"DailyRoutine - LogPoint - \n{e}", driver, _mail) - try: - Fidelite() - except Exception as e: - LogError(f"DailyRoutine - Fidelité - \n{e}", driver, _mail) - - try: - BingMobileSearch() - except Exception as e: - LogError(f"DailyRoutine - BingMobileSearch - \n{e}", driver, _mail) - CustomSleep(uniform(3, 20)) - - try: - LogPoint(_mail) - except Exception as e: - LogError(f"DailyRoutine - LogPoint - \n{e}", driver, _mail) - else : - LogError(f"probleme de login sur le comte {_mail}", driver, _mail) def close(): @@ -809,20 +832,14 @@ def CustomStart(Credentials): if not LINUX_HOST : raise NameError('You need to be on linux to do that, due to the utilisation of a module named enquieries, sorry.') global driver - global _mail - global _password - - ids = [x[0] for x in Credentials] # list of all email adresses - actions = ["tout", "daily", "pc", "mobile", "LogPoint","Fidelite", "dev"] + global _mail, _password system("clear") # clear from previous command to allow a clean choice - Comptes = enquiries.choose("quels comptes ?", ids, multi=True) + actions = ["tout", "daily", "pc", "mobile", "LogPoint","Fidelite", "dev"] Actions = enquiries.choose("quels Actions ?", actions, multi=True) - for i in Comptes: + for _mail, _password in SelectAccount(): - _mail = Credentials[ids.index(i)][0] - _password = Credentials[ids.index(i)][1] driver = FirefoxDriver() driver.implicitly_wait(10) @@ -869,14 +886,24 @@ def CustomStart(Credentials): driver.close() -with open(CREDENTIALS_PATH) as f: - reader = reader(f) - Credentials = list(reader) +def SelectAccount(multiple = True): + system("clear") # clear from previous command to allow a clean choice + emails = [x[0] for x in Credentials] # list of all email adresses + emailsSelected = enquiries.choose("quels comptes ?", emails, multi=multiple) + return([x for x in Credentials if x[0] in emailsSelected]) -shuffle(Credentials) if CUSTOM_START: CustomStart(Credentials) +elif UNBAN: + _mail, _password = SelectAccount(False)[0] + try : + login() + raise NotBanned + except Banned : + unban() + except NotBanned : + LogError("you are not cureently banned on this account") else: for _mail, _password in Credentials: system("pkill -9 firefox") diff --git a/modules/config.py b/modules/config.py index cec70f7..535ecfa 100644 --- a/modules/config.py +++ b/modules/config.py @@ -18,11 +18,30 @@ Setup for option, like --override or --fulllog parser = argparse.ArgumentParser() parser.add_argument( - "-o", "--override", help="override", dest="override", action="store_true" + "-o", + "--override", + help="override", + dest="override", + action="store_true" ) + parser.add_argument( - "-l", "--log", dest="log", help="enable logging in terminal", action="store_true" + "-u", + "--unban", + help="unban an account", + dest="unban", + action="store_true" ) + + +parser.add_argument( + "-l", + "--log", + dest="log", + help="enable logging in terminal", + action="store_true" +) + parser.add_argument( "-fl", "--fulllog", @@ -31,15 +50,23 @@ parser.add_argument( action="store_true", ) parser.add_argument( - "-r", "--risky", help="make the program faster, probably better risk of ban", dest="fast", action="store_true" + "-r", + "--risky", + help="make the program faster, probably better risk of ban", + dest="fast", + action="store_true" ) parser.add_argument( - "-c", "--config", help="Choose a specific config file", type=argparse.FileType('r') + "-c", + "--config", + help="Choose a specific config file", + type=argparse.FileType('r') ) args = parser.parse_args() CUSTOM_START = args.override +UNBAN = args.unban LOG = args.log FULL_LOG = args.fulllog FAST = args.fast @@ -115,3 +142,7 @@ else : g.close() +with open(CREDENTIALS_PATH) as f: + reader = reader(f) + Credentials = list(reader) +shuffle(Credentials) \ No newline at end of file diff --git a/modules/error.py b/modules/error.py new file mode 100644 index 0000000..0e13540 --- /dev/null +++ b/modules/error.py @@ -0,0 +1,5 @@ +class Banned(Exception): + pass + +class NotBanned(Exception): + pass \ No newline at end of file diff --git a/modules/tools.py b/modules/tools.py index 0f6d17f..ca525d4 100644 --- a/modules/tools.py +++ b/modules/tools.py @@ -90,7 +90,6 @@ def CustomSleep(temps): passe += 0.125 print(f"{points[i]} - {round(float(temps) - passe, 3)}", end="\r") print(" ", end="\r") - else: sleep(temps) except KeyboardInterrupt :