implementing UserCredential class
This commit is contained in:
parent
cf6905b169
commit
b89d3036bb
178
V6.py
178
V6.py
|
@ -5,21 +5,26 @@ from modules.driver_tools import *
|
|||
from modules.cards import *
|
||||
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
|
||||
display = g.display
|
||||
|
||||
|
||||
# create a webdriver
|
||||
def create_driver(mobile=False, headless=False):
|
||||
def create_driver(mobile=False):
|
||||
PC_USER_AGENT = (
|
||||
"Mozilla/5.0 (X11; Linux x86_64)"
|
||||
"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 = (
|
||||
"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)"
|
||||
"Chrome/%s Mobile Safari/537.36"
|
||||
"Chrome/22 Mobile Safari/537.36"
|
||||
)
|
||||
chrome_options = webdriver.ChromeOptions()
|
||||
if mobile:
|
||||
|
@ -28,20 +33,20 @@ def create_driver(mobile=False, headless=False):
|
|||
chrome_options.add_argument(f"--user-agent={PC_USER_AGENT}")
|
||||
# disabled as it may cause detection
|
||||
if g.proxy_enabled:
|
||||
PROXY = f"{g.proxy_address}:{g.proxy_port}" # IP:PORT or HOST:PORT
|
||||
chrome_options.add_argument(f'--proxy-server={PROXY}')
|
||||
chrome_options.add_argument(f'--proxy-server={g.proxy_address}:{g.proxy_port}')
|
||||
driver = uc.Chrome(options=chrome_options)
|
||||
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
|
||||
if l_driver is None:
|
||||
l_driver = driver
|
||||
if type(error) is not str:
|
||||
error = format_error(error)
|
||||
printf(f"\n\n\033[93m Erreur : {str(error)} \033[0m\n\n")
|
||||
if type(error_message) is not str:
|
||||
error_message = format_error(error_message)
|
||||
|
||||
error(str(error_message))
|
||||
if g.discord_enabled_error:
|
||||
with open("page.html", "w") as f:
|
||||
try:
|
||||
|
@ -56,13 +61,13 @@ def log_error(error, l_driver=driver, log=g.full_log):
|
|||
if not log:
|
||||
embed = Embed(
|
||||
title="An Error has occured",
|
||||
description=str(error),
|
||||
description=str(error_message),
|
||||
colour=Colour.red(),
|
||||
)
|
||||
else:
|
||||
embed = Embed(
|
||||
title="Full log is enabled",
|
||||
description=str(error),
|
||||
description=str(error_message),
|
||||
colour=Colour.blue(),
|
||||
)
|
||||
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
|
||||
def close_tab(tab, SwitchTo=0) -> None:
|
||||
def close_tab(tab, switch_to: int = 0) -> None:
|
||||
driver.switch_to.window(tab)
|
||||
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.
|
||||
|
@ -410,16 +415,16 @@ def try_play(nom="inconnu"):
|
|||
|
||||
# Login with password or with cookies.
|
||||
# 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")
|
||||
ldriver.get("https://login.live.com")
|
||||
wait_until_visible(By.ID, "i0116", browser=ldriver)
|
||||
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)
|
||||
wait_until_visible(By.ID, "i0118", browser=ldriver)
|
||||
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)
|
||||
custom_sleep(2)
|
||||
# 2FA
|
||||
|
@ -478,9 +483,9 @@ def login_part_2(ldriver, cookies=False):
|
|||
|
||||
# login() tries to login to your Microsoft account.
|
||||
# it uses global variable g._mail and g._password to login
|
||||
def login(ldriver):
|
||||
def login(ldriver, cred: Credentials):
|
||||
try:
|
||||
pwd_login(ldriver)
|
||||
pwd_login(ldriver, cred)
|
||||
login_part_2(ldriver, 0)
|
||||
ldriver.get("https://rewards.bing.com/")
|
||||
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)}")
|
||||
|
||||
|
||||
# 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
|
||||
def log_points(account="unknown"):
|
||||
def get_points():
|
||||
|
@ -726,16 +701,16 @@ def bing_mobile_search(override=randint(22, 25)):
|
|||
mobile_driver.quit()
|
||||
|
||||
|
||||
def daily_routine(custom=False):
|
||||
def daily_routine(cred: UserCredentials, custom=False):
|
||||
try:
|
||||
if not custom: # custom already login
|
||||
login(driver)
|
||||
login(driver, cred)
|
||||
except Banned:
|
||||
log_error("This account is locked. Fix that. (-U ?)", driver)
|
||||
return ()
|
||||
log_error("This account is locked.", driver)
|
||||
return
|
||||
except Identity:
|
||||
log_error("This account has an issue. Fix that.", driver)
|
||||
return ()
|
||||
log_error("This account has an issue.", driver)
|
||||
return
|
||||
|
||||
try:
|
||||
all_cards()
|
||||
|
@ -828,7 +803,7 @@ def CustomStart():
|
|||
driver.quit()
|
||||
|
||||
|
||||
def very_custom_start(json):
|
||||
def json_start(json):
|
||||
global driver
|
||||
display = SmartDisplay(backend="xvnc", size=(1920, 1080), rfbport=2345, color_depth=24)
|
||||
display.start()
|
||||
|
@ -847,12 +822,11 @@ def very_custom_start(json):
|
|||
print(f"{g._mail} : {j}")
|
||||
except KeyError:
|
||||
pass
|
||||
# print(f"none is set to \"{j}\"")
|
||||
if start:
|
||||
driver = create_driver()
|
||||
try:
|
||||
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.")
|
||||
for _ in range(1200):
|
||||
sleep(1)
|
||||
|
@ -887,7 +861,6 @@ def very_custom_start(json):
|
|||
log_error(e)
|
||||
except KeyError:
|
||||
pass
|
||||
# print("none is set to \"pc\"")
|
||||
try:
|
||||
if str(i) in json["mobile"]:
|
||||
try:
|
||||
|
@ -896,7 +869,6 @@ def very_custom_start(json):
|
|||
log_error(e)
|
||||
except KeyError:
|
||||
pass
|
||||
# print("none is set to \"mobile\"")
|
||||
try:
|
||||
log_points(g._mail)
|
||||
except Exception as e:
|
||||
|
@ -908,59 +880,49 @@ def very_custom_start(json):
|
|||
|
||||
if g.very_custom:
|
||||
dict_data = json.loads(g.very_custom.replace("'", "\""))
|
||||
very_custom_start(dict_data)
|
||||
json_start(dict_data)
|
||||
|
||||
else:
|
||||
c = Config(args)
|
||||
if g.vnc_enabled or g.dev:
|
||||
display = SmartDisplay(backend="xvnc", size=(1920, 1080), rfbport=g.vnc_port, color_depth=24)
|
||||
else:
|
||||
display = SmartDisplay(size=(1920, 1080))
|
||||
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.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:
|
||||
if cred[0] != "":
|
||||
g._mail = cred[0]
|
||||
g._password = cred[1]
|
||||
if cred[2] != '':
|
||||
g._otp = TOTP(cred[2])
|
||||
custom_sleep(1)
|
||||
printf("Début du driver.")
|
||||
driver = create_driver()
|
||||
printf("Driver demarré.")
|
||||
driver.implicitly_wait(3)
|
||||
try:
|
||||
attente = uniform(1200, 3600)
|
||||
printf(f"Attente de {round(attente / 60)} min avant de démarrer")
|
||||
daily_routine()
|
||||
driver.quit()
|
||||
custom_sleep(attente)
|
||||
except KeyboardInterrupt:
|
||||
printf("Canceled. Closing driver and display.")
|
||||
driver.quit()
|
||||
display.stop()
|
||||
break
|
||||
except Exception as e:
|
||||
log_error(f"Error not catched. Skipping this account. " + format_error(e), driver)
|
||||
printf(f"Error not catched. Skipping this account. {e}")
|
||||
driver.quit()
|
||||
|
||||
display.stop()
|
||||
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")
|
||||
|
||||
while c.UserCredentials.is_valid():
|
||||
g._mail = c.UserCredentials.get_mail()
|
||||
g._password = c.UserCredentials.get_password()
|
||||
if c.UserCredentials.tfa_enable():
|
||||
g._otp = TOTP(c.UserCredentials.get_tfa())
|
||||
|
||||
custom_sleep(1)
|
||||
info("Starting driver.")
|
||||
driver = create_driver()
|
||||
info("Driver started.")
|
||||
driver.implicitly_wait(3)
|
||||
try:
|
||||
wait_time = uniform(1200, 3600)
|
||||
info(f"Waiting for {round(wait_time / 60)}min before starting")
|
||||
daily_routine(c.UserCredentials)
|
||||
driver.quit()
|
||||
custom_sleep(wait_time)
|
||||
except KeyboardInterrupt:
|
||||
critical("Canceled by user. Closing driver and display.")
|
||||
driver.quit()
|
||||
display.stop()
|
||||
break
|
||||
except Exception as e:
|
||||
log_error(f"Error not caught. Skipping this account. " + format_error(e), driver)
|
||||
critical(f"Error not caught. Skipping this account. {e}")
|
||||
driver.quit()
|
||||
|
||||
c.UserCredentials.next_account()
|
||||
|
||||
display.stop()
|
||||
|
|
Loading…
Reference in New Issue