well don't update till tomorrow I guess

This commit is contained in:
piair 2023-03-27 22:20:54 +02:00
parent d5bacd99a1
commit a2b07b9fcd
5 changed files with 103 additions and 132 deletions

85
V5.py
View File

@ -1,31 +1,10 @@
#!/usr/bin/python3.10
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 modules.imports import *
from modules.db import add_to_database
from modules.config import *
from modules.tools import *
from modules.error import *
import modules.progress
from modules.driver_tools import *
global driver
driver = None
@ -42,13 +21,6 @@ def printf(e, f = ""):
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):
global driver
@ -84,27 +56,6 @@ def log_error(error, ldriver=driver, log=FULL_LOG):
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
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])
#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.
# 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:
@ -472,7 +414,7 @@ def login(ldriver):
if ('Abuse' in ldriver.current_url) :
log_error("account suspended")
raise Banned()
save_cookies()
save_cookies(driver)
for id in ["KmsiCheckboxField","iLooksGood", "idSIButton9", "iCancel"]:
try:
ldriver.find_element(By.ID, id).click()
@ -914,25 +856,6 @@ def CustomStart(Credentials):
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 :
display = SmartDisplay(backend="xvnc", size=(2160, 2160), rfbport=VNC_PORT, color_depth=24)
@ -953,7 +876,7 @@ elif UNBAN:
driver.quit()
elif POINTS_FILE != "":
SavePointsFromFile(POINTS_FILE)
save_points_from_file(POINTS_FILE)
else:
for cred in Credentials:
_mail = cred[0]

55
modules/driver_tools.py Normal file
View File

@ -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")

22
modules/imports.py Normal file
View File

@ -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

View File

@ -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)

View File

@ -1,24 +1,6 @@
from time import sleep
from datetime import timedelta, datetime
from random import uniform
import discord
from selenium.webdriver.common.by import By
from modules.imports 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]&
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) + ">"
spaces = " " * (barLength - len(arrow))
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])