well don't update till tomorrow I guess
This commit is contained in:
parent
d5bacd99a1
commit
a2b07b9fcd
85
V5.py
85
V5.py
|
@ -1,31 +1,10 @@
|
||||||
#!/usr/bin/python3.10
|
#!/usr/bin/python3.10
|
||||||
import asyncio
|
from modules.imports import *
|
||||||
import csv
|
|
||||||
from os import sys, system, path
|
|
||||||
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.common.exceptions import 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.ui import WebDriverWait
|
|
||||||
from selenium.webdriver.support import expected_conditions as EC
|
|
||||||
from selenium.webdriver.support.ui import Select
|
|
||||||
from pyotp import TOTP
|
|
||||||
from pyvirtualdisplay import Display
|
|
||||||
from pyvirtualdisplay.smartdisplay import SmartDisplay
|
|
||||||
import pickle
|
|
||||||
|
|
||||||
from modules.db import add_to_database
|
from modules.db import add_to_database
|
||||||
from modules.config import *
|
from modules.config import *
|
||||||
from modules.tools import *
|
from modules.tools import *
|
||||||
from modules.error import *
|
from modules.error import *
|
||||||
import modules.progress
|
from modules.driver_tools import *
|
||||||
|
|
||||||
global driver
|
global driver
|
||||||
driver = None
|
driver = None
|
||||||
|
@ -42,13 +21,6 @@ def printf(e, f = ""):
|
||||||
|
|
||||||
custom_sleep = CustomSleep
|
custom_sleep = CustomSleep
|
||||||
|
|
||||||
def save_cookies():
|
|
||||||
pickle.dump(driver.get_cookies(), open(f"{'/'.join(__file__.split('/')[:-1])}/user_data/cookies/{_mail}.pkl", "wb"))
|
|
||||||
|
|
||||||
def load_cookies(driver):
|
|
||||||
cookies = pickle.load(open(f"{'/'.join(__file__.split('/')[:-1])}/user_data/cookies/{_mail}.pkl", "rb"))
|
|
||||||
for cookie in cookies:
|
|
||||||
driver.add_cookie(cookie)
|
|
||||||
|
|
||||||
def log_error(error, ldriver=driver, log=FULL_LOG):
|
def log_error(error, ldriver=driver, log=FULL_LOG):
|
||||||
global driver
|
global driver
|
||||||
|
@ -84,27 +56,6 @@ def log_error(error, ldriver=driver, log=FULL_LOG):
|
||||||
webhookFailure.send(file=discord.File("page.html"))
|
webhookFailure.send(file=discord.File("page.html"))
|
||||||
|
|
||||||
|
|
||||||
# Wait for the presence of the element identifier or [timeout]s
|
|
||||||
def wait_until_visible(search_by: str, identifier: str, timeout = 20, browser = driver) -> None:
|
|
||||||
try :
|
|
||||||
WebDriverWait(browser, timeout).until(EC.visibility_of_element_located((search_by,identifier)), "element not found")
|
|
||||||
except TimeoutException as e:
|
|
||||||
print(f"element not found after {timeout}s")
|
|
||||||
|
|
||||||
|
|
||||||
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",
|
|
||||||
}
|
|
||||||
|
|
||||||
# create a webdriver
|
# create a webdriver
|
||||||
def firefox_driver(mobile=False, headless=False):
|
def firefox_driver(mobile=False, headless=False):
|
||||||
|
@ -144,15 +95,6 @@ def close_tab(tab, SwitchTo=0) -> None:
|
||||||
driver.switch_to.window(driver.window_handles[SwitchTo])
|
driver.switch_to.window(driver.window_handles[SwitchTo])
|
||||||
|
|
||||||
|
|
||||||
#Deal with rgpd popup as well as some random popup like 'are you satisfied' one
|
|
||||||
def rgpd_popup(driver) -> None:
|
|
||||||
for i in ["bnp_btn_accept", "bnp_hfly_cta2", "bnp_hfly_close"] :
|
|
||||||
try:
|
|
||||||
driver.find_element(By.ID, i).click()
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
# 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.
|
||||||
# override is the number of question, by default, it's the number of question in this specific quiz. Can be useful in some case, where the program crashes before finishing the quiz
|
# override is the number of question, by default, it's the number of question in this specific quiz. Can be useful in some case, where the program crashes before finishing the quiz
|
||||||
def play_quiz2(override=10) -> None:
|
def play_quiz2(override=10) -> None:
|
||||||
|
@ -472,7 +414,7 @@ def login(ldriver):
|
||||||
if ('Abuse' in ldriver.current_url) :
|
if ('Abuse' in ldriver.current_url) :
|
||||||
log_error("account suspended")
|
log_error("account suspended")
|
||||||
raise Banned()
|
raise Banned()
|
||||||
save_cookies()
|
save_cookies(driver)
|
||||||
for id in ["KmsiCheckboxField","iLooksGood", "idSIButton9", "iCancel"]:
|
for id in ["KmsiCheckboxField","iLooksGood", "idSIButton9", "iCancel"]:
|
||||||
try:
|
try:
|
||||||
ldriver.find_element(By.ID, id).click()
|
ldriver.find_element(By.ID, id).click()
|
||||||
|
@ -914,25 +856,6 @@ def CustomStart(Credentials):
|
||||||
driver.close()
|
driver.close()
|
||||||
|
|
||||||
|
|
||||||
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])
|
|
||||||
|
|
||||||
|
|
||||||
def SavePointsFromFile(file):
|
|
||||||
with open(file) as f:
|
|
||||||
reader = csv.reader(f)
|
|
||||||
points_list = list(reader)
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
with open(file, "w") as f:
|
|
||||||
f.write("")
|
|
||||||
|
|
||||||
|
|
||||||
if VNC_ENABLED :
|
if VNC_ENABLED :
|
||||||
display = SmartDisplay(backend="xvnc", size=(2160, 2160), rfbport=VNC_PORT, color_depth=24)
|
display = SmartDisplay(backend="xvnc", size=(2160, 2160), rfbport=VNC_PORT, color_depth=24)
|
||||||
|
@ -953,7 +876,7 @@ elif UNBAN:
|
||||||
|
|
||||||
driver.quit()
|
driver.quit()
|
||||||
elif POINTS_FILE != "":
|
elif POINTS_FILE != "":
|
||||||
SavePointsFromFile(POINTS_FILE)
|
save_points_from_file(POINTS_FILE)
|
||||||
else:
|
else:
|
||||||
for cred in Credentials:
|
for cred in Credentials:
|
||||||
_mail = cred[0]
|
_mail = cred[0]
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
from modules.imports import *
|
||||||
|
|
||||||
|
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",
|
||||||
|
}
|
||||||
|
|
||||||
|
#Deal with rgpd popup as well as some random popup like 'are you satisfied' one
|
||||||
|
def rgpd_popup(driver) -> None:
|
||||||
|
for i in ["bnp_btn_accept", "bnp_hfly_cta2", "bnp_hfly_close"] :
|
||||||
|
try:
|
||||||
|
driver.find_element(By.ID, i).click()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# save webdriver cookies
|
||||||
|
def save_cookies():
|
||||||
|
pickle.dump(driver.get_cookies(), open(f"{'/'.join(__file__.split('/')[:-1])}/user_data/cookies/{_mail}.pkl", "wb"))
|
||||||
|
|
||||||
|
# load cookies previously saved to the driver
|
||||||
|
def load_cookies(driver):
|
||||||
|
cookies = pickle.load(open(f"{'/'.join(__file__.split('/')[:-1])}/user_data/cookies/{_mail}.pkl", "rb"))
|
||||||
|
for cookie in cookies:
|
||||||
|
driver.add_cookie(cookie)
|
||||||
|
|
||||||
|
"""
|
||||||
|
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 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))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Wait for the presence of the element identifier or [timeout]s
|
||||||
|
def wait_until_visible(search_by: str, identifier: str, timeout = 20, browser = driver) -> None:
|
||||||
|
try :
|
||||||
|
WebDriverWait(browser, timeout).until(EC.visibility_of_element_located((search_by,identifier)), "element not found")
|
||||||
|
except TimeoutException as e:
|
||||||
|
print(f"element not found after {timeout}s")
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
import asyncio
|
||||||
|
import csv
|
||||||
|
from os import sys, system, path
|
||||||
|
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.common.exceptions import 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.ui import WebDriverWait
|
||||||
|
from selenium.webdriver.support import expected_conditions as EC
|
||||||
|
from selenium.webdriver.support.ui import Select
|
||||||
|
from pyotp import TOTP
|
||||||
|
from pyvirtualdisplay import Display
|
||||||
|
from pyvirtualdisplay.smartdisplay import SmartDisplay
|
||||||
|
import pickle
|
||||||
|
from datetime import timedelta, datetime
|
|
@ -1,32 +0,0 @@
|
||||||
#add return a string witx tabs
|
|
||||||
def tabs(x):
|
|
||||||
return(x*4*" ")
|
|
||||||
|
|
||||||
|
|
||||||
#create dictionnary with all progress bars
|
|
||||||
def dico(progress):
|
|
||||||
dico_task = {
|
|
||||||
"daily" : {
|
|
||||||
"all" : progress.add_task("[yellow]daily", total=100, start=False, visible=False),
|
|
||||||
"carte0" : progress.add_task(f"[yellow]{tabs(1)}carte 1", total=100, start=False, visible = False),
|
|
||||||
"carte1" : progress.add_task(f"[yellow]{tabs(1)}carte 2", total=100, start=False, visible = False),
|
|
||||||
"carte2" : progress.add_task(f"[yellow]{tabs(1)}carte 3", total=100, start=False, visible = False)
|
|
||||||
},
|
|
||||||
"weekly" : {
|
|
||||||
"all" : progress.add_task("[yellow]weekly", total=100, start=False, visible=False),
|
|
||||||
"carte1" : progress.add_task(f"[yellow]{tabs(1)}carte 1", total=100, start=False, visible = False),
|
|
||||||
"carte2" : progress.add_task(f"[yellow]{tabs(1)}carte 2", total=100, start=False, visible = False),
|
|
||||||
"carte3" : progress.add_task(f"[yellow]{tabs(1)}carte 3", total=100, start=False, visible = False),
|
|
||||||
"carte3" : progress.add_task(f"[yellow]{tabs(1)}carte 4", total=100, start=False, visible = False),
|
|
||||||
"carte3" : progress.add_task(f"[yellow]{tabs(1)}carte 5", total=100, start=False, visible = False),
|
|
||||||
"carte3" : progress.add_task(f"[yellow]{tabs(1)}carte 6", total=100, start=False, visible = False),
|
|
||||||
"carte3" : progress.add_task(f"[yellow]{tabs(1)}carte 7", total=100, start=False, visible = False),
|
|
||||||
"carte3" : progress.add_task(f"[yellow]{tabs(1)}carte 8", total=100, start=False, visible = False),
|
|
||||||
"carte3" : progress.add_task(f"[yellow]{tabs(1)}carte 9", total=100, start=False, visible = False),
|
|
||||||
},
|
|
||||||
"PC" : progress.add_task(f"[yellow]PC", total=100, start=False, visible = False),
|
|
||||||
"Mobile" : progress.add_task(f"[yellow]Mobile", total=100, start=False, visible = False),
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
return(dico_task)
|
|
|
@ -1,24 +1,6 @@
|
||||||
from time import sleep
|
from modules.imports import *
|
||||||
from datetime import timedelta, datetime
|
|
||||||
from random import uniform
|
|
||||||
import discord
|
|
||||||
|
|
||||||
from selenium.webdriver.common.by import By
|
|
||||||
from modules.config import *
|
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))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# add the time arround the text given in [text]&
|
# add the time arround the text given in [text]&
|
||||||
def Timer(text: str, mail: str) -> str:
|
def Timer(text: str, mail: str) -> str:
|
||||||
|
@ -80,3 +62,24 @@ def progressBar(current, total=30, barLength=20, name="Progress"):
|
||||||
arrow = "-" * int(percent / 100 * barLength - 1) + ">"
|
arrow = "-" * int(percent / 100 * barLength - 1) + ">"
|
||||||
spaces = " " * (barLength - len(arrow))
|
spaces = " " * (barLength - len(arrow))
|
||||||
print(name + ": [%s%s] %d %%" % (arrow, spaces, percent), end="\r")
|
print(name + ": [%s%s] %d %%" % (arrow, spaces, percent), end="\r")
|
||||||
|
|
||||||
|
|
||||||
|
def save_points_from_file(file):
|
||||||
|
with open(file) as f:
|
||||||
|
reader = csv.reader(f)
|
||||||
|
points_list = list(reader)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
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_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])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue