mirror of
https://gitea.augustin64.fr/piair/MsRewards-Reborn.git
synced 2025-07-16 08:56:36 +02:00
Compare commits
76 Commits
05b88945ed
...
v5.5.2
Author | SHA1 | Date | |
---|---|---|---|
12a6968ee0 | |||
8726785dc8 | |||
e9f629dee4 | |||
c9a838d368 | |||
808916ddd3 | |||
c51c463338 | |||
a22d1e6ddb | |||
93bb634f7c | |||
31426a1dfd | |||
f862af8699 | |||
78e7342acf | |||
4d8157ba1e | |||
661566aade | |||
eb2b9dc2d3 | |||
3385540350 | |||
0588180dda | |||
9995bc8e25 | |||
98ff0a183a | |||
d579a2c160 | |||
ccf284f6e2 | |||
f30832d8cd | |||
799d3d67d5 | |||
f10cd8d226 | |||
e41d28c142 | |||
b0c6a93951 | |||
012e923ab5 | |||
0cb0521da6 | |||
c5beafe036 | |||
098b934e96 | |||
339775bdf4 | |||
a2b07b9fcd | |||
d5bacd99a1 | |||
43035e115d | |||
c1bbb26c26 | |||
95156bacd8 | |||
f7c6d3f65e | |||
4ab2530f98 | |||
3ca16d1f37 | |||
db4ab3bf90 | |||
6fefaca00a | |||
a2328c2ca7 | |||
37f002049a | |||
8f655a04fb | |||
860c7b536a | |||
e93d4f0baf | |||
a72c74ec05 | |||
5282b4b434 | |||
0263f2e4c1 | |||
3324fa478d | |||
d14e0efad9 | |||
16ddd7aae9 | |||
66de4dbbd2 | |||
27237354b2 | |||
484a9692cf | |||
ebb1847a51 | |||
80f6cbc919 | |||
dff47887bc | |||
d0c78d7db1 | |||
ebd22102ef | |||
6ce85286dd | |||
db557c2e3c | |||
2888f1d761 | |||
84898cee76 | |||
cef0204868 | |||
93600dd78a | |||
7e64604e9f | |||
c28c2c573d | |||
1a4cd03ae1 | |||
87195de1e5 | |||
4631a6608c | |||
904ad83f36 | |||
cd5ce0f6c1 | |||
e28660ea7d | |||
bad8be5d1f | |||
87b47e97fd | |||
442dbb08d9 |
4
.gitignore
vendored
4
.gitignore
vendored
@ -6,8 +6,10 @@ update.sh
|
||||
page.html
|
||||
screenshot.png
|
||||
login.csv
|
||||
requirements.txt
|
||||
data
|
||||
**/__pycache__
|
||||
/user_data
|
||||
install.sh
|
||||
nohup.out
|
||||
test.py
|
||||
points.csv
|
||||
|
@ -13,7 +13,11 @@ RUN set -x \
|
||||
git \
|
||||
libx11-xcb1 \
|
||||
libdbus-glib-1-2 \
|
||||
libasound.so.2 \
|
||||
libasound2 \
|
||||
libgtk-3-0 \
|
||||
xvfb \
|
||||
nano \
|
||||
tigervnc-standalone-server \
|
||||
&& git clone https://github.com/piair338/MsRewards \
|
||||
&& 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 \
|
||||
|
14
README.md
14
README.md
@ -1,9 +1,9 @@
|
||||
# MsReward
|
||||
|
||||
|
||||
A Microsoft reward automator, designed to work headless on a raspberry pi. Tested with a pi 3b+ and a pi 4 2Gb .
|
||||
Using a discord webhook or SQL to log points everydays.
|
||||
Using Selenium and geckodriver.
|
||||
A Microsoft reward automator, designed to work headless on any server.
|
||||
Using a discord webhook or SQL to log points everyday.
|
||||
Using Selenium and Geckodriver.
|
||||
|
||||
## If you're using docker (way easier)
|
||||
to use docker, run
|
||||
@ -12,17 +12,17 @@ sudo docker build .
|
||||
#copy the build id
|
||||
sudo docker run -ti --name MsRewards [build id]
|
||||
```
|
||||
Then, fill the config and start the programm everydays with
|
||||
Then, fill the config and start the program everyday with
|
||||
```
|
||||
sudo docker start MsRewards
|
||||
```
|
||||
|
||||
## Other configuration
|
||||
|
||||
To use the database, I recommand MySql, Create a database with the name you want and create a table `daily`, like the one from the image :
|
||||
To use the database, I recommend MySql, Create a database with the name you want and create a table `daily`, like the one from the image :
|
||||

|
||||
|
||||
You have to use the default worldlist (`sudo apt install wfrench`). The language is french by default, but you can change it if you want.
|
||||
You have to use the default world list (`sudo apt install wfrench`). The language is french by default, but you can change it if you want.
|
||||
You can add a link to a website where content is only the link of the monthly fidelity card.
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ You should limit to 6 account per IP, and DON'T USE outlook account, they are ba
|
||||
|
||||
installation recommandation :
|
||||
```
|
||||
sudo apt-get install xdg-utils libdbus-glib-1-2 bzip2 wfrench -y
|
||||
sudo apt-get install xdg-utils libdbus-glib-1-2 bzip2 wfrench tigervnc-standalone-server -y
|
||||
|
||||
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 -xjf firefox-91.9.1esr.tar.bz2
|
||||
|
69
database.py
69
database.py
@ -1,6 +1,25 @@
|
||||
import mysql.connector
|
||||
import configparser
|
||||
from os import path
|
||||
import argparse
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"-f",
|
||||
"--file",
|
||||
help="Choose a file",
|
||||
type=argparse.FileType('r')
|
||||
)
|
||||
parser.add_argument(
|
||||
"-m",
|
||||
"--manual",
|
||||
help="add point manually do database",
|
||||
dest="manual",
|
||||
action="store_true"
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
MANUAL = args.manual
|
||||
|
||||
config_path = "./user_data/config.cfg"
|
||||
config = configparser.ConfigParser()
|
||||
@ -35,19 +54,39 @@ def ban_account(name: str, pts = 0):
|
||||
def update_pts(name: str, pts = 0):
|
||||
pass
|
||||
|
||||
if not MANUAL :
|
||||
print("ajouter un compte : 1\nban un compte : 2")
|
||||
i = input()
|
||||
if i == "1":
|
||||
if args.file :
|
||||
l =[x.split(",")[0].split("@")[0] for x in args.file.readlines()]
|
||||
endroit = input("ou est le bot ? ")
|
||||
proprio = input("qui est le proprio ? ")
|
||||
for name in l :
|
||||
add_account(name, endroit, proprio)
|
||||
else :
|
||||
name = input("quel est le nom ? ").split("@")[0]
|
||||
endroit = input("ou est le bot ? ")
|
||||
proprio = input("qui est le proprio ? ")
|
||||
add_account(name, endroit, proprio)
|
||||
elif i == '2':
|
||||
name = input("quel est le compte qui a été ban ? ")
|
||||
pts = input("il avait combien de points ? ")
|
||||
ban_account(name, pts)
|
||||
|
||||
print("ajouter un compte : 1\nban un compte : 2")
|
||||
i = input()
|
||||
if i == "1":
|
||||
name = input("quel est le nom ? ")
|
||||
endroit = input("ou est le bot ? ")
|
||||
proprio = input("qui est le proprio ? ")
|
||||
add_account(name, endroit, proprio)
|
||||
elif i == '2':
|
||||
name = input("quel est le compte qui a été ban ? ")
|
||||
pts = input("il avait combien de points ? ")
|
||||
ban_account(name, pts)
|
||||
|
||||
mydb.commit()
|
||||
mycursor.close()
|
||||
mydb.close()
|
||||
mydb.commit()
|
||||
mycursor.close()
|
||||
mydb.close()
|
||||
else :
|
||||
import modules.db as datab
|
||||
config_path = f"{path.abspath(path.dirname(path.dirname( __file__ )))}/MsRewards/user_data/config.cfg"
|
||||
print(config_path)
|
||||
config = configparser.ConfigParser()
|
||||
config.read(config_path)
|
||||
sql_usr = config["SQL"]["usr"]
|
||||
sql_pwd = config["SQL"]["pwd"]
|
||||
sql_host = config["SQL"]["host"]
|
||||
sql_database = config["SQL"]["database"]
|
||||
account_name = input("compte ? ")
|
||||
points = int(input("points ? "))
|
||||
datab.add_to_database(account_name, points, sql_host, sql_usr, sql_pwd, sql_database)
|
50
main.py
50
main.py
@ -1,8 +1,11 @@
|
||||
#/usr/bin/python3.10
|
||||
|
||||
from packaging.version import parse as parse_version
|
||||
import configparser
|
||||
import os
|
||||
import shutil
|
||||
import requests
|
||||
import sys
|
||||
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
|
||||
@ -16,8 +19,6 @@ except :
|
||||
config.read(config_path)
|
||||
|
||||
|
||||
|
||||
|
||||
def confirm(texte, default = False):
|
||||
if default :
|
||||
txt = '[Y/n]'
|
||||
@ -41,12 +42,12 @@ text = {"fr" : {
|
||||
"next" : "voulez vous ajouter un compte ? ",
|
||||
"finc" : "comptes en cours d'ajout ",
|
||||
"ajout" : "comptes ajouté ",
|
||||
"fidelity" : "avez vous un lien sur lequel le lien vers la page fidelité du mois est le seul contenu de la page ? ",
|
||||
"fidelity" : "avez vous un lien sur lequel le lien vers la page fidélité du mois est le seul contenu de la page ? ",
|
||||
"lien" : "entrez le lien ",
|
||||
"discorde" : "voulez vous envoyer les erreurs sur discord ? ",
|
||||
"w1" : "entrez le lien du WebHook pour envoyer les points ",
|
||||
"w2" : "entrez le lien du WebHook pour envoyer les erreurs ",
|
||||
"msqle" : "voulez vous untiliser une base de donnée ",
|
||||
"msqle" : "voulez vous utiliser une base de donnée ",
|
||||
"msqll" : "entrez le lien de la base de donnée ",
|
||||
"msqlu" : "entrez l'utilisateur de la base de donnée ",
|
||||
"msqlp" : "entrez le mot de passe de la base de donnée ",
|
||||
@ -83,8 +84,6 @@ def setup_comptes():
|
||||
f.write("\n")
|
||||
f.close()
|
||||
print(t["ajout"])
|
||||
|
||||
#modifie le fichier de configuration
|
||||
edit_config_txt("logpath",f'{os.getcwd()}/user_data/login.csv')
|
||||
|
||||
|
||||
@ -111,8 +110,8 @@ def setup_settings():
|
||||
discord()
|
||||
proxy()
|
||||
sql()
|
||||
amazon()
|
||||
|
||||
|
||||
|
||||
def general():
|
||||
if confirm(t["fidelity"]):
|
||||
lien = input(t["lien"])
|
||||
@ -143,7 +142,8 @@ def sql() :
|
||||
edit_config_txt("usr",user)
|
||||
pwd = input(t["msqlp"])
|
||||
edit_config_txt("pwd",pwd)
|
||||
|
||||
|
||||
|
||||
def proxy() :
|
||||
enabled = confirm(t["proxye"], default = False)
|
||||
if enabled :
|
||||
@ -152,14 +152,34 @@ def proxy() :
|
||||
edit_config_txt("url",lien)
|
||||
port = input(t["proxyp"])
|
||||
edit_config_txt("port",port)
|
||||
|
||||
def amazon():
|
||||
enabled = confirm("claim les recompenses automatiquement sur amazon ?", default = False)
|
||||
edit_config_txt("claim_amazon",enabled)
|
||||
|
||||
|
||||
def check_update(args):
|
||||
try :
|
||||
latest = requests.get("https://api.github.com/repos/piair338/MsRewards/releases").json()[0]["tag_name"]
|
||||
latest = parse_version(latest)
|
||||
except Exception as e :
|
||||
print(e)
|
||||
return (args)
|
||||
f = open("./version", 'r')
|
||||
txt = f.readlines()[0].replace("\n","")
|
||||
f.close()
|
||||
cur = parse_version(txt)
|
||||
if not (cur < latest) :
|
||||
print("Already up to date.")
|
||||
return(args)
|
||||
else :
|
||||
print(f"updating to {latest}")
|
||||
os.system("git reset --hard")
|
||||
os.system("git pull")
|
||||
os.system("python3 -m pip install -r requirements.txt > update.result")
|
||||
print(f"updated to {latest}")
|
||||
return(args + f" --version {latest}")
|
||||
|
||||
LogPath = config["PATH"]["logpath"]
|
||||
if LogPath == "/your/path/to/loginandpass.csv" :
|
||||
setup()
|
||||
else :
|
||||
os.system("python3 V4.py")
|
||||
args = " ".join(sys.argv[1::])
|
||||
args = check_update(args)
|
||||
os.system("python3 V5.py " + args)
|
||||
|
69
manual_claim.py
Normal file
69
manual_claim.py
Normal file
@ -0,0 +1,69 @@
|
||||
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()
|
@ -7,7 +7,9 @@ import argparse
|
||||
from discord import ( # Importing discord.Webhook and discord.RequestsWebhookAdapter
|
||||
RequestsWebhookAdapter,
|
||||
Webhook,
|
||||
Colour,
|
||||
)
|
||||
|
||||
from time import time
|
||||
from random import shuffle
|
||||
|
||||
@ -33,13 +35,6 @@ parser.add_argument(
|
||||
action="store_true"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--claim",
|
||||
help="show claim",
|
||||
dest="claim",
|
||||
action="store_true"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"-l",
|
||||
"--log",
|
||||
@ -78,8 +73,22 @@ parser.add_argument(
|
||||
default=""
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"-v",
|
||||
"--vnc",
|
||||
help="enable VNC",
|
||||
dest="vnc",
|
||||
default="None"
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"--version",
|
||||
help="display a message on discord to tell that the bot have been updated",
|
||||
dest="update_version",
|
||||
default="None"
|
||||
)
|
||||
args = parser.parse_args()
|
||||
CLAIM = args.claim
|
||||
|
||||
CUSTOM_START = args.override
|
||||
UNBAN = args.unban
|
||||
LOG = args.log
|
||||
@ -87,11 +96,12 @@ 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
|
||||
# global variables used later in the code
|
||||
LINUX_HOST = platform == "linux" # if the computer running this programm is linux, it allow more things
|
||||
LINUX_HOST = platform == "linux" # if the computer running this program is Linux, it allow more things
|
||||
START_TIME = time()
|
||||
|
||||
|
||||
@ -121,7 +131,11 @@ 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"
|
||||
|
||||
try :
|
||||
AVATAR_URL = config["OTHER"]["avatar"]== "True"
|
||||
except :
|
||||
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:
|
||||
@ -144,9 +158,8 @@ sql_pwd = config["SQL"]["pwd"]
|
||||
sql_host = config["SQL"]["host"]
|
||||
sql_database = config["SQL"]["database"]
|
||||
|
||||
# Other seetings
|
||||
# Other settings
|
||||
IPV6_CHECKED = config["OTHER"]["ipv6"]
|
||||
CLAIM_AMAZON = config["OTHER"]["claim_amazon"] == "True"
|
||||
|
||||
|
||||
g = open(MotPath, "r", encoding="utf-8")
|
||||
|
57
modules/driver_tools.py
Normal file
57
modules/driver_tools.py
Normal file
@ -0,0 +1,57 @@
|
||||
from modules.imports import *
|
||||
from modules.config 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(driver, _mail):
|
||||
pickle.dump(driver.get_cookies(), open(f"{'/'.join(__file__.split('/')[:-2])}/user_data/cookies/{_mail}.pkl", "wb"))
|
||||
|
||||
# load cookies previously saved to the driver
|
||||
def load_cookies(driver, _mail):
|
||||
cookies = pickle.load(open(f"{'/'.join(__file__.split('/')[:-2])}/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 = None) -> 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")
|
||||
|
@ -1,5 +1,3 @@
|
||||
from selenium.common.exceptions import TimeoutException, NoSuchElementException, ElementClickInterceptedException
|
||||
|
||||
class Banned(Exception):
|
||||
pass
|
||||
|
||||
|
24
modules/imports.py
Normal file
24
modules/imports.py
Normal file
@ -0,0 +1,24 @@
|
||||
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.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 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
|
@ -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)
|
101
modules/tools.py
101
modules/tools.py
@ -1,87 +1,37 @@
|
||||
from time import sleep
|
||||
from datetime import timedelta
|
||||
from random import uniform
|
||||
import discord
|
||||
from discord import ( # Importing discord.Webhook and discord.RequestsWebhookAdapter
|
||||
Colour,
|
||||
Webhook,
|
||||
)
|
||||
|
||||
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))
|
||||
|
||||
|
||||
def LogError(message, driver, mail, log=FULL_LOG):
|
||||
print(f"\n\n\033[93m Erreur : {str(message)} \033[0m\n\n")
|
||||
if DISCORD_ENABLED_ERROR:
|
||||
with open("page.html", "w") as f:
|
||||
f.write(driver.page_source)
|
||||
|
||||
driver.save_screenshot("screenshot.png")
|
||||
if not log:
|
||||
embed = discord.Embed(
|
||||
title="An Error has occured",
|
||||
description=str(message),
|
||||
colour=Colour.red(),
|
||||
)
|
||||
else:
|
||||
embed = discord.Embed(
|
||||
title="Full log is enabled",
|
||||
description=str(message),
|
||||
colour=Colour.blue(),
|
||||
)
|
||||
|
||||
file = discord.File("screenshot.png")
|
||||
embed.set_image(url="attachment://screenshot.png")
|
||||
embed.set_footer(text=mail)
|
||||
webhookFailure.send(embed=embed, file=file)
|
||||
webhookFailure.send(file=discord.File("page.html"))
|
||||
|
||||
|
||||
|
||||
# add the time arround the text given in [text]
|
||||
# [text] : string
|
||||
def Timer(text, mail):
|
||||
return(f"[{mail} - {timedelta(seconds = round(float(time() - START_TIME)))}] " + str(text))
|
||||
# add the time arround the text given in [text]&
|
||||
def Timer(text: str, mail: str) -> str:
|
||||
return(f"[{mail} - {datetime.today().strftime('%d-%m-%Y')} - {timedelta(seconds = round(float(time() - START_TIME)))}] " + str(text))
|
||||
|
||||
|
||||
# replace the function print, with more options
|
||||
# [txt] : string, [driver] : selenium wbdriver
|
||||
# [txt] : string, [driver] : selenium webdriver
|
||||
def printf2(txt, mail, LOG = LOG):
|
||||
if LOG:
|
||||
print(Timer(txt, mail))
|
||||
print(Timer(txt, mail))
|
||||
|
||||
|
||||
|
||||
# check if the user is using IPV4 using ipify.org
|
||||
# [driver] : selenium webdriver
|
||||
|
||||
# never used here
|
||||
# can be useful as Ms had issues with IPV6 at some point
|
||||
def check_ipv4(driver):
|
||||
driver.get("https://api64.ipify.org")
|
||||
elm = driver.find_element(BY.TAG_NAME, "body")
|
||||
elm = driver.find_element(By.TAG_NAME, "body")
|
||||
if len(elm.text.split('.')) == 4 :
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
|
||||
def CustomSleep(temps):
|
||||
def custom_sleep(temps):
|
||||
try :
|
||||
if FAST and temps > 50:
|
||||
sleep(temps/10)
|
||||
return()
|
||||
if not LOG or not LINUX_HOST: #only print sleep when user see it
|
||||
elif LOG: #only print sleep when user see it
|
||||
points = ["⢿", "⣻", "⣽", "⣾", "⣷", "⣯", "⣟", "⡿"]
|
||||
passe = 0
|
||||
for i in range(int(temps)):
|
||||
@ -96,7 +46,13 @@ def CustomSleep(temps):
|
||||
print("attente annulée")
|
||||
|
||||
|
||||
|
||||
def format_error(e) -> str:
|
||||
tb = e.__traceback__
|
||||
txt = ""
|
||||
while tb != None :
|
||||
txt = txt + f" -> {tb.tb_frame.f_code.co_name} ({tb.tb_lineno}) "
|
||||
tb = tb.tb_next
|
||||
return(txt + "\n" + str(e))
|
||||
|
||||
|
||||
def progressBar(current, total=30, barLength=20, name="Progress"):
|
||||
@ -104,3 +60,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])
|
||||
|
||||
|
@ -5,3 +5,8 @@ selenium
|
||||
enquiries
|
||||
rich
|
||||
requests
|
||||
pyvirtualdisplay
|
||||
pillow
|
||||
EasyProcess
|
||||
pyotp
|
||||
packaging
|
||||
|
@ -31,6 +31,5 @@ usr = root
|
||||
pwd = password
|
||||
|
||||
[OTHER]
|
||||
|
||||
ipv6 = False
|
||||
claim_amazon = False
|
||||
avatar = https://cdn.discordapp.com/icons/793934298977009674/d8055bccef6eca4855c349e808d0d788.webp
|
||||
ipv6 = False
|
4
user_data/cookies/.gitignore
vendored
Normal file
4
user_data/cookies/.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file
|
||||
!.gitignore
|
Reference in New Issue
Block a user