oh boy i probably just broke everything

This commit is contained in:
piair338 2022-10-24 18:08:33 +00:00
parent f8e9daaedd
commit 3155b545dc
3 changed files with 344 additions and 367 deletions

517
V4.py
View File

@ -1,20 +1,13 @@
#!/usr/bin/python3.10 #!/usr/bin/python3.10
import asyncio import asyncio
import configparser
from csv import reader from csv import reader
from os import sys, system, path from os import sys, system, path
from random import choice, randint, shuffle, uniform from random import choice, randint, shuffle, uniform
from re import findall, search from re import findall, search
from sys import platform from sys import platform
from time import sleep, time from time import sleep
from requests import get from requests import get
from datetime import timedelta from datetime import timedelta
import discord
from discord import ( # Importing discord.Webhook and discord.RequestsWebhookAdapter
Colour,
RequestsWebhookAdapter,
Webhook,
)
from selenium import webdriver from selenium import webdriver
from selenium.common import exceptions from selenium.common import exceptions
from selenium.webdriver.common.by import By from selenium.webdriver.common.by import By
@ -23,120 +16,12 @@ from selenium.webdriver.firefox.options import Options
from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException, NoSuchElementException from selenium.common.exceptions import TimeoutException, NoSuchElementException
import argparse
from modules.db import add_to_database from modules.db import add_to_database
from modules.config import *
from modules.tools import *
"""
Setup for option, like --override or --fulllog
"""
parser = argparse.ArgumentParser()
parser.add_argument(
"-o", "--override", help="override", dest="override", action="store_true"
)
parser.add_argument(
"-l", "--log", dest="log", help="enable logging in terminal", action="store_true"
)
parser.add_argument(
"-fl",
"--fulllog",
dest="fulllog",
help="enable full logging in discord",
action="store_true",
)
parser.add_argument(
"-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')
)
args = parser.parse_args()
CUSTOM_START = args.override
LOG = args.log
FULL_LOG = args.fulllog
FAST = args.fast
if CUSTOM_START :
LOG = True
#SOON (maybe) (no)
#logpath = ("/".join(__file__.split("/")[:-1])+"/LogFile.out")
#logfile = open(logpath, "w")
# gloabal variables used later in the code
LINUX_HOST = platform == "linux" # if the computer running this programm is linux, it allow more things
START_TIME = time()
global driver global driver
driver = None
if LINUX_HOST:
import enquiries
else:
system("") # enable colors in windows cmd
#reading configuration
config_path = f"{path.abspath( path.dirname( __file__ ) )}/user_data/config.cfg"
if args.config :
config_path = path.abspath(args.config.name)
config = configparser.ConfigParser()
config.read(config_path)
# path configurations
MotPath = config["PATH"]["motpath"]
CREDENTIALS_PATH = config["PATH"]["logpath"]
# discord configuration
DISCORD_SUCCESS_LINK = config["DISCORD"]["successlink"]
DISCORD_ERROR_LINK = config["DISCORD"]["errorlink"]
DISCORD_ENABLED_ERROR = config["DISCORD"]["DiscordErrorEnabled"] == "True"
DISCORD_ENABLED_SUCCESS = config["DISCORD"]["DiscordSuccessEnabled"]== "True"
if DISCORD_ENABLED_ERROR:
webhookFailure = Webhook.from_url(DISCORD_ERROR_LINK, adapter=RequestsWebhookAdapter())
if DISCORD_ENABLED_SUCCESS:
webhookSuccess = Webhook.from_url(DISCORD_SUCCESS_LINK, adapter=RequestsWebhookAdapter())
# base settings
FidelityLink = config["SETTINGS"]["FidelityLink"]
DISCORD_EMBED = config["SETTINGS"]["embeds"] == "True" #print new point value in an embed
Headless = config["SETTINGS"]["headless"] == "True"
# proxy settings
proxy_enabled = config["PROXY"]["proxy_enabled"] == "True"
proxy_address = config["PROXY"]["url"]
proxy_port = config["PROXY"]["port"]
# MySQL settings
sql_enabled = config["SQL"]["sql_enabled"] == "True"
sql_usr = config["SQL"]["usr"]
sql_pwd = config["SQL"]["pwd"]
sql_host = config["SQL"]["host"]
sql_database = config["SQL"]["database"]
# Other seetings
IPV6_CHECKED = config["OTHER"]["ipv6"]
CLAIM_AMAZON = config["OTHER"]["claim_amazon"]
g = open(MotPath, "r", encoding="utf-8")
lines = g.readlines()
if len(lines) < 3 :
Liste_de_mot = list(lines[0].split(","))
else :
Liste_de_mot = [x.replace('\n', "") for x in lines]
g.close()
def WaitUntilVisible(by, id, to = 20, browser = driver): def WaitUntilVisible(by, id, to = 20, browser = driver):
@ -146,17 +31,6 @@ def WaitUntilVisible(by, id, to = 20, browser = driver):
print(f"element not found after {to}s") print(f"element not found after {to}s")
def Timer(text="undefined"):
return(f"[{_mail} - {timedelta(seconds = round(float(time() - START_TIME)))}] " + str(text))
def check_ipv4():
driver.get("https://api64.ipify.org")
elm = driver.find_element(By.TAG_NAME, "body")
if len(elm.text.split('.')) == 4 :
return True
return False
def claim_amazon(): def claim_amazon():
try : try :
@ -196,14 +70,14 @@ def claim_amazon():
webhookFailure.send(_mail +" - "+ fcode) webhookFailure.send(_mail +" - "+ fcode)
return(1) return(1)
else : else :
LogError("impossible de localiser le code ") LogError("impossible de localiser le code ", driver)
return(1) return(1)
else : else :
LogError("la recuperation ne peux pas être automatique") LogError("la recuperation ne peux pas être automatique", driver)
return(0) return(0)
except Exception as e : except Exception as e :
LogError(f'problème dans la recuperation : {str(e)}') LogError(f'problème dans la recuperation : {str(e)}', driver)
def setup_proxy(ip, port) : def setup_proxy(ip, port) :
@ -242,22 +116,12 @@ def FirefoxDriver(mobile=False, Headless=Headless):
return driver return driver
def printf(txt, end="", Mobdriver=driver):
if LOG:
print(Timer(txt))
if FULL_LOG:
try :
LogError(Timer(txt), Mobdriver=Mobdriver)
except Exception as e:
print("\n" + Timer(e) + "\n" + Timer(txt) + "\n" )
def CustomSleep(temps): def CustomSleep(temps):
try : try :
if FAST and temps > 50: if FAST and temps > 50:
sleep(temps/10) sleep(temps/10)
return() return()
if LOG or not LINUX_HOST: #only print sleep when user see it if not LOG or not LINUX_HOST: #only print sleep when user see it
points = ["", "", "", "", "", "", "", ""] points = ["", "", "", "", "", "", "", ""]
passe = 0 passe = 0
for i in range(int(temps)): for i in range(int(temps)):
@ -273,37 +137,6 @@ def CustomSleep(temps):
printf("attente annulée") printf("attente annulée")
def LogError(message, log=FULL_LOG, Mobdriver=None):
print(f"\n\n\033[93m Erreur : {str(message)} \033[0m\n\n")
if Mobdriver:
gdriver = Mobdriver
else:
gdriver = driver
if LINUX_HOST and DISCORD_ENABLED_ERROR:
with open("page.html", "w") as f:
f.write(gdriver.page_source)
gdriver.save_screenshot("screenshot.png")
if not log:
embed = discord.Embed(
title="An Error has occured",
description=str(message),
colour=Colour.red(),
)
else:
embed = discord.Embed(
title="Full log is enabled",
description=str(message),
colour=Colour.blue(),
)
file = discord.File("screenshot.png")
embed.set_image(url="attachment://screenshot.png")
embed.set_footer(text=_mail)
webhookFailure.send(embed=embed, file=file)
webhookFailure.send(file=discord.File("page.html"))
def progressBar(current, total=30, barLength=20, name="Progress"): def progressBar(current, total=30, barLength=20, name="Progress"):
percent = float(current + 1) * 100 / total percent = float(current + 1) * 100 / total
@ -368,7 +201,7 @@ def PlayQuiz2(override=10):
driver.execute_script("arguments[0].click();", elem) driver.execute_script("arguments[0].click();", elem)
except Exception as e: except Exception as e:
LogError("PlayQuiz2" + str(e)) LogError("PlayQuiz2" + str(e), driver)
break break
printf("PlayQuiz2 finis") printf("PlayQuiz2 finis")
@ -387,7 +220,7 @@ def PlayQuiz8(override=3):
if 'iscorrectoption="True" ' in Card.get_attribute("outerHTML"): if 'iscorrectoption="True" ' in Card.get_attribute("outerHTML"):
ListeOfGood.append(f"rqAnswerOption{i-1}") # premier div = 3 ? ListeOfGood.append(f"rqAnswerOption{i-1}") # premier div = 3 ?
except Exception as e: except Exception as e:
LogError(f"playquiz8 - 1 - {e}") LogError(f"playquiz8 - 1 - {e}", driver)
shuffle(ListeOfGood) shuffle(ListeOfGood)
for i in ListeOfGood: for i in ListeOfGood:
@ -401,7 +234,7 @@ def PlayQuiz8(override=3):
try: try:
driver.execute_script("arguments[0].click();", elem) driver.execute_script("arguments[0].click();", elem)
except Exception as e: except Exception as e:
LogError(f"playquizz8 - 2 - {e}") LogError(f"playquizz8 - 2 - {e}", driver)
except exceptions.NoSuchElementException as e : except exceptions.NoSuchElementException as e :
try : try :
driver.refresh() driver.refresh()
@ -409,15 +242,15 @@ def PlayQuiz8(override=3):
elem = driver.find_element(By.ID, i) elem = driver.find_element(By.ID, i)
elem.click() elem.click()
except Exception as e : except Exception as e :
LogError(f"playquizz8 - 5 - {e}") LogError(f"playquizz8 - 5 - {e}", driver)
except Exception as e: except Exception as e:
if CUSTOM_START: if CUSTOM_START:
printf(f"playquiz8 - 3 - {e}") # may append during printf(f"playquiz8 - 3 - {e}") # may append during
else: else:
LogError(f"playquizz8 - 3 - {e}") LogError(f"playquizz8 - 3 - {e}", driver)
except Exception as e: except Exception as e:
LogError(f"PlayQuiz8 - 4 - {e} \n ListOfGood : {str(ListeOfGood)}") LogError(f"PlayQuiz8 - 4 - {e} \n ListOfGood : {str(ListeOfGood)}", driver)
printf("PlayQuiz8 : fin ") printf("PlayQuiz8 : fin ")
@ -438,8 +271,8 @@ def PlayQuiz4(override=None):
RGPD() RGPD()
reponse = search('correctAnswer":"([^"]+)', txt)[1] # je suis pas sur qu'il y ait un espace reponse = search('correctAnswer":"([^"]+)', txt)[1] # je suis pas sur qu'il y ait un espace
reponse = reponse.replace("\\u0027", "'") # il faut cancel l'unicode avec un double \ (on replacer les caracteres en unicode en caracteres utf-8) reponse = reponse.replace("\\u0027", "'") # il faut cancel l'unicode avec un double \ (on replacer les caracteres en unicode en caracteres utf-8)
printf(f"validation de la reponse ",end="\r",) printf(f"validation de la reponse ")
printf(f"validation de la reponse {i+1}/{override} {reponse}", end="\r") printf(f"validation de la reponse {i+1}/{override} {reponse}")
try: try:
elem = driver.find_element( elem = driver.find_element(
By.CSS_SELECTOR, f'[data-option="{reponse}"]' By.CSS_SELECTOR, f'[data-option="{reponse}"]'
@ -449,7 +282,7 @@ def PlayQuiz4(override=None):
driver.execute_script("arguments[0].click();", elem) driver.execute_script("arguments[0].click();", elem)
except Exception as e: except Exception as e:
LogError(f"PlayQuiz4 {str(e)}") LogError(f"PlayQuiz4 {str(e)}", driver)
raise ValueError(e) raise ValueError(e)
printf("PlayQuiz4 : end") printf("PlayQuiz4 : end")
@ -467,7 +300,7 @@ def PlayPoll():
driver.execute_script("arguments[0].click();", elem) driver.execute_script("arguments[0].click();", elem)
CustomSleep(uniform(2, 2.5)) CustomSleep(uniform(2, 2.5))
except Exception as e: except Exception as e:
LogError("PlayPoll" + str(e)) LogError("PlayPoll" + str(e), driver)
raise ValueError(e) raise ValueError(e)
printf("PlayPoll : end") printf("PlayPoll : end")
@ -506,7 +339,7 @@ def AllCard(): # fonction qui clique sur les cartes
except Exception as e: except Exception as e:
printf(f"Allcard card {titre} error ({e})") printf(f"Allcard card {titre} error ({e})")
except Exception as e: except Exception as e:
LogError(f"Dailycards {e}") LogError(f"Dailycards {e}", driver)
try: try:
dailyCards() dailyCards()
@ -552,7 +385,7 @@ def AllCard(): # fonction qui clique sur les cartes
weekly_cards() weekly_cards()
break break
except Exception as e: except Exception as e:
LogError(f"weekly_cards, try n°{i+1} \n {e}") LogError(f"weekly_cards, try n°{i+1} \n {e}", driver)
if i == 0 : if i == 0 :
driver.refresh() driver.refresh()
else : else :
@ -560,18 +393,6 @@ def AllCard(): # fonction qui clique sur les cartes
driver.refresh() driver.refresh()
"""
send_keys_wait([selenium element:element, str:keys]) send the different keys to the field element, with a random time between each press to simulate human action.
keys can be an string, but alos selenium keys
"""
def send_keys_wait(element, keys):
for i in keys:
element.send_keys(i)
if FAST :
pass
else :
sleep(uniform(0.1, 0.3))
""" """
login() tries to login to your micrososft account. login() tries to login to your micrososft account.
@ -599,29 +420,11 @@ def login():
send_keys_wait(pwd, _password) send_keys_wait(pwd, _password)
pwd.send_keys(Keys.ENTER) pwd.send_keys(Keys.ENTER)
CustomSleep(5) CustomSleep(5)
try: for i in ["KmsiCheckboxField","iLooksGood", "idSIButton9", "iCancel"]:
driver.find_element(By.ID, "KmsiCheckboxField").click() try:
except Exception as e: driver.find_element(By.ID, i).click()
pass except Exception as e:
#printf(f"login - 2.1 - erreur validation bouton KmsiCheckboxField. pas forcement grave {e}") pass
try:
driver.find_element(By.ID, "iLooksGood").click()
except Exception as e:
pass
#printf(f"login - 2.2 - erreur validation bouton iLooksGood. pas forcement grave {e}")
try:
driver.find_element(By.ID, "idSIButton9").click()
except Exception as e:
pass
#printf(f"login - 2.3 - erreur validation bouton idSIButton9. pas forcement grave {e}")
try:
driver.find_element(By.ID, "iCancel").click()
except Exception as e:
pass
#printf(f"login - 2.4 - erreur validation bouton iCancel. pas forcement grave {e}")
try : try :
elm = driver.find_element(By.TAG_NAME, "body") elm = driver.find_element(By.TAG_NAME, "body")
elm.send_keys(Keys.ENTER) elm.send_keys(Keys.ENTER)
@ -638,7 +441,7 @@ def login():
sub_login() sub_login()
return (driver.current_window_handle) return (driver.current_window_handle)
except Exception as e: except Exception as e:
LogError("login - 3 - " + str(e)) LogError("login - 3 - " + str(e), driver)
driver.close() driver.close()
CustomSleep(1200) CustomSleep(1200)
driver = FirefoxDriver() driver = FirefoxDriver()
@ -683,137 +486,11 @@ def BingPcSearch(override=randint(35, 40)):
driver.get('https://www.bing.com/search?q=pls') driver.get('https://www.bing.com/search?q=pls')
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:
LogError(f"BingPcSearch - clear la barre de recherche - {e}") LogError(f"BingPcSearch - clear la barre de recherche - {e}", driver)
print("\n\n") print("\n\n")
def BingMobileSearch(override=randint(22, 25)):
MobileDriver = "unable to start"
try:
try:
MobileDriver = FirefoxDriver(mobile=True)
MobileDriver.implicitly_wait(15)
except Exception as e:
sleep(30)
LogError("BingMobileSearch - 1 - echec de la creation du driver mobile")
MobileDriver = FirefoxDriver(mobile=True)
MobileDriver.implicitly_wait(15)
echec = 0
def Mlogin(echec):
try:
MobileDriver.get(
"https://www.bing.com/search?q=test+speed"
)
MRGPD()
CustomSleep(uniform(3, 5))
printf("début du login", Mobdriver=MobileDriver)
MobileDriver.find_element(By.ID, "mHamburger").click()
CustomSleep(uniform(1, 2))
printf("Mlogin - 1", Mobdriver=MobileDriver)
MobileDriver.find_element(By.ID, "hb_s").click()
CustomSleep(uniform(1, 2))
printf("Mlogin - 2", Mobdriver=MobileDriver)
mail = MobileDriver.find_element(By.ID, "i0116")
send_keys_wait(mail, _mail)
printf("Mlogin - 3", Mobdriver=MobileDriver)
mail.send_keys(Keys.ENTER)
CustomSleep(uniform(7, 9))
printf("Mlogin - 4", Mobdriver=MobileDriver)
pwd = MobileDriver.find_element(By.ID, "i0118")
printf("Mlogin - 5", Mobdriver=MobileDriver)
send_keys_wait(pwd, _password)
printf("Mlogin - 6", Mobdriver=MobileDriver)
pwd.send_keys(Keys.ENTER)
CustomSleep(uniform(1, 2))
try:
MobileDriver.find_element(By.ID, "KmsiCheckboxField").click()
except Exception as e:
printf(f"Mlogin - 2.1 - erreur validation bouton KmsiCheckboxField. pas forcement grave {e}")
try:
MobileDriver.find_element(By.ID, "iLooksGood").click()
except Exception as e:
printf(f"Mlogin - 2.2 - erreur validation bouton iLooksGood. pas forcement grave {e}")
try:
MobileDriver.find_element(By.ID, "idSIButton9").click()
except Exception as e:
printf(f"Mlogin - 2.3 - erreur validation bouton idSIButton9. pas forcement grave {e}")
printf("fin du Mlogin", Mobdriver=MobileDriver)
except Exception as e:
echec += 1
if echec <= 3:
printf(
f"echec du login sur la version mobile. on reesaye ({echec}/3), {e}"
)
CustomSleep(uniform(5, 10))
Mlogin(echec)
else:
LogError(
f"login impossible 3 fois de suite. {e}", Mobdriver=MobileDriver
)
MobileDriver.quit()
return True
def MRGPD():
try:
MobileDriver.find_element(By.ID, "bnp_btn_accept").click()
except Exception as e:
pass
printf(e)
try:
MobileDriver.find_element(By.ID, "bnp_hfly_cta2").click()
except Exception as e:
pass
printf(f"MRGPD : e")
def Alerte():
try:
alert = MobileDriver.switch_to.alert
alert.dismiss()
except exceptions.NoAlertPresentException as e:
pass
except Exception as e:
LogError(
f"error sur une alerte dans le driver mobile. {e}",
Mobdriver=MobileDriver,
)
if not Mlogin(echec):
CustomSleep(uniform(1, 2))
MRGPD()
CustomSleep(uniform(1, 1.5))
for i in range(override): # 20
try :
mot = choice(Liste_de_mot)
send_keys_wait(MobileDriver.find_element(By.ID, "sb_form_q"), mot)
MobileDriver.find_element(By.ID, "sb_form_q").send_keys(Keys.ENTER)
progressBar(i, override, name="Mobile")
printf(MobileDriver.current_url, Mobdriver=MobileDriver)
CustomSleep(uniform(5, 20))
Alerte() # verifie si il y a des alertes (demande de positions ....)
MobileDriver.find_element(By.ID, "sb_form_q").clear()
except :
driver.refresh()
CustomSleep(30)
i -= 1
MobileDriver.quit()
except Exception as e:
LogError("BingMobileSearch - 4 - " + str(e), Mobdriver=MobileDriver)
try:
MobileDriver.quit()
except Exception as e:
LogError(f"can't close mobile driveer . {e}")
def TryPlay(nom="inconnu"): def TryPlay(nom="inconnu"):
@ -845,9 +522,7 @@ def TryPlay(nom="inconnu"):
except Exception as e: except Exception as e:
printf(f"echec de PlayQuiz 2. Aborted {e}") printf(f"echec de PlayQuiz 2. Aborted {e}")
else: else:
LogError( LogError("probleme dans la carte : il y a un bouton play et aucun quiz detecté", driver)
"probleme dans la carte : il y a un bouton play et aucun quiz detecté"
)
try: try:
driver.find_element(By.ID, "rqStartQuiz").click() # start the quiz driver.find_element(By.ID, "rqStartQuiz").click() # start the quiz
@ -922,7 +597,7 @@ def LogPoint(account="unknown"): # log des points sur discord
points = None points = None
if not points : if not points :
LogError(f"impossible d'avoir les points : {e}") LogError(f"impossible d'avoir les points : {e}", driver)
CustomSleep(uniform(3, 20)) CustomSleep(uniform(3, 20))
account = account.split("@")[0] account = account.split("@")[0]
@ -989,7 +664,7 @@ def Fidelite():
t = driver.find_element(By.XPATH,'/html/body/div[1]/div[2]/main/div[2]/div[2]/div[7]/div[3]/div[1]') t = driver.find_element(By.XPATH,'/html/body/div[1]/div[2]/main/div[2]/div[2]/div[7]/div[3]/div[1]')
t.click() t.click()
except Exception as e2 : except Exception as e2 :
LogError(f"fidélité - double erreur - e1 : {e1} - e2 {e2}") LogError(f"fidélité - double erreur - e1 : {e1} - e2 {e2}", driver)
break break
CustomSleep(uniform(3, 5)) CustomSleep(uniform(3, 5))
driver.switch_to.window(driver.window_handles[1]) driver.switch_to.window(driver.window_handles[1])
@ -1004,7 +679,115 @@ def Fidelite():
else : else :
printf("lien invalide") printf("lien invalide")
except Exception as e: except Exception as e:
LogError("Fidélité" + str(e)) LogError("Fidélité" + str(e), driver)
def Mlogin(echec):
try:
MobileDriver.get("https://www.bing.com/search?q=test+speed")
MRGPD()
printf("début du login", Mobdriver=MobileDriver)
MobileDriver.find_element(By.ID, "mHamburger").click()
CustomSleep(uniform(1, 2))
MobileDriver.find_element(By.ID, "hb_s").click()
CustomSleep(uniform(1, 2))
mail = MobileDriver.find_element(By.ID, "i0116")
send_keys_wait(mail, _mail)
mail.send_keys(Keys.ENTER)
CustomSleep(uniform(7, 9))
pwd = MobileDriver.find_element(By.ID, "i0118")
send_keys_wait(pwd, _password)
pwd.send_keys(Keys.ENTER)
CustomSleep(uniform(1, 2))
try:
MobileDriver.find_element(By.ID, "KmsiCheckboxField").click()
except Exception as e:
pass
try:
MobileDriver.find_element(By.ID, "iLooksGood").click()
except Exception as e:
pass
try:
MobileDriver.find_element(By.ID, "idSIButton9").click()
except Exception as e:
pass
printf("fin du Mlogin")
except Exception as e:
echec += 1
if echec <= 3:
printf(
f"echec du login sur la version mobile. on reesaye ({echec}/3), {e}"
)
CustomSleep(uniform(5, 10))
Mlogin(echec)
else:
LogError(
f"login impossible 3 fois de suite. {e}", MobileDriver
)
MobileDriver.quit()
return True
def MRGPD():
try:
MobileDriver.find_element(By.ID, "bnp_btn_accept").click()
except Exception as e:
pass
try:
MobileDriver.find_element(By.ID, "bnp_hfly_cta2").click()
except Exception as e:
pass
def Alerte():
try:
alert = MobileDriver.switch_to.alert
alert.dismiss()
except exceptions.NoAlertPresentException as e:
pass
except Exception as e:
LogError(
f"mobile.py -> Alerte : {e}",
driver=MobileDriver,
)
def BingMobileSearch(override=randint(22, 25)):
MobileDriver = "unable to start"
try:
try:
MobileDriver = FirefoxDriver(mobile=True)
MobileDriver.implicitly_wait(15)
except Exception as e:
LogError("BingMobileSearch - 1 - echec de la creation du driver mobile", MobileDriver)
echec = 0
if not Mlogin(echec):
CustomSleep(uniform(1, 2))
MRGPD()
CustomSleep(uniform(1, 1.5))
for i in range(override): # 20
try :
mot = choice(Liste_de_mot)
send_keys_wait(MobileDriver.find_element(By.ID, "sb_form_q"), mot)
MobileDriver.find_element(By.ID, "sb_form_q").send_keys(Keys.ENTER)
progressBar(i, override, name="Mobile")
printf(MobileDriver.current_url)
CustomSleep(uniform(5, 20))
Alerte() # verifie si il y a des alertes (demande de positions ....)
MobileDriver.find_element(By.ID, "sb_form_q").clear()
except :
driver.refresh()
CustomSleep(30)
i -= 1
MobileDriver.quit()
except Exception as e:
LogError("BingMobileSearch - 4 - " + str(e), MobileDriver)
MobileDriver.quit()
def DailyRoutine(custom = False): def DailyRoutine(custom = False):
@ -1017,31 +800,31 @@ def DailyRoutine(custom = False):
try: try:
AllCard() AllCard()
except Exception as e: except Exception as e:
LogError(f"DailyRoutine - AllCard - \n{e}") LogError(f"DailyRoutine - AllCard - \n{e}", driver)
try: try:
BingPcSearch() BingPcSearch()
except Exception as e: except Exception as e:
LogError(f"DailyRoutine - BingPcSearch - \n{e}") LogError(f"DailyRoutine - BingPcSearch - \n{e}", driver)
CustomSleep(uniform(3, 20)) CustomSleep(uniform(3, 20))
try: try:
Fidelite() Fidelite()
except Exception as e: except Exception as e:
LogError(f"DailyRoutine - Fidelité - \n{e}") LogError(f"DailyRoutine - Fidelité - \n{e}", driver)
try: try:
BingMobileSearch() BingMobileSearch()
except Exception as e: except Exception as e:
LogError(f"DailyRoutine - BingMobileSearch - \n{e}") LogError(f"DailyRoutine - BingMobileSearch - \n{e}", driver)
CustomSleep(uniform(3, 20)) CustomSleep(uniform(3, 20))
try: try:
LogPoint(_mail) LogPoint(_mail)
except Exception as e: except Exception as e:
LogError(f"DailyRoutine - LogPoint - \n{e}") LogError(f"DailyRoutine - LogPoint - \n{e}", driver)
else : else :
LogError(f"probleme de login sur le comte {_mail}") LogError(f"probleme de login sur le comte {_mail}", driver)
def close(): def close():
@ -1050,7 +833,7 @@ def close():
def dev(): def dev():
print(check_ipv4()) pass
def CustomStart(Credentials): def CustomStart(Credentials):
@ -1082,25 +865,25 @@ def CustomStart(Credentials):
try: try:
AllCard() AllCard()
except Exception as e: except Exception as e:
LogError(f"AllCards - {e} -- override") LogError(f"AllCards - {e} -- override", driver)
if "pc" in Actions: if "pc" in Actions:
try: try:
BingPcSearch() BingPcSearch()
except Exception as e: except Exception as e:
LogError(f"il y a eu une erreur dans BingPcSearch, {e} -- override") LogError(f"il y a eu une erreur dans BingPcSearch, {e} -- override", driver)
if "mobile" in Actions: if "mobile" in Actions:
try: try:
BingMobileSearch() BingMobileSearch()
except Exception as e: except Exception as e:
LogError(f"BingMobileSearch - {e} -- override") LogError(f"BingMobileSearch - {e} -- override", driver)
if "Fidelite" in Actions: if "Fidelite" in Actions:
try : try :
Fidelite() Fidelite()
except Exception as e : except Exception as e :
LogError(f"Fidelite - {e} -- override") LogError(f"Fidelite - {e} -- override", driver)
if "dev" in Actions: if "dev" in Actions:
try: try:

117
modules/config.py Normal file
View File

@ -0,0 +1,117 @@
#!/usr/bin/python3.10
import configparser
from csv import reader
from os import sys, system, path
from sys import platform
import argparse
from discord import ( # Importing discord.Webhook and discord.RequestsWebhookAdapter
RequestsWebhookAdapter,
Webhook,
)
from time import time
"""
Setup for option, like --override or --fulllog
"""
parser = argparse.ArgumentParser()
parser.add_argument(
"-o", "--override", help="override", dest="override", action="store_true"
)
parser.add_argument(
"-l", "--log", dest="log", help="enable logging in terminal", action="store_true"
)
parser.add_argument(
"-fl",
"--fulllog",
dest="fulllog",
help="enable full logging in discord",
action="store_true",
)
parser.add_argument(
"-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')
)
args = parser.parse_args()
CUSTOM_START = args.override
LOG = args.log
FULL_LOG = args.fulllog
FAST = args.fast
if CUSTOM_START :
LOG = True
# gloabal variables used later in the code
LINUX_HOST = platform == "linux" # if the computer running this programm is linux, it allow more things
START_TIME = time()
driver = None
if LINUX_HOST:
import enquiries
else:
system("") # enable colors in windows cmd
#reading configuration
config_path = f"{path.abspath( path.dirname( __file__ ) )}/user_data/config.cfg"
if args.config :
config_path = path.abspath(args.config.name)
config = configparser.ConfigParser()
config.read(config_path)
# path configurations
MotPath = config["PATH"]["motpath"]
CREDENTIALS_PATH = config["PATH"]["logpath"]
# discord configuration
DISCORD_SUCCESS_LINK = config["DISCORD"]["successlink"]
DISCORD_ERROR_LINK = config["DISCORD"]["errorlink"]
DISCORD_ENABLED_ERROR = config["DISCORD"]["DiscordErrorEnabled"] == "True"
DISCORD_ENABLED_SUCCESS = config["DISCORD"]["DiscordSuccessEnabled"]== "True"
if DISCORD_ENABLED_ERROR:
webhookFailure = Webhook.from_url(DISCORD_ERROR_LINK, adapter=RequestsWebhookAdapter())
if DISCORD_ENABLED_SUCCESS:
webhookSuccess = Webhook.from_url(DISCORD_SUCCESS_LINK, adapter=RequestsWebhookAdapter())
# base settings
FidelityLink = config["SETTINGS"]["FidelityLink"]
DISCORD_EMBED = config["SETTINGS"]["embeds"] == "True" #print new point value in an embed
Headless = config["SETTINGS"]["headless"] == "True"
# proxy settings
proxy_enabled = config["PROXY"]["proxy_enabled"] == "True"
proxy_address = config["PROXY"]["url"]
proxy_port = config["PROXY"]["port"]
# MySQL settings
sql_enabled = config["SQL"]["sql_enabled"] == "True"
sql_usr = config["SQL"]["usr"]
sql_pwd = config["SQL"]["pwd"]
sql_host = config["SQL"]["host"]
sql_database = config["SQL"]["database"]
# Other seetings
IPV6_CHECKED = config["OTHER"]["ipv6"]
CLAIM_AMAZON = config["OTHER"]["claim_amazon"]
g = open(MotPath, "r", encoding="utf-8")
lines = g.readlines()
if len(lines) < 3 :
Liste_de_mot = list(lines[0].split(","))
else :
Liste_de_mot = [x.replace('\n', "") for x in lines]
g.close()

77
modules/tools.py Normal file
View File

@ -0,0 +1,77 @@
from time import sleep
from random import uniform
import discord
from discord import ( # Importing discord.Webhook and discord.RequestsWebhookAdapter
Colour,
Webhook,
)
from modules.config import *
"""
send_keys_wait([selenium element:element, str:keys]) send the different keys to the field element, with a random time between each press to simulate human action.
keys can be an string, but alos selenium keys
"""
def send_keys_wait(element, keys):
for i in keys:
element.send_keys(i)
if FAST :
pass
else :
sleep(uniform(0.1, 0.3))
def LogError(message, driver, log=FULL_LOG):
print(f"\n\n\033[93m Erreur : {str(message)} \033[0m\n\n")
if DISCORD_ENABLED_ERROR:
with open("page.html", "w") as f:
f.write(gdriver.page_source)
gdriver.save_screenshot("screenshot.png")
if not log:
embed = discord.Embed(
title="An Error has occured",
description=str(message),
colour=Colour.red(),
)
else:
embed = discord.Embed(
title="Full log is enabled",
description=str(message),
colour=Colour.blue(),
)
file = discord.File("screenshot.png")
embed.set_image(url="attachment://screenshot.png")
embed.set_footer(text=_mail)
webhookFailure.send(embed=embed, file=file)
webhookFailure.send(file=discord.File("page.html"))
# add the time arround the text given in [text]
# [text] : string
def Timer(text="undefined"):
return(f"[{_mail} - {timedelta(seconds = round(float(time() - START_TIME)))}] " + str(text))
# replace the function print, with more options
# [txt] : string, [driver] : selenium wbdriver
def printf(txt, LOG = False):
if LOG:
print(Timer(txt))
# check if the user is using IPV4 using ipify.org
# [driver] : selenium webdriver
def check_ipv4(driver):
driver.get("https://api64.ipify.org")
elm = driver.find_element(By.TAG_NAME, "body")
if len(elm.text.split('.')) == 4 :
return True
return False