forked from piair/MsRewards-Reborn
implementing UserCredential class
This commit is contained in:
parent
cf6905b169
commit
b89d3036bb
146
V6.py
146
V6.py
@ -5,21 +5,26 @@ from modules.driver_tools import *
|
|||||||
from modules.cards import *
|
from modules.cards import *
|
||||||
import modules.globals as g
|
import modules.globals as g
|
||||||
|
|
||||||
|
from modules.Classes.Config import Config
|
||||||
|
from modules.Classes.UserCredentials import UserCredentials
|
||||||
|
from modules.Tools.logger import warning, info, debug, error, critical
|
||||||
|
|
||||||
|
|
||||||
driver = g.driver
|
driver = g.driver
|
||||||
display = g.display
|
display = g.display
|
||||||
|
|
||||||
|
|
||||||
# create a webdriver
|
# create a webdriver
|
||||||
def create_driver(mobile=False, headless=False):
|
def create_driver(mobile=False):
|
||||||
PC_USER_AGENT = (
|
PC_USER_AGENT = (
|
||||||
"Mozilla/5.0 (X11; Linux x86_64)"
|
"Mozilla/5.0 (X11; Linux x86_64)"
|
||||||
"AppleWebKit/537.36 (KHTML, like Gecko)"
|
"AppleWebKit/537.36 (KHTML, like Gecko)"
|
||||||
"Chrome/118.0.0.0 Safari/537.36 Edg/118.0.2088.46"
|
"Chrome/122.0.0.0 Safari/537.36 Edg/122.0.2088.46"
|
||||||
)
|
)
|
||||||
MOBILE_USER_AGENT = (
|
MOBILE_USER_AGENT = (
|
||||||
"Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N)"
|
"Mozilla/5.0 (Linux; Android 7.0; Nexus 5 Build/MRA58N)"
|
||||||
"AppleWebKit/537.36 (KHTML, like Gecko)"
|
"AppleWebKit/537.36 (KHTML, like Gecko)"
|
||||||
"Chrome/%s Mobile Safari/537.36"
|
"Chrome/22 Mobile Safari/537.36"
|
||||||
)
|
)
|
||||||
chrome_options = webdriver.ChromeOptions()
|
chrome_options = webdriver.ChromeOptions()
|
||||||
if mobile:
|
if mobile:
|
||||||
@ -28,20 +33,20 @@ def create_driver(mobile=False, headless=False):
|
|||||||
chrome_options.add_argument(f"--user-agent={PC_USER_AGENT}")
|
chrome_options.add_argument(f"--user-agent={PC_USER_AGENT}")
|
||||||
# disabled as it may cause detection
|
# disabled as it may cause detection
|
||||||
if g.proxy_enabled:
|
if g.proxy_enabled:
|
||||||
PROXY = f"{g.proxy_address}:{g.proxy_port}" # IP:PORT or HOST:PORT
|
chrome_options.add_argument(f'--proxy-server={g.proxy_address}:{g.proxy_port}')
|
||||||
chrome_options.add_argument(f'--proxy-server={PROXY}')
|
|
||||||
driver = uc.Chrome(options=chrome_options)
|
driver = uc.Chrome(options=chrome_options)
|
||||||
set_language(driver)
|
set_language(driver)
|
||||||
return (driver)
|
return driver
|
||||||
|
|
||||||
|
|
||||||
def log_error(error, l_driver=driver, log=g.full_log):
|
def log_error(error_message, l_driver=driver, log=g.full_log):
|
||||||
global driver
|
global driver
|
||||||
if l_driver is None:
|
if l_driver is None:
|
||||||
l_driver = driver
|
l_driver = driver
|
||||||
if type(error) is not str:
|
if type(error_message) is not str:
|
||||||
error = format_error(error)
|
error_message = format_error(error_message)
|
||||||
printf(f"\n\n\033[93m Erreur : {str(error)} \033[0m\n\n")
|
|
||||||
|
error(str(error_message))
|
||||||
if g.discord_enabled_error:
|
if g.discord_enabled_error:
|
||||||
with open("page.html", "w") as f:
|
with open("page.html", "w") as f:
|
||||||
try:
|
try:
|
||||||
@ -56,13 +61,13 @@ def log_error(error, l_driver=driver, log=g.full_log):
|
|||||||
if not log:
|
if not log:
|
||||||
embed = Embed(
|
embed = Embed(
|
||||||
title="An Error has occured",
|
title="An Error has occured",
|
||||||
description=str(error),
|
description=str(error_message),
|
||||||
colour=Colour.red(),
|
colour=Colour.red(),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
embed = Embed(
|
embed = Embed(
|
||||||
title="Full log is enabled",
|
title="Full log is enabled",
|
||||||
description=str(error),
|
description=str(error_message),
|
||||||
colour=Colour.blue(),
|
colour=Colour.blue(),
|
||||||
)
|
)
|
||||||
file = File("screenshot.png")
|
file = File("screenshot.png")
|
||||||
@ -73,10 +78,10 @@ def log_error(error, l_driver=driver, log=g.full_log):
|
|||||||
|
|
||||||
|
|
||||||
# close the tab currently on and go back to the one first, or the one specified
|
# close the tab currently on and go back to the one first, or the one specified
|
||||||
def close_tab(tab, SwitchTo=0) -> None:
|
def close_tab(tab, switch_to: int = 0) -> None:
|
||||||
driver.switch_to.window(tab)
|
driver.switch_to.window(tab)
|
||||||
driver.close()
|
driver.close()
|
||||||
driver.switch_to.window(driver.window_handles[SwitchTo])
|
driver.switch_to.window(driver.window_handles[switch_to])
|
||||||
|
|
||||||
|
|
||||||
# play_quiz[N]([int : override]) make the quiz with N choice each time. They usually have between 4 and 10 questions.
|
# play_quiz[N]([int : override]) make the quiz with N choice each time. They usually have between 4 and 10 questions.
|
||||||
@ -410,16 +415,16 @@ 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):
|
def pwd_login(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)
|
||||||
mail_elem = ldriver.find_element(By.ID, "i0116")
|
mail_elem = ldriver.find_element(By.ID, "i0116")
|
||||||
send_keys_wait(mail_elem, g._mail)
|
send_keys_wait(mail_elem, cred.get_mail())
|
||||||
mail_elem.send_keys(Keys.ENTER)
|
mail_elem.send_keys(Keys.ENTER)
|
||||||
wait_until_visible(By.ID, "i0118", browser=ldriver)
|
wait_until_visible(By.ID, "i0118", browser=ldriver)
|
||||||
pwd_elem = ldriver.find_element(By.ID, "i0118")
|
pwd_elem = ldriver.find_element(By.ID, "i0118")
|
||||||
send_keys_wait(pwd_elem, g._password)
|
send_keys_wait(pwd_elem, cred.get_password())
|
||||||
pwd_elem.send_keys(Keys.ENTER)
|
pwd_elem.send_keys(Keys.ENTER)
|
||||||
custom_sleep(2)
|
custom_sleep(2)
|
||||||
# 2FA
|
# 2FA
|
||||||
@ -478,9 +483,9 @@ def login_part_2(ldriver, cookies=False):
|
|||||||
|
|
||||||
# login() tries to login to your Microsoft account.
|
# login() tries to login to your Microsoft account.
|
||||||
# it uses global variable g._mail and g._password to login
|
# it uses global variable g._mail and g._password to login
|
||||||
def login(ldriver):
|
def login(ldriver, cred: Credentials):
|
||||||
try:
|
try:
|
||||||
pwd_login(ldriver)
|
pwd_login(ldriver, cred)
|
||||||
login_part_2(ldriver, 0)
|
login_part_2(ldriver, 0)
|
||||||
ldriver.get("https://rewards.bing.com/")
|
ldriver.get("https://rewards.bing.com/")
|
||||||
except Banned:
|
except Banned:
|
||||||
@ -528,36 +533,6 @@ def bing_pc_search(override=randint(35, 40)):
|
|||||||
log_error(f"clear la barre de recherche - {format_error(e)}")
|
log_error(f"clear la barre de recherche - {format_error(e)}")
|
||||||
|
|
||||||
|
|
||||||
# Unban an account, called with -u parameter. You will need a phone number
|
|
||||||
def unban() -> None:
|
|
||||||
driver.find_element(By.ID, "StartAction").click()
|
|
||||||
custom_sleep(2)
|
|
||||||
txt = driver.page_source
|
|
||||||
uuid0 = findall('wlspispHIPCountrySelect([a-z0-9]+)', txt)[0]
|
|
||||||
uuid1 = findall('wlspispHIPPhoneInput([a-z0-9]+)', txt)[0]
|
|
||||||
uuid2 = findall('wlspispHipSendCode([a-z0-9]+)', txt)[0]
|
|
||||||
uuid3 = findall('wlspispSolutionElement([a-z0-9]+)', txt)[0]
|
|
||||||
country_code_select = Select(driver.find_element(By.ID, "wlspispHIPCountrySelect" + uuid0))
|
|
||||||
country_code_input = input("enter Country code (FR, ...) ")
|
|
||||||
country_code_select.select_by_value(country_code_input)
|
|
||||||
wait_until_visible(By.ID, "wlspispHIPPhoneInput" + uuid1, browser=driver)
|
|
||||||
phone_input = input("phone number : +33")
|
|
||||||
phone_elem = driver.find_element(By.ID, "wlspispHIPPhoneInput" + uuid1)
|
|
||||||
phone_elem.send_keys(phone_input)
|
|
||||||
wait_until_visible(By.ID, "wlspispHipSendCode" + uuid2, browser=driver)
|
|
||||||
send_sms_elem = driver.find_element(By.ID, "wlspispHipSendCode" + uuid2)
|
|
||||||
send_sms_elem.click()
|
|
||||||
wait_until_visible(By.ID, "wlspispSolutionElement" + uuid3, browser=driver)
|
|
||||||
sms_code_elem = driver.find_element(By.ID, "wlspispSolutionElement" + uuid3)
|
|
||||||
sms_code_input = input("entrez le contenu du msg : ")
|
|
||||||
sms_code_elem.send_keys(sms_code_input)
|
|
||||||
send_box = driver.find_element(By.ID, "ProofAction")
|
|
||||||
send_box.click()
|
|
||||||
wait_until_visible(By.ID, "FinishAction", browser=driver)
|
|
||||||
end_elem = driver.find_element(By.ID, "FinishAction")
|
|
||||||
end_elem.click()
|
|
||||||
|
|
||||||
|
|
||||||
# Sends points to database, discord and whatever service you want
|
# Sends points to database, discord and whatever service you want
|
||||||
def log_points(account="unknown"):
|
def log_points(account="unknown"):
|
||||||
def get_points():
|
def get_points():
|
||||||
@ -726,16 +701,16 @@ def bing_mobile_search(override=randint(22, 25)):
|
|||||||
mobile_driver.quit()
|
mobile_driver.quit()
|
||||||
|
|
||||||
|
|
||||||
def daily_routine(custom=False):
|
def daily_routine(cred: UserCredentials, custom=False):
|
||||||
try:
|
try:
|
||||||
if not custom: # custom already login
|
if not custom: # custom already login
|
||||||
login(driver)
|
login(driver, cred)
|
||||||
except Banned:
|
except Banned:
|
||||||
log_error("This account is locked. Fix that. (-U ?)", driver)
|
log_error("This account is locked.", driver)
|
||||||
return ()
|
return
|
||||||
except Identity:
|
except Identity:
|
||||||
log_error("This account has an issue. Fix that.", driver)
|
log_error("This account has an issue.", driver)
|
||||||
return ()
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
all_cards()
|
all_cards()
|
||||||
@ -828,7 +803,7 @@ def CustomStart():
|
|||||||
driver.quit()
|
driver.quit()
|
||||||
|
|
||||||
|
|
||||||
def very_custom_start(json):
|
def json_start(json):
|
||||||
global driver
|
global driver
|
||||||
display = SmartDisplay(backend="xvnc", size=(1920, 1080), rfbport=2345, color_depth=24)
|
display = SmartDisplay(backend="xvnc", size=(1920, 1080), rfbport=2345, color_depth=24)
|
||||||
display.start()
|
display.start()
|
||||||
@ -847,12 +822,11 @@ def very_custom_start(json):
|
|||||||
print(f"{g._mail} : {j}")
|
print(f"{g._mail} : {j}")
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
# print(f"none is set to \"{j}\"")
|
|
||||||
if start:
|
if start:
|
||||||
driver = create_driver()
|
driver = create_driver()
|
||||||
try:
|
try:
|
||||||
if str(i) in json["unban"]:
|
if str(i) in json["unban"]:
|
||||||
pwd_login(driver) # TODO : define only the first part of login
|
pwd_login(driver)
|
||||||
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)
|
||||||
@ -887,7 +861,6 @@ def very_custom_start(json):
|
|||||||
log_error(e)
|
log_error(e)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
# print("none is set to \"pc\"")
|
|
||||||
try:
|
try:
|
||||||
if str(i) in json["mobile"]:
|
if str(i) in json["mobile"]:
|
||||||
try:
|
try:
|
||||||
@ -896,7 +869,6 @@ def very_custom_start(json):
|
|||||||
log_error(e)
|
log_error(e)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
# print("none is set to \"mobile\"")
|
|
||||||
try:
|
try:
|
||||||
log_points(g._mail)
|
log_points(g._mail)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -908,59 +880,49 @@ def very_custom_start(json):
|
|||||||
|
|
||||||
if g.very_custom:
|
if g.very_custom:
|
||||||
dict_data = json.loads(g.very_custom.replace("'", "\""))
|
dict_data = json.loads(g.very_custom.replace("'", "\""))
|
||||||
very_custom_start(dict_data)
|
json_start(dict_data)
|
||||||
|
|
||||||
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.dev:
|
|
||||||
driver = create_driver()
|
|
||||||
# input("kill ?")
|
|
||||||
driver.quit()
|
|
||||||
elif g.custom_start:
|
|
||||||
CustomStart()
|
|
||||||
elif g.unban:
|
|
||||||
g._mail, g._password = select_accounts(False)[0]
|
|
||||||
driver = create_driver()
|
|
||||||
try:
|
|
||||||
login(driver)
|
|
||||||
except Banned:
|
|
||||||
unban()
|
|
||||||
driver.quit()
|
|
||||||
else:
|
|
||||||
if g.update_version != "None":
|
if g.update_version != "None":
|
||||||
if g.discord_enabled_error:
|
if g.discord_enabled_error:
|
||||||
webhookFailure.send(f"Updated to {g.update_version}", username="UPDATE",
|
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")
|
||||||
for cred in g._cred:
|
|
||||||
if cred[0] != "":
|
while c.UserCredentials.is_valid():
|
||||||
g._mail = cred[0]
|
g._mail = c.UserCredentials.get_mail()
|
||||||
g._password = cred[1]
|
g._password = c.UserCredentials.get_password()
|
||||||
if cred[2] != '':
|
if c.UserCredentials.tfa_enable():
|
||||||
g._otp = TOTP(cred[2])
|
g._otp = TOTP(c.UserCredentials.get_tfa())
|
||||||
|
|
||||||
custom_sleep(1)
|
custom_sleep(1)
|
||||||
printf("Début du driver.")
|
info("Starting driver.")
|
||||||
driver = create_driver()
|
driver = create_driver()
|
||||||
printf("Driver demarré.")
|
info("Driver started.")
|
||||||
driver.implicitly_wait(3)
|
driver.implicitly_wait(3)
|
||||||
try:
|
try:
|
||||||
attente = uniform(1200, 3600)
|
wait_time = uniform(1200, 3600)
|
||||||
printf(f"Attente de {round(attente / 60)} min avant de démarrer")
|
info(f"Waiting for {round(wait_time / 60)}min before starting")
|
||||||
daily_routine()
|
daily_routine(c.UserCredentials)
|
||||||
driver.quit()
|
driver.quit()
|
||||||
custom_sleep(attente)
|
custom_sleep(wait_time)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
printf("Canceled. Closing driver and display.")
|
critical("Canceled by user. Closing driver and display.")
|
||||||
driver.quit()
|
driver.quit()
|
||||||
display.stop()
|
display.stop()
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log_error(f"Error not catched. Skipping this account. " + format_error(e), driver)
|
log_error(f"Error not caught. Skipping this account. " + format_error(e), driver)
|
||||||
printf(f"Error not catched. Skipping this account. {e}")
|
critical(f"Error not caught. Skipping this account. {e}")
|
||||||
driver.quit()
|
driver.quit()
|
||||||
|
|
||||||
|
c.UserCredentials.next_account()
|
||||||
|
|
||||||
display.stop()
|
display.stop()
|
||||||
|
Loading…
Reference in New Issue
Block a user