mirror of
https://gitea.augustin64.fr/piair/MsRewards-Reborn.git
synced 2025-06-25 10:53:58 +02:00
Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
ed1e91b304 | |||
710c272659 | |||
6f325c5a6a | |||
3b82419d4d | |||
9e0514a902 | |||
5c8730dc26 | |||
d11ae4055c | |||
2dc8cda167 | |||
fbb2feae31 | |||
8d53a2b30b | |||
f8f3ff2382 | |||
024b556f5e |
@ -4,11 +4,11 @@ ENV DEBIAN_FRONTEND noninteractive
|
||||
ENV GECKODRIVER_VER v0.31.0
|
||||
ENV FIREFOX_VER 87.0
|
||||
WORKDIR /app
|
||||
|
||||
RUN set -x \
|
||||
&& apt update \
|
||||
&& apt upgrade -y \
|
||||
&& apt install -y \
|
||||
tzdata \
|
||||
wfrench \
|
||||
git \
|
||||
libx11-xcb1 \
|
||||
@ -19,6 +19,7 @@ RUN set -x \
|
||||
nano \
|
||||
tigervnc-standalone-server \
|
||||
&& git clone https://github.com/piair338/MsRewards \
|
||||
&& ln -fs /usr/share/zoneinfo/Europe/Paris /etc/localtime \
|
||||
&& pip install -r MsRewards/requirements.txt \
|
||||
&& curl -sSLO https://download-installer.cdn.mozilla.net/pub/firefox/releases/91.9.1esr/linux-x86_64/en-US/firefox-91.9.1esr.tar.bz2 \
|
||||
&& tar -jxf firefox-* \
|
||||
@ -31,6 +32,7 @@ RUN set -x \
|
||||
&& mv geckodriver /usr/bin/
|
||||
|
||||
|
||||
ENV TZ="Europe/Paris"
|
||||
WORKDIR /app/MsRewards
|
||||
CMD python main.py
|
||||
|
||||
|
296
V5.py
296
V5.py
@ -1,10 +1,11 @@
|
||||
#!/usr/bin/python3.10
|
||||
from modules.imports import *
|
||||
from modules.db import add_to_database
|
||||
from modules.config import *
|
||||
from modules.db import add_to_database
|
||||
from modules.tools import *
|
||||
from modules.error import *
|
||||
from modules.driver_tools import *
|
||||
from modules.cards import *
|
||||
import modules.globals as g
|
||||
|
||||
|
||||
@ -12,10 +13,6 @@ driver = g.driver
|
||||
display = g.display
|
||||
|
||||
|
||||
# TODO
|
||||
# handle "panda"'s error: error while logging in preventing some task to be done SadPanda.svg:
|
||||
|
||||
|
||||
# create a webdriver
|
||||
def firefox_driver(mobile=False, headless=False):
|
||||
PC_USER_AGENT = (
|
||||
@ -29,12 +26,8 @@ def firefox_driver(mobile=False, headless=False):
|
||||
)
|
||||
options = Options()
|
||||
options.set_preference('intl.accept_languages', 'fr-FR, fr')
|
||||
if proxy_enabled :
|
||||
setup_proxy(proxy_address,proxy_port, options)
|
||||
options.set_preference("browser.link.open_newwindow", 3)
|
||||
options.set_preference("dom.confirm_repost.testing.always_accept", True)
|
||||
if FAST :
|
||||
options.set_preference("permissions.default.image", 2) #disable image loading. You shouldn't use it except if really nessecary
|
||||
if headless:
|
||||
options.add_argument("-headless")
|
||||
if mobile :
|
||||
@ -48,14 +41,14 @@ def firefox_driver(mobile=False, headless=False):
|
||||
return(driver)
|
||||
|
||||
|
||||
def log_error(error, ldriver=driver, log=FULL_LOG):
|
||||
def log_error(error, ldriver=driver, log=g.full_log):
|
||||
global driver
|
||||
if ldriver is None:
|
||||
ldriver = driver
|
||||
if type(error) != str :
|
||||
error = format_error(error)
|
||||
printf(f"\n\n\033[93m Erreur : {str(error)} \033[0m\n\n")
|
||||
if DISCORD_ENABLED_ERROR:
|
||||
if g.discord_enabled_error:
|
||||
with open("page.html", "w") as f:
|
||||
try :
|
||||
f.write(ldriver.page_source)
|
||||
@ -81,8 +74,8 @@ def log_error(error, ldriver=driver, log=FULL_LOG):
|
||||
file = File("screenshot.png")
|
||||
embed.set_image(url="attachment://screenshot.png")
|
||||
embed.set_footer(text=g._mail)
|
||||
webhookFailure.send(embed=embed, username="error", file=file, avatar_url = AVATAR_URL)
|
||||
webhookFailure.send(username="error", file=File("page.html"), avatar_url = 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)
|
||||
|
||||
|
||||
# close the tab currently on and go back to the one first, or the one specified
|
||||
@ -113,10 +106,12 @@ def play_quiz2(override=10) -> None:
|
||||
if somme + offset == int(correct_answer_value):
|
||||
answer_elem = driver.find_element(By.ID, "rqAnswerOption0")
|
||||
answer_elem.click()
|
||||
if g.log:
|
||||
progressBar(j, 10, name="quiz 2")
|
||||
else:
|
||||
answer_elem = driver.find_element(By.ID, "rqAnswerOption1")
|
||||
answer_elem.click()
|
||||
if g.log:
|
||||
progressBar(j, 10, name="quiz 2")
|
||||
|
||||
except exceptions.ElementNotInteractableException as e:
|
||||
@ -125,6 +120,7 @@ def play_quiz2(override=10) -> None:
|
||||
log_error(e)
|
||||
break
|
||||
printf("play_quiz2 done")
|
||||
custom_sleep(3)
|
||||
|
||||
|
||||
def play_quiz8():
|
||||
@ -147,6 +143,7 @@ def play_quiz8():
|
||||
for answer_id in correct_answers:
|
||||
wait_until_visible(By.ID, answer_id, timeout = 20, browser=driver)
|
||||
counter += 1
|
||||
if g.log :
|
||||
progressBar(counter, 16, name="Quiz 8")
|
||||
try:
|
||||
answer_elem = driver.find_element(By.ID, answer_id)
|
||||
@ -164,6 +161,7 @@ def play_quiz8():
|
||||
except Exception as e:
|
||||
log_error(f"{format_error(e)} \n Good answers : {' '.join(correct_answers)}")
|
||||
printf("play_quiz8 : fin ")
|
||||
custom_sleep(3)
|
||||
|
||||
|
||||
def play_quiz4(override=None):
|
||||
@ -192,6 +190,7 @@ def play_quiz4(override=None):
|
||||
log_error(e)
|
||||
raise ValueError(e)
|
||||
printf("play_quiz4 : end")
|
||||
custom_sleep(3)
|
||||
|
||||
|
||||
# do_poll() answer a random thing to poll, on of daily activities
|
||||
@ -208,117 +207,94 @@ def do_poll():
|
||||
log_error(error)
|
||||
raise ValueError(error)
|
||||
printf("do_poll : end")
|
||||
custom_sleep(3)
|
||||
|
||||
|
||||
# finds all task to do, and launch them
|
||||
def all_cards(): # return to the main page and closes all other tabs
|
||||
def reset(part2=False):
|
||||
if len(driver.window_handles) == 1:
|
||||
driver.get("https://www.bing.com/rewardsapp/flyout")
|
||||
if part2:
|
||||
row_element = driver.find_elements(By.CSS_SELECTOR, f'[class="i-h rw-sh fp_row"]')[1]
|
||||
expanded = row_element.get_attribute("aria-expanded")
|
||||
if expanded != "true":
|
||||
row_element.click()
|
||||
else:
|
||||
def all_cards():
|
||||
driver.get("https://rewards.bing.com")
|
||||
wait_until_visible(By.CLASS_NAME, "c-card-content", 10, driver)
|
||||
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
|
||||
custom_sleep(2)
|
||||
if "welcometour" in driver.current_url:
|
||||
welcome_tour_NO(driver)
|
||||
try :
|
||||
promo()
|
||||
except Exception as e:
|
||||
printf("no promo card")
|
||||
if(len(liste) < 10):
|
||||
log_error("moins de 10 cartes", driver)
|
||||
if (len(liste) < 20):
|
||||
if not g.norvege :
|
||||
g.norvege = True
|
||||
printf("moins de 20 cartes, disabling fidelity")
|
||||
g.fidelity_link = "Disabled because norway"
|
||||
log_error("Verifying if Norway", driver, True)
|
||||
for i in range(len(liste)):
|
||||
printf(f"carte {i}")
|
||||
try :
|
||||
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
|
||||
except StaleElementReferenceException :
|
||||
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
|
||||
printf(f"staled, {len(liste)}")
|
||||
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
|
||||
except IndexError:
|
||||
log_error("IndexError ?", driver)
|
||||
driver.refresh()
|
||||
custom_sleep(10)
|
||||
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
|
||||
if checked:
|
||||
custom_sleep(3)
|
||||
driver.execute_script("arguments[0].scrollIntoView();", liste[i])
|
||||
liste[i].click()
|
||||
if len(driver.window_handles) > 1 :
|
||||
driver.switch_to.window(driver.window_handles[1])
|
||||
printf(f"fermeture : {driver.current_url}")
|
||||
driver.close()
|
||||
driver.switch_to.window(driver.window_handles[0])
|
||||
if driver.current_url != "https://www.bing.com/rewardsapp/flyout":
|
||||
driver.get("https://www.bing.com/rewardsapp/flyout")
|
||||
reset(part2)
|
||||
|
||||
def daily_cards(): # cartes de la premiere partie (renouvelée chaque jour).
|
||||
try:
|
||||
# make sure that the daily area is expanded
|
||||
row_element = driver.find_elements(By.CSS_SELECTOR, f'[class="i-h rw-sh fp_row"]')[0]
|
||||
expanded = row_element.get_attribute("aria-expanded")
|
||||
if expanded != "true":
|
||||
row_element.click()
|
||||
for i in range(3):
|
||||
custom_sleep(uniform(3, 5))
|
||||
try:
|
||||
titre = "Placeholder"
|
||||
elm = driver.find_elements(By.CLASS_NAME, 'promo_cont')
|
||||
elm[i].click()
|
||||
sleep(1)
|
||||
titre = driver.title
|
||||
try_play(titre)
|
||||
sleep(1)
|
||||
reset()
|
||||
printf(f"DailyCard {titre} ok")
|
||||
except Exception as e:
|
||||
log_error(f"all_cards card `{titre}` error ({format_error(e)})")
|
||||
break
|
||||
|
||||
try : # devrait renvoyer vrai si la carte i est faite ou pas, a l'aide su symbole en haut a droite de la carte
|
||||
elm = driver.find_elements(By.CLASS_NAME, 'promo_cont')[i]
|
||||
if not ("correctCircle" in elm.get_attribute("innerHTML")):
|
||||
printf(f"missed card {i}")
|
||||
elm.click()
|
||||
try_play("recovery")
|
||||
sleep(3)
|
||||
reset()
|
||||
try_play(driver.title)
|
||||
close_tab(driver.window_handles[1])
|
||||
try :
|
||||
driver.refresh()
|
||||
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
|
||||
if ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML")) :
|
||||
printf(f"carte {i} not okay. Retrying.")
|
||||
liste[i].click()
|
||||
log_error(f"Card {i} with issue. WTF ?", driver)
|
||||
driver.switch_to.window(driver.window_handles[1])
|
||||
try_play(driver.title)
|
||||
close_tab(driver.window_handles[1])
|
||||
except :
|
||||
pass
|
||||
else :
|
||||
printf(f'carte OK')
|
||||
except Exception as e :
|
||||
printf(format_error(e) + " probablement ok - check card")
|
||||
# if it fail, it's probably okay -> when all three card are done, the pannel fold
|
||||
except Exception as e:
|
||||
log_error(e)
|
||||
|
||||
def weekly_cards():
|
||||
# make sure that the weekly area is expanded
|
||||
row_element = driver.find_elements(By.CSS_SELECTOR, f'[class="i-h rw-sh fp_row"]')[1]
|
||||
expanded = row_element.get_attribute("aria-expanded")
|
||||
if expanded != "true":
|
||||
row_element.click()
|
||||
|
||||
for i in range(20): # Should raise an error whene there is no card left
|
||||
elm = driver.find_elements(By.CLASS_NAME, 'promo_cont')
|
||||
try :
|
||||
elm[0].click()
|
||||
printf(f"Carte {i+1} cliquée.")
|
||||
except Exception as e :
|
||||
printf(f"Plus aucune carte.")
|
||||
welcome_tour(liste[i], driver)
|
||||
except Exception as e:
|
||||
printf("no new windows" + format_error(e))
|
||||
driver.get("https://rewards.bing.com")
|
||||
custom_sleep(3)
|
||||
|
||||
|
||||
def promo():
|
||||
elm = driver.find_element(By.ID, "promo-item")
|
||||
for i in range(10):
|
||||
if not elm:
|
||||
break
|
||||
driver.switch_to.window(driver.window_handles[len(driver.window_handles) - 1])
|
||||
sleep(1)
|
||||
titre = driver.title.split(" - Recherche")[0]
|
||||
printf(f"Carte `{titre}` en cours.")
|
||||
try_play(titre)
|
||||
reset(True)
|
||||
sleep(1)
|
||||
|
||||
def top_cards():
|
||||
for _ in range(2):
|
||||
if i > 8 :
|
||||
log_error("chelou, plus de 8 truc", driver)
|
||||
driver.execute_script("arguments[0].click();", elm)
|
||||
custom_sleep(3)
|
||||
if len(driver.window_handles) > 1 :
|
||||
driver.switch_to.window(driver.window_handles[len(driver.window_handles)-1])
|
||||
try_play(driver.title)
|
||||
close_tab(driver.window_handles[1])
|
||||
else :
|
||||
try :
|
||||
driver.find_elements(By.CSS_SELECTOR, '[class="banner_cont single wpoints"]')[0].click()
|
||||
reset()
|
||||
except Exception as e:
|
||||
printf(format_error(e))
|
||||
break
|
||||
|
||||
try :
|
||||
top_cards()
|
||||
except Exception as e:
|
||||
log_error(e)
|
||||
|
||||
try:
|
||||
daily_cards()
|
||||
except Exception as e:
|
||||
log_error(e)
|
||||
|
||||
try :
|
||||
weekly_cards()
|
||||
except Exception as e:
|
||||
log_error(e)
|
||||
spotify(driver)
|
||||
except :
|
||||
log_error("no new windows", driver)
|
||||
driver.get("https://rewards.bing.com")
|
||||
custom_sleep(3)
|
||||
|
||||
|
||||
# Find out which type of action to do
|
||||
def try_play(nom="inconnu"):
|
||||
# rgpd_popup(driver)
|
||||
def play(number):
|
||||
if number == 8 or number == 9:
|
||||
try:
|
||||
@ -349,10 +325,13 @@ def try_play(nom="inconnu"):
|
||||
log_error("There is an error. rqAnswerOption present in page but no action to do. skipping.")
|
||||
|
||||
try:
|
||||
if wait_until_visible(By.ID, "rqStartQuiz", 5, driver):
|
||||
custom_sleep(3)
|
||||
driver.find_element(By.ID, "rqStartQuiz").click() # start the quiz
|
||||
answer_number = driver.page_source.count("rqAnswerOption")
|
||||
play(answer_number)
|
||||
|
||||
else :
|
||||
raise (NameError("going to next part"))
|
||||
except Exception as e: # if there is no start button, an error is thrown
|
||||
if "bt_PollRadio" in driver.page_source:
|
||||
try:
|
||||
@ -411,7 +390,12 @@ def cookie_login(ldriver):
|
||||
except FileNotFoundError :
|
||||
printf("No cookies file Found.")
|
||||
return(False)
|
||||
try :
|
||||
ldriver.refresh()
|
||||
except Exception as e:
|
||||
printf(format_error(e))
|
||||
printf("FIX YOUR SITE MS.......")
|
||||
|
||||
return(True)
|
||||
|
||||
|
||||
@ -431,42 +415,28 @@ def login_part_2(ldriver, cookies = False):
|
||||
except Exception as e:
|
||||
pass
|
||||
wait_until_visible(By.CSS_SELECTOR, '[data-bi-id="sh-sharedshell-home"]', 20, ldriver)
|
||||
ldriver.get("https://www.bing.com")
|
||||
ldriver.get("https://www.bing.com/?setlang=fr&cc=fr&cc=FR")
|
||||
rgpd_popup(ldriver)
|
||||
ldriver.refresh()
|
||||
rgpd_popup(ldriver)
|
||||
ldriver.get("https://account.microsoft.com/")
|
||||
if wait_until_visible(By.CSS_SELECTOR, '[data-bi-id="sh-sharedshell-home"]', 30, ldriver) :
|
||||
return(True) #the account logging was successful
|
||||
else :
|
||||
log_error("Error during login. Trying to refresh")
|
||||
ldriver.refresh()
|
||||
return(wait_until_visible(By.CSS_SELECTOR, '[data-bi-id="sh-sharedshell-home"]', 30, ldriver))
|
||||
|
||||
|
||||
#going to MsRewards
|
||||
def go_to_msrewards(ldriver):
|
||||
for i in ["[h='ID=RewardsFlyout,2.1']", f'[title="Rejoindre maintenant"]', f'[title="Rejoindre"]', f'[title="Join now"]'] :
|
||||
ldriver.get("https://www.bing.com/rewardsapp/flyout")
|
||||
if ('>Tableau de bord' in ldriver.page_source) :
|
||||
printf('On MsRewards flyout')
|
||||
return(True)
|
||||
try:
|
||||
ldriver.find_element(By.CSS_SELECTOR, i).click() # depend of the language of the page
|
||||
except:
|
||||
printf(f"element {i} not found")
|
||||
|
||||
#ldriver.get("https://account.microsoft.com/")
|
||||
#if wait_until_visible(By.CSS_SELECTOR, '[data-bi-id="sh-sharedshell-home"]', 30, ldriver) :
|
||||
# return(True) #the account logging was successful
|
||||
#else :
|
||||
# log_error("Error during login. Trying to refresh")
|
||||
# ldriver.refresh()
|
||||
# return(wait_until_visible(By.CSS_SELECTOR, '[data-bi-id="sh-sharedshell-home"]', 30, ldriver))
|
||||
# useless ?
|
||||
|
||||
# login() tries to login to your Microsoft account.
|
||||
# it uses global variable g._mail and g._password to login
|
||||
def login(ldriver):
|
||||
try :
|
||||
success_cookies = cookie_login(ldriver)
|
||||
input("paused")
|
||||
if not success_cookies:
|
||||
pwd_login(ldriver)
|
||||
login_part_2(ldriver, not success_cookies)
|
||||
go_to_msrewards(ldriver)
|
||||
ldriver.get("https://rewards.bing.com/")
|
||||
except Banned:
|
||||
raise Banned()
|
||||
except Exception as e:
|
||||
@ -578,8 +548,8 @@ def log_points(account="unknown"):
|
||||
custom_sleep(uniform(3, 20))
|
||||
account_name = account.split("@")[0]
|
||||
|
||||
if DISCORD_ENABLED_SUCCESS:
|
||||
if DISCORD_EMBED:
|
||||
if g.discord_enabled_success:
|
||||
if g.discord_embed:
|
||||
embed = Embed(
|
||||
title=f"{account_name} actuellement à {str(points)} points", colour=Colour.green()
|
||||
)
|
||||
@ -588,8 +558,8 @@ def log_points(account="unknown"):
|
||||
else:
|
||||
webhookSuccess.send(f"{account_name} actuellement à {str(points)} points")
|
||||
|
||||
if sql_enabled :
|
||||
add_to_database(account_name, points, sql_host, sql_usr, sql_pwd, sql_database)
|
||||
if g.sql_enabled :
|
||||
add_to_database(account_name, points, g.sql_host, g.sql_usr, g.sql_pwd, g.sql_database)
|
||||
|
||||
|
||||
def fidelity():
|
||||
@ -600,7 +570,7 @@ def fidelity():
|
||||
except:
|
||||
break
|
||||
try :
|
||||
fidelity_link_page = get(FidelityLink) #get the url of fidelity page
|
||||
fidelity_link_page = get(g.fidelity_link) #get the url of fidelity page
|
||||
except Exception as e :
|
||||
printf(e)
|
||||
fidelity_link_page = False
|
||||
@ -702,7 +672,7 @@ def daily_routine(custom = False):
|
||||
if not custom: # custom already login
|
||||
login(driver)
|
||||
except Banned :
|
||||
log_error("THIS ACCOUNT IS BANNED. FIX THIS ISSUE WITH -U")
|
||||
log_error("This account is locked. Fix that. (-U ?)", driver)
|
||||
return()
|
||||
|
||||
try:
|
||||
@ -725,7 +695,6 @@ def daily_routine(custom = False):
|
||||
except Exception as e:
|
||||
log_error(e)
|
||||
|
||||
|
||||
try:
|
||||
log_points(g._mail)
|
||||
except Exception as e:
|
||||
@ -733,20 +702,19 @@ def daily_routine(custom = False):
|
||||
|
||||
|
||||
def dev():
|
||||
input("paused")
|
||||
input("dev pause")
|
||||
|
||||
|
||||
def CustomStart(Credentials):
|
||||
global START_TIME
|
||||
if not LINUX_HOST :
|
||||
def CustomStart():
|
||||
if not g.islinux :
|
||||
raise NameError('You need to be on linux to do that, due to the utilisation of a module named enquieries, sorry.')
|
||||
global driver, p
|
||||
global driver
|
||||
|
||||
system("clear") # clear from previous command to allow a clean choice
|
||||
actions = ["tout", "daily", "pc", "mobile", "log_points","fidelity", "dev"]
|
||||
Actions = enquiries.choose("quels Actions ?", actions, multi=True)
|
||||
liste = select_accounts()
|
||||
START_TIME = time() # Reset timer to the start of the actions
|
||||
g.start_time = time() # Reset timer to the start of the actions
|
||||
|
||||
for cred in liste:
|
||||
g._mail = cred[0]
|
||||
@ -756,7 +724,6 @@ def CustomStart(Credentials):
|
||||
|
||||
driver = firefox_driver()
|
||||
driver.implicitly_wait(3)
|
||||
|
||||
if login(driver) != "STOP":
|
||||
if "tout" in Actions:
|
||||
daily_routine(True)
|
||||
@ -791,34 +758,33 @@ def CustomStart(Credentials):
|
||||
log_points(g._mail)
|
||||
except Exception as e:
|
||||
printf(f"CustomStart {e}")
|
||||
driver.close()
|
||||
driver.quit()
|
||||
|
||||
|
||||
if VNC_ENABLED :
|
||||
display = SmartDisplay(backend="xvnc", size=(2160, 2160), rfbport=VNC_PORT, color_depth=24)
|
||||
if g.vnc_enabled :
|
||||
display = SmartDisplay(backend="xvnc", size=(2160, 2160), rfbport=g.vnc_port, color_depth=24)
|
||||
else :
|
||||
display = SmartDisplay(size=(2160, 2160))
|
||||
display.start()
|
||||
|
||||
|
||||
if CUSTOM_START:
|
||||
CustomStart(Credentials)
|
||||
elif UNBAN:
|
||||
if g.custom_start:
|
||||
CustomStart()
|
||||
elif g.unban:
|
||||
g._mail, g._password = select_accounts(False)[0]
|
||||
driver = firefox_driver()
|
||||
try :
|
||||
login(driver)
|
||||
except Banned:
|
||||
unban()
|
||||
|
||||
driver.quit()
|
||||
elif POINTS_FILE != "":
|
||||
save_points_from_file(POINTS_FILE)
|
||||
elif g.points_file != "":
|
||||
save_points_from_file(g.points_file)
|
||||
else:
|
||||
if UPDATE_VERSION != "None":
|
||||
if DISCORD_ENABLED_ERROR:
|
||||
webhookFailure.send(f"Updated to {UPDATE_VERSION}", username="UPDATE", avatar_url="https://cdn-icons-png.flaticon.com/512/1688/1688988.png")
|
||||
for cred in Credentials:
|
||||
if g.update_version != "None":
|
||||
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")
|
||||
for cred in g._cred:
|
||||
g._mail = cred[0]
|
||||
g._password = cred[1]
|
||||
if len(cred) == 3:
|
||||
|
@ -1,69 +0,0 @@
|
||||
from easyprocess import EasyProcess
|
||||
from pyvirtualdisplay import Display
|
||||
from modules.config import *
|
||||
from selenium import webdriver
|
||||
from selenium.common import exceptions
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
from selenium.webdriver.firefox.options import Options
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.support.ui import Select
|
||||
|
||||
|
||||
def setup_proxy(ip, port, options, socks=False) :
|
||||
PROXY = f"{ip}:{port}"
|
||||
if socks :
|
||||
options.set_preference('network.proxy.type', 1)
|
||||
options.set_preference('network.proxy.socks', ip)
|
||||
options.set_preference('network.proxy.socks_port', int(port))
|
||||
options.set_preference("browser.link.open_newwindow", 3)
|
||||
else :
|
||||
webdriver.DesiredCapabilities.FIREFOX['proxy'] = {
|
||||
"httpProxy": PROXY,
|
||||
"sslProxy": PROXY,
|
||||
"proxyType": "MANUAL",
|
||||
}
|
||||
|
||||
def firefox_driver(mobile=False, Headless=False):
|
||||
PC_USER_AGENT = (
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
|
||||
"AppleWebKit/537.36 (KHTML, like Gecko)"
|
||||
"Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.56")
|
||||
MOBILE_USER_AGENT = (
|
||||
"Mozilla/5.0 (iPhone; CPU iPhone OS 15_5 like Mac OS X)"
|
||||
"AppleWebKit/605.1.15 (KHTML, like Gecko)"
|
||||
"CriOS/103.0.5060.63 Mobile/15E148 Safari/604.1"
|
||||
)
|
||||
|
||||
options = Options()
|
||||
options.set_preference('intl.accept_languages', 'fr-FR, fr')
|
||||
if proxy_enabled :
|
||||
setup_proxy(proxy_address,proxy_port, options)
|
||||
options.set_preference("browser.link.open_newwindow", 3)
|
||||
if FAST :
|
||||
options.set_preference("permissions.default.image", 2) #disable image loading. May add this without the fast option soon
|
||||
if Headless:
|
||||
options.add_argument("-headless")
|
||||
if mobile :
|
||||
options.set_preference("general.useragent.override", MOBILE_USER_AGENT)
|
||||
else :
|
||||
options.set_preference("general.useragent.override", PC_USER_AGENT)
|
||||
driver = webdriver.Firefox(options=options)
|
||||
driver.set_window_size(1900 + hash(_mail)%20 , 1070 + hash(_password + "salt")%10)
|
||||
return(driver)
|
||||
|
||||
def select_accounts(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
|
||||
emails_selected = enquiries.choose(f"quel{'s' if multiple else ''} compte{'s' if multiple else ''} ?", emails, multi=multiple)
|
||||
return([x for x in Credentials if x[0] in emails_selected])
|
||||
|
||||
|
||||
|
||||
with Display(backend="xvnc", size=(2000, 1000), rfbport=5904) as disp:
|
||||
_mail, _password = select_accounts(False)[0]
|
||||
driver = firefox_driver()
|
||||
print(f"connect via VNC to port 5904. \nID: {_mail}\npwd : {_password}")
|
||||
i = input('stop ? ')
|
||||
driver.close()
|
34
modules/cards.py
Normal file
34
modules/cards.py
Normal file
@ -0,0 +1,34 @@
|
||||
from modules.imports import *
|
||||
|
||||
|
||||
def welcome_tour(elm, driver):
|
||||
try :
|
||||
driver.find_element(By.CSS_SELECTOR, '[class="welcome-tour-next-button c-call-to-action c-glyph"]').click()
|
||||
except :
|
||||
pass
|
||||
driver.find_element(By.CSS_SELECTOR, '[class="quiz-link gray-button c-call-to-action c-glyph f-lightweight"]').click()
|
||||
sleep(5)
|
||||
driver.find_element(By.CSS_SELECTOR, '[class="c-glyph glyph-cancel"]').click()
|
||||
elm.click()
|
||||
driver.find_element(By.CSS_SELECTOR, '[class="quiz-link gray-button c-call-to-action c-glyph f-lightweight"]').click()
|
||||
sleep(5)
|
||||
driver.find_element(By.CSS_SELECTOR, '[class="c-glyph glyph-cancel"]').click()
|
||||
elm.click()
|
||||
driver.find_element(By.CSS_SELECTOR, '[class="quiz-link gray-button c-call-to-action c-glyph f-lightweight"]').click()
|
||||
sleep(5)
|
||||
driver.find_element(By.CSS_SELECTOR, '[class="c-glyph glyph-cancel"]').click()
|
||||
|
||||
def welcome_tour_NO(driver):
|
||||
try :
|
||||
driver.find_element(By.CSS_SELECTOR, '[class="welcome-tour-next-button c-call-to-action c-glyph"]').click()
|
||||
except :
|
||||
pass
|
||||
driver.find_element(By.CSS_SELECTOR, '[class="c-glyph glyph-cancel"]').click()
|
||||
sleep(5)
|
||||
|
||||
|
||||
def spotify(driver):
|
||||
sleep(5)
|
||||
driver.find_element(By.CSS_SELECTOR, '[data-bi-id="spotify-premium gratuit"]').click()
|
||||
sleep(5)
|
||||
close_tab(driver.window_handles[1])
|
@ -1,18 +1,7 @@
|
||||
#!/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,
|
||||
Colour,
|
||||
)
|
||||
|
||||
from time import time
|
||||
from random import shuffle
|
||||
|
||||
from modules.driver_tools import *
|
||||
from modules.imports import *
|
||||
import modules.globals as g
|
||||
"""
|
||||
Setup for option, like --override or --fulllog
|
||||
"""
|
||||
@ -50,19 +39,12 @@ parser.add_argument(
|
||||
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')
|
||||
default=""
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
@ -87,91 +69,102 @@ parser.add_argument(
|
||||
dest="update_version",
|
||||
default="None"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--dev",
|
||||
help="dev option",
|
||||
dest="dev",
|
||||
action="store_true"
|
||||
)
|
||||
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
CUSTOM_START = args.override
|
||||
UNBAN = args.unban
|
||||
LOG = args.log
|
||||
FULL_LOG = args.fulllog
|
||||
FAST = args.fast
|
||||
if CUSTOM_START :
|
||||
LOG = True
|
||||
VNC_ENABLED = args.vnc != "None"
|
||||
VNC_PORT = args.vnc
|
||||
POINTS_FILE = args.points_file
|
||||
UPDATE_VERSION = args.update_version
|
||||
g.custom_start = args.override
|
||||
g.unban = args.unban
|
||||
g.log = args.log
|
||||
g.full_log = args.fulllog
|
||||
g.dev = args.dev
|
||||
|
||||
if g.custom_start :
|
||||
g.log = True
|
||||
|
||||
g.vnc_enabled = args.vnc != "None"
|
||||
g.vnc_port = args.vnc
|
||||
g.points_file = args.points_file
|
||||
g.update_version = args.update_version
|
||||
# global variables used later in the code
|
||||
LINUX_HOST = platform == "linux" # if the computer running this program is Linux, it allow more things
|
||||
START_TIME = time()
|
||||
|
||||
|
||||
if LINUX_HOST:
|
||||
import enquiries
|
||||
else:
|
||||
system("") # enable colors in windows cmd
|
||||
g.islinux = platform == "linux" # if the computer running this program is Linux, it allow more things
|
||||
g.start_time = time()
|
||||
|
||||
#reading configuration
|
||||
|
||||
config_path = f"{path.abspath(path.dirname(path.dirname( __file__ )))}/user_data/config.cfg"
|
||||
if args.config :
|
||||
config_path = path.abspath(args.config.name)
|
||||
|
||||
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.read(config_path)
|
||||
|
||||
if args.config :
|
||||
try :
|
||||
config_path =f"{path.abspath(path.dirname(path.dirname( __file__ )))}/user_data/config{args.config}.cfg"
|
||||
config.read(config_path)
|
||||
g.mot_path = config["PATH"]["motpath"]
|
||||
except :
|
||||
config_path = path.abspath(args.config)
|
||||
config.read(config_path)
|
||||
else :
|
||||
config_path = f"{path.abspath(path.dirname(path.dirname( __file__ )))}/user_data/config.cfg"
|
||||
config.read(config_path)
|
||||
|
||||
|
||||
# path configurations
|
||||
MotPath = config["PATH"]["motpath"]
|
||||
CREDENTIALS_PATH = config["PATH"]["logpath"]
|
||||
g.mot_path = config["PATH"]["motpath"]
|
||||
g.credential_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"
|
||||
g.discord_success_link = config["DISCORD"]["successlink"]
|
||||
g.discord_error_link = config["DISCORD"]["errorlink"]
|
||||
g.discord_enabled_error = config["DISCORD"]["DiscordErrorEnabled"] == "True"
|
||||
g.discord_enabled_success = config["DISCORD"]["DiscordSuccessEnabled"]== "True"
|
||||
try :
|
||||
AVATAR_URL = config["OTHER"]["avatar"]== "True"
|
||||
g.avatar_url = config["OTHER"]["avatar"]
|
||||
except :
|
||||
AVATAR_URL = "https://cdn.discordapp.com/icons/793934298977009674/d8055bccef6eca4855c349e808d0d788.webp"
|
||||
g.avatar_url = "https://cdn.discordapp.com/icons/793934298977009674/d8055bccef6eca4855c349e808d0d788.webp"
|
||||
|
||||
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())
|
||||
if g.discord_enabled_error:
|
||||
webhookFailure = Webhook.from_url(g.discord_error_link, adapter=RequestsWebhookAdapter())
|
||||
if g.discord_enabled_success:
|
||||
webhookSuccess = Webhook.from_url(g.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"
|
||||
g.fidelity_link = config["SETTINGS"]["FidelityLink"]
|
||||
g.discord_embed = config["SETTINGS"]["embeds"] == "True" #print new point value in an embed
|
||||
g.headless = config["SETTINGS"]["headless"] == "True"
|
||||
|
||||
# proxy settings
|
||||
proxy_enabled = config["PROXY"]["proxy_enabled"] == "True"
|
||||
proxy_address = config["PROXY"]["url"]
|
||||
proxy_port = config["PROXY"]["port"]
|
||||
g.proxy_enabled = config["PROXY"]["proxy_enabled"] == "True"
|
||||
g.proxy_address = config["PROXY"]["url"]
|
||||
g.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 settings
|
||||
IPV6_CHECKED = config["OTHER"]["ipv6"]
|
||||
g.sql_enabled = config["SQL"]["sql_enabled"] == "True"
|
||||
g.sql_usr = config["SQL"]["usr"]
|
||||
g.sql_pwd = config["SQL"]["pwd"]
|
||||
g.sql_host = config["SQL"]["host"]
|
||||
g.sql_database = config["SQL"]["database"]
|
||||
|
||||
|
||||
g = open(MotPath, "r", encoding="utf-8")
|
||||
lines = g.readlines()
|
||||
h = open(g.mot_path, "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]
|
||||
g.close()
|
||||
h.close()
|
||||
|
||||
|
||||
with open(CREDENTIALS_PATH) as f:
|
||||
with open(g.credential_path) as f:
|
||||
reader = reader(f)
|
||||
Credentials = list(reader)
|
||||
shuffle(Credentials)
|
||||
g._cred = Credentials
|
||||
|
||||
if g.proxy_enabled :
|
||||
setup_proxy(g.proxy_address,g.proxy_port)
|
||||
|
@ -1,15 +1,10 @@
|
||||
from modules.imports import *
|
||||
from modules.config import *
|
||||
from modules.tools import *
|
||||
import modules.globals as g
|
||||
|
||||
def setup_proxy(ip, port, options, socks=False) :
|
||||
def setup_proxy(ip, port) :
|
||||
PROXY = f"{ip}:{port}"
|
||||
if socks :
|
||||
options.set_preference('network.proxy.type', 1)
|
||||
options.set_preference('network.proxy.socks', ip)
|
||||
options.set_preference('network.proxy.socks_port', int(port))
|
||||
options.set_preference("browser.link.open_newwindow", 3)
|
||||
else :
|
||||
webdriver.DesiredCapabilities.FIREFOX['proxy'] = {
|
||||
"httpProxy": PROXY,
|
||||
"sslProxy": PROXY,
|
||||
@ -26,10 +21,22 @@ def rgpd_popup(driver) -> None:
|
||||
|
||||
# save webdriver cookies
|
||||
def save_cookies(driver):
|
||||
if g.dev:
|
||||
f = open(f"{'/'.join(__file__.split('/')[:-2])}/user_data/cookies/{g._mail}_unsafe.pkl", "w")
|
||||
for i in driver.get_cookies():
|
||||
f.write(str(i) + "\n")
|
||||
f.close()
|
||||
else :
|
||||
pickle.dump(driver.get_cookies(), open(f"{'/'.join(__file__.split('/')[:-2])}/user_data/cookies/{g._mail}.pkl", "wb"))
|
||||
|
||||
# load cookies previously saved to the driver
|
||||
def load_cookies(driver):
|
||||
if g.dev:
|
||||
f = open(f"{'/'.join(__file__.split('/')[:-2])}/user_data/cookies/{g._mail}_unsafe.pkl", "r")
|
||||
lines = f.readlines()
|
||||
f.close()
|
||||
cookies = [literal_eval(x) for x in lines]
|
||||
else :
|
||||
cookies = pickle.load(open(f"{'/'.join(__file__.split('/')[:-2])}/user_data/cookies/{g._mail}.pkl", "rb"))
|
||||
for cookie in cookies:
|
||||
driver.add_cookie(cookie)
|
||||
@ -41,9 +48,6 @@ keys can be an string, but also 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))
|
||||
|
||||
|
||||
@ -54,6 +58,6 @@ def wait_until_visible(search_by: str, identifier: str, timeout = 20, browser =
|
||||
WebDriverWait(browser, timeout).until(EC.visibility_of_element_located((search_by,identifier)), "element not found")
|
||||
return(True)
|
||||
except TimeoutException as e:
|
||||
print(f"element not found after {timeout}s")
|
||||
printf(f"element not found after {timeout}s")
|
||||
return(False)
|
||||
|
||||
|
@ -3,3 +3,34 @@ _mail = '_mail temp'
|
||||
_password = '_password temp'
|
||||
_otp = '_otp temp'
|
||||
display = None
|
||||
_cred = []
|
||||
custom_start = False
|
||||
unban = False
|
||||
log = False
|
||||
full_log = False
|
||||
vnc_enabled = False
|
||||
vnc_port = 0
|
||||
points_file = "/"
|
||||
update_version = False
|
||||
islinux = True
|
||||
start_time = 0
|
||||
mot_path = "/"
|
||||
credential_path = "/"
|
||||
discord_success_link = "https://example.com"
|
||||
discord_error_link = "https://example.com"
|
||||
discord_enabled_error = False
|
||||
discord_enabled_success = False
|
||||
avatar_url = ""
|
||||
fidelity_link = "None"
|
||||
discord_embed = False
|
||||
headless = False
|
||||
proxy_enabled = False
|
||||
proxy_address = "0.0.0.0"
|
||||
proxy_port = "0"
|
||||
sql_enabled = False
|
||||
sql_usr = "None"
|
||||
sql_pwd = "azerty"
|
||||
sql_host = "https://example.com"
|
||||
sql_database = "MsRewards"
|
||||
dev = False
|
||||
norvege = False
|
@ -1,24 +1,33 @@
|
||||
import argparse
|
||||
import asyncio
|
||||
import csv
|
||||
from os import sys, system, path
|
||||
import configparser
|
||||
import pickle
|
||||
from csv import reader
|
||||
from datetime import datetime, timedelta
|
||||
from os import path, sys, system
|
||||
from random import choice, randint, shuffle, uniform
|
||||
from re import findall, search
|
||||
from sys import platform
|
||||
from time import sleep
|
||||
from requests import get
|
||||
from selenium import webdriver
|
||||
from selenium.common import exceptions
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
from selenium.webdriver.firefox.options import Options
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.support.ui import Select
|
||||
from selenium.common.exceptions import WebDriverException, TimeoutException, NoSuchElementException, ElementClickInterceptedException
|
||||
from time import sleep, time
|
||||
|
||||
from discord import Colour, Embed, File, RequestsWebhookAdapter, Webhook
|
||||
from pyotp import TOTP
|
||||
from pyvirtualdisplay import Display
|
||||
from pyvirtualdisplay.smartdisplay import SmartDisplay
|
||||
import pickle
|
||||
from datetime import timedelta, datetime
|
||||
from discord import Embed, Colour, File
|
||||
from requests import get
|
||||
from selenium import webdriver
|
||||
from selenium.common import exceptions
|
||||
from selenium.common.exceptions import (ElementClickInterceptedException,
|
||||
NoSuchElementException,
|
||||
StaleElementReferenceException,
|
||||
TimeoutException, WebDriverException)
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.common.keys import Keys
|
||||
from selenium.webdriver.firefox.options import Options
|
||||
from selenium.webdriver.support import expected_conditions as EC
|
||||
from selenium.webdriver.support.ui import Select, WebDriverWait
|
||||
from ast import literal_eval
|
||||
try:
|
||||
import enquiries
|
||||
except:
|
||||
system("") # enable colors in windows cmd
|
||||
|
@ -1,10 +1,10 @@
|
||||
from modules.imports import *
|
||||
from modules.config import *
|
||||
from modules.db import *
|
||||
import modules.globals as g
|
||||
|
||||
# add the time arround the text given in [text]&
|
||||
def Timer(text: str) -> str:
|
||||
return(f"[{g._mail.split('@')[0]} - {datetime.today().strftime('%d/%m')} - {timedelta(seconds = round(float(time() - START_TIME)))}] " + str(text))
|
||||
return(f"[{g._mail.split('@')[0]} - {datetime.today().strftime('%d/%m')} - {timedelta(seconds = round(float(time() - g.start_time)))}] " + str(text))
|
||||
|
||||
|
||||
# replace the function print, with more options
|
||||
@ -32,9 +32,7 @@ def check_ipv4(driver):
|
||||
|
||||
def custom_sleep(temps):
|
||||
try :
|
||||
if FAST and temps > 50:
|
||||
sleep(temps/10)
|
||||
elif LOG: #only print sleep when user see it
|
||||
if g.log : #only print sleep when user see it
|
||||
points = ["⢿", "⣻", "⣽", "⣾", "⣷", "⣯", "⣟", "⡿"]
|
||||
passe = 0
|
||||
for i in range(int(temps)):
|
||||
@ -67,20 +65,18 @@ def progressBar(current, total=30, barLength=20, name="Progress"):
|
||||
|
||||
def save_points_from_file(file):
|
||||
with open(file) as f:
|
||||
reader = csv.reader(f)
|
||||
points_list = list(reader)
|
||||
|
||||
read = reader(f)
|
||||
points_list = list(read)
|
||||
for item in points_list:
|
||||
compte, points = item[0], item[1]
|
||||
add_to_database(compte, points, sql_host,sql_usr,sql_pwd,sql_database, save_if_fail=False)
|
||||
|
||||
add_to_database(compte, points, g.sql_host,g.sql_usr,g.sql_pwd,g.sql_database, save_if_fail=False)
|
||||
with open(file, "w") as f:
|
||||
f.write("")
|
||||
|
||||
|
||||
def select_accounts(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
|
||||
emails = [x[0] for x in g._cred] # list of all email adresses
|
||||
emails_selected = enquiries.choose(f"quel{'s' if multiple else ''} compte{'s' if multiple else ''} ?", emails, multi=multiple)
|
||||
return([x for x in Credentials if x[0] in emails_selected])
|
||||
return([x for x in g._cred if x[0] in emails_selected])
|
||||
|
||||
|
Reference in New Issue
Block a user