This commit is contained in:
piair 2023-04-15 11:03:47 +02:00
parent fbb2feae31
commit 2dc8cda167
7 changed files with 143 additions and 142 deletions

View File

@ -19,6 +19,7 @@ RUN set -x \
nano \ nano \
tigervnc-standalone-server \ tigervnc-standalone-server \
&& git clone https://github.com/piair338/MsRewards \ && git clone https://github.com/piair338/MsRewards \
&& ln -fs /usr/share/zoneinfo/Europe/Paris /etc/localtime \
&& pip install -r MsRewards/requirements.txt \ && 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 \ && 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 -jxf firefox-* \ && tar -jxf firefox-* \

63
V5.py
View File

@ -1,7 +1,7 @@
#!/usr/bin/python3.10 #!/usr/bin/python3.10
from modules.imports import * from modules.imports import *
from modules.db import add_to_database
from modules.config import * from modules.config import *
from modules.db import add_to_database
from modules.tools import * from modules.tools import *
from modules.error import * from modules.error import *
from modules.driver_tools import * from modules.driver_tools import *
@ -29,12 +29,8 @@ def firefox_driver(mobile=False, headless=False):
) )
options = Options() options = Options()
options.set_preference('intl.accept_languages', 'fr-FR, fr') 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) options.set_preference("browser.link.open_newwindow", 3)
options.set_preference("dom.confirm_repost.testing.always_accept", True) options.set_preference("dom.confirm_repost.testing.always_accept", True)
if FAST :
options.set_preference("permissions.default.image", 2) #disable image loading. You shouldn't use it except if really nessecary
if headless: if headless:
options.add_argument("-headless") options.add_argument("-headless")
if mobile : if mobile :
@ -48,14 +44,14 @@ def firefox_driver(mobile=False, headless=False):
return(driver) return(driver)
def log_error(error, ldriver=driver, log=FULL_LOG): def log_error(error, ldriver=driver, log=g.full_log):
global driver global driver
if ldriver is None: if ldriver is None:
ldriver = driver ldriver = driver
if type(error) != str : if type(error) != str :
error = format_error(error) error = format_error(error)
printf(f"\n\n\033[93m Erreur : {str(error)} \033[0m\n\n") printf(f"\n\n\033[93m Erreur : {str(error)} \033[0m\n\n")
if DISCORD_ENABLED_ERROR: if g.discord_enabled_error:
with open("page.html", "w") as f: with open("page.html", "w") as f:
try : try :
f.write(ldriver.page_source) f.write(ldriver.page_source)
@ -81,8 +77,8 @@ def log_error(error, ldriver=driver, log=FULL_LOG):
file = File("screenshot.png") file = File("screenshot.png")
embed.set_image(url="attachment://screenshot.png") embed.set_image(url="attachment://screenshot.png")
embed.set_footer(text=g._mail) embed.set_footer(text=g._mail)
webhookFailure.send(embed=embed, username="error", file=file, avatar_url = AVATAR_URL) webhookFailure.send(embed=embed, username="error", file=file, avatar_url = g.avatar_url)
webhookFailure.send(username="error", file=File("page.html"), avatar_url = AVATAR_URL) webhookFailure.send(username="error", file=File("page.html"), avatar_url = g.avatar_url)
# 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
@ -125,6 +121,7 @@ def play_quiz2(override=10) -> None:
log_error(e) log_error(e)
break break
printf("play_quiz2 done") printf("play_quiz2 done")
custom_sleep(3)
def play_quiz8(): def play_quiz8():
@ -164,6 +161,7 @@ def play_quiz8():
except Exception as e: except Exception as e:
log_error(f"{format_error(e)} \n Good answers : {' '.join(correct_answers)}") log_error(f"{format_error(e)} \n Good answers : {' '.join(correct_answers)}")
printf("play_quiz8 : fin ") printf("play_quiz8 : fin ")
custom_sleep(3)
def play_quiz4(override=None): def play_quiz4(override=None):
@ -192,6 +190,7 @@ def play_quiz4(override=None):
log_error(e) log_error(e)
raise ValueError(e) raise ValueError(e)
printf("play_quiz4 : end") printf("play_quiz4 : end")
custom_sleep(3)
# do_poll() answer a random thing to poll, on of daily activities # do_poll() answer a random thing to poll, on of daily activities
@ -208,6 +207,7 @@ def do_poll():
log_error(error) log_error(error)
raise ValueError(error) raise ValueError(error)
printf("do_poll : end") printf("do_poll : end")
custom_sleep(3)
def all_cards(): def all_cards():
@ -552,8 +552,8 @@ def log_points(account="unknown"):
custom_sleep(uniform(3, 20)) custom_sleep(uniform(3, 20))
account_name = account.split("@")[0] account_name = account.split("@")[0]
if DISCORD_ENABLED_SUCCESS: if g.discord_enabled_success:
if DISCORD_EMBED: if g.discord_embed:
embed = Embed( embed = Embed(
title=f"{account_name} actuellement à {str(points)} points", colour=Colour.green() title=f"{account_name} actuellement à {str(points)} points", colour=Colour.green()
) )
@ -562,8 +562,8 @@ def log_points(account="unknown"):
else: else:
webhookSuccess.send(f"{account_name} actuellement à {str(points)} points") webhookSuccess.send(f"{account_name} actuellement à {str(points)} points")
if sql_enabled : if g.sql_enabled :
add_to_database(account_name, points, sql_host, sql_usr, sql_pwd, sql_database) add_to_database(account_name, points, g.sql_host, g.sql_usr, g.sql_pwd, g.sql_database)
def fidelity(): def fidelity():
@ -707,20 +707,19 @@ def daily_routine(custom = False):
def dev(): def dev():
input("paused") input("dev pause")
def CustomStart(Credentials): def CustomStart():
global START_TIME if not g.islinux :
if not LINUX_HOST :
raise NameError('You need to be on linux to do that, due to the utilisation of a module named enquieries, sorry.') raise NameError('You need to be on linux to do that, due to the utilisation of a module named enquieries, sorry.')
global driver, p global driver
system("clear") # clear from previous command to allow a clean choice system("clear") # clear from previous command to allow a clean choice
actions = ["tout", "daily", "pc", "mobile", "log_points","fidelity", "dev"] actions = ["tout", "daily", "pc", "mobile", "log_points","fidelity", "dev"]
Actions = enquiries.choose("quels Actions ?", actions, multi=True) Actions = enquiries.choose("quels Actions ?", actions, multi=True)
liste = select_accounts() liste = select_accounts()
START_TIME = time() # Reset timer to the start of the actions g.start_time = time() # Reset timer to the start of the actions
for cred in liste: for cred in liste:
g._mail = cred[0] g._mail = cred[0]
@ -730,7 +729,6 @@ def CustomStart(Credentials):
driver = firefox_driver() driver = firefox_driver()
driver.implicitly_wait(3) driver.implicitly_wait(3)
if login(driver) != "STOP": if login(driver) != "STOP":
if "tout" in Actions: if "tout" in Actions:
daily_routine(True) daily_routine(True)
@ -765,34 +763,33 @@ def CustomStart(Credentials):
log_points(g._mail) log_points(g._mail)
except Exception as e: except Exception as e:
printf(f"CustomStart {e}") printf(f"CustomStart {e}")
driver.close() driver.quit()
if VNC_ENABLED : if g.vnc_enabled :
display = SmartDisplay(backend="xvnc", size=(2160, 2160), rfbport=VNC_PORT, color_depth=24) display = SmartDisplay(backend="xvnc", size=(2160, 2160), rfbport=g.vnc_port, color_depth=24)
else : else :
display = SmartDisplay(size=(2160, 2160)) display = SmartDisplay(size=(2160, 2160))
display.start() display.start()
if CUSTOM_START: if g.custom_start:
CustomStart(Credentials) CustomStart()
elif UNBAN: elif g.unban:
g._mail, g._password = select_accounts(False)[0] g._mail, g._password = select_accounts(False)[0]
driver = firefox_driver() driver = firefox_driver()
try : try :
login(driver) login(driver)
except Banned: except Banned:
unban() unban()
driver.quit() driver.quit()
elif POINTS_FILE != "": elif g.points_file != "":
save_points_from_file(POINTS_FILE) save_points_from_file(g.points_file)
else: else:
if UPDATE_VERSION != "None": if g.update_version != "None":
if DISCORD_ENABLED_ERROR: if g.discord_enabled_error:
webhookFailure.send(f"Updated to {UPDATE_VERSION}", username="UPDATE", avatar_url="https://cdn-icons-png.flaticon.com/512/1688/1688988.png") 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 Credentials: for cred in g._cred:
g._mail = cred[0] g._mail = cred[0]
g._password = cred[1] g._password = cred[1]
if len(cred) == 3: if len(cred) == 3:

View File

@ -1,18 +1,7 @@
#!/usr/bin/python3.10 #!/usr/bin/python3.10
import configparser from modules.driver_tools import *
from csv import reader from modules.imports import *
from os import sys, system, path import modules.globals as g
from sys import platform
import argparse
from discord import ( # Importing discord.Webhook and discord.RequestsWebhookAdapter
RequestsWebhookAdapter,
Webhook,
Colour,
)
from time import time
from random import shuffle
""" """
Setup for option, like --override or --fulllog Setup for option, like --override or --fulllog
""" """
@ -50,13 +39,6 @@ parser.add_argument(
help="enable full logging in discord", help="enable full logging in discord",
action="store_true", action="store_true",
) )
parser.add_argument(
"-r",
"--risky",
help="make the program faster, probably better risk of ban",
dest="fast",
action="store_true"
)
parser.add_argument( parser.add_argument(
"-c", "-c",
@ -89,26 +71,21 @@ parser.add_argument(
) )
args = parser.parse_args() args = parser.parse_args()
CUSTOM_START = args.override g.custom_start = args.override
UNBAN = args.unban g.unban = args.unban
LOG = args.log g.log = args.log
FULL_LOG = args.fulllog g.full_log = args.fulllog
FAST = args.fast
if CUSTOM_START : if g.custom_start :
LOG = True g.log = True
VNC_ENABLED = args.vnc != "None"
VNC_PORT = args.vnc g.vnc_enabled = args.vnc != "None"
POINTS_FILE = args.points_file g.vnc_port = args.vnc
UPDATE_VERSION = args.update_version g.points_file = args.points_file
g.update_version = args.update_version
# global variables used later in the code # global variables used later in the code
LINUX_HOST = platform == "linux" # if the computer running this program is Linux, it allow more things g.islinux = platform == "linux" # if the computer running this program is Linux, it allow more things
START_TIME = time() g.start_time = time()
if LINUX_HOST:
import enquiries
else:
system("") # enable colors in windows cmd
#reading configuration #reading configuration
@ -122,56 +99,57 @@ config = configparser.ConfigParser()
config.read(config_path) config.read(config_path)
# path configurations # path configurations
MotPath = config["PATH"]["motpath"] g.mot_path = config["PATH"]["motpath"]
CREDENTIALS_PATH = config["PATH"]["logpath"] g.credential_path = config["PATH"]["logpath"]
# discord configuration # discord configuration
DISCORD_SUCCESS_LINK = config["DISCORD"]["successlink"] g.discord_success_link = config["DISCORD"]["successlink"]
DISCORD_ERROR_LINK = config["DISCORD"]["errorlink"] g.discord_error_link = config["DISCORD"]["errorlink"]
DISCORD_ENABLED_ERROR = config["DISCORD"]["DiscordErrorEnabled"] == "True" g.discord_enabled_error = config["DISCORD"]["DiscordErrorEnabled"] == "True"
DISCORD_ENABLED_SUCCESS = config["DISCORD"]["DiscordSuccessEnabled"]== "True" g.discord_enabled_success = config["DISCORD"]["DiscordSuccessEnabled"]== "True"
try : try :
AVATAR_URL = config["OTHER"]["avatar"]== "True" g.avatar_url = config["OTHER"]["avatar"]
except : except :
AVATAR_URL = "https://cdn.discordapp.com/icons/793934298977009674/d8055bccef6eca4855c349e808d0d788.webp" g.avatar_url = "https://cdn.discordapp.com/icons/793934298977009674/d8055bccef6eca4855c349e808d0d788.webp"
if DISCORD_ENABLED_ERROR: if g.discord_enabled_error:
webhookFailure = Webhook.from_url(DISCORD_ERROR_LINK, adapter=RequestsWebhookAdapter()) webhookFailure = Webhook.from_url(g.discord_error_link, adapter=RequestsWebhookAdapter())
if DISCORD_ENABLED_SUCCESS: if g.discord_enabled_success:
webhookSuccess = Webhook.from_url(DISCORD_SUCCESS_LINK, adapter=RequestsWebhookAdapter()) webhookSuccess = Webhook.from_url(g.discord_success_link, adapter=RequestsWebhookAdapter())
# base settings # base settings
FidelityLink = config["SETTINGS"]["FidelityLink"] g.fidelity_link = config["SETTINGS"]["FidelityLink"]
DISCORD_EMBED = config["SETTINGS"]["embeds"] == "True" #print new point value in an embed g.discord_embed = config["SETTINGS"]["embeds"] == "True" #print new point value in an embed
Headless = config["SETTINGS"]["headless"] == "True" g.headless = config["SETTINGS"]["headless"] == "True"
# proxy settings # proxy settings
proxy_enabled = config["PROXY"]["proxy_enabled"] == "True" g.proxy_enabled = config["PROXY"]["proxy_enabled"] == "True"
proxy_address = config["PROXY"]["url"] g.proxy_address = config["PROXY"]["url"]
proxy_port = config["PROXY"]["port"] g.proxy_port = config["PROXY"]["port"]
# MySQL settings # MySQL settings
sql_enabled = config["SQL"]["sql_enabled"] == "True" g.sql_enabled = config["SQL"]["sql_enabled"] == "True"
sql_usr = config["SQL"]["usr"] g.sql_usr = config["SQL"]["usr"]
sql_pwd = config["SQL"]["pwd"] g.sql_pwd = config["SQL"]["pwd"]
sql_host = config["SQL"]["host"] g.sql_host = config["SQL"]["host"]
sql_database = config["SQL"]["database"] g.sql_database = config["SQL"]["database"]
# Other settings
IPV6_CHECKED = config["OTHER"]["ipv6"]
g = open(MotPath, "r", encoding="utf-8") h = open(g.mot_path, "r", encoding="utf-8")
lines = g.readlines() lines = h.readlines()
if len(lines) < 3 : if len(lines) < 3 :
Liste_de_mot = list(lines[0].split(",")) Liste_de_mot = list(lines[0].split(","))
else : else :
Liste_de_mot = [x.replace('\n', "") for x in lines] Liste_de_mot = [x.replace('\n', "") for x in lines]
g.close() h.close()
with open(CREDENTIALS_PATH) as f: with open(g.credential_path) as f:
reader = reader(f) reader = reader(f)
Credentials = list(reader) Credentials = list(reader)
shuffle(Credentials) shuffle(Credentials)
g._cred = Credentials
if g.proxy_enabled :
setup_proxy(g.proxy_address,g.proxy_port)

View File

@ -3,14 +3,8 @@ from modules.config import *
from modules.tools import * from modules.tools import *
import modules.globals as g import modules.globals as g
def setup_proxy(ip, port, options, socks=False) : def setup_proxy(ip, port) :
PROXY = f"{ip}:{port}" 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'] = { webdriver.DesiredCapabilities.FIREFOX['proxy'] = {
"httpProxy": PROXY, "httpProxy": PROXY,
"sslProxy": PROXY, "sslProxy": PROXY,
@ -42,9 +36,6 @@ keys can be an string, but also selenium keys
def send_keys_wait(element, keys): def send_keys_wait(element, keys):
for i in keys: for i in keys:
element.send_keys(i) element.send_keys(i)
if FAST :
pass
else :
sleep(uniform(0.1, 0.3)) sleep(uniform(0.1, 0.3))

View File

@ -3,3 +3,32 @@ _mail = '_mail temp'
_password = '_password temp' _password = '_password temp'
_otp = '_otp temp' _otp = '_otp temp'
display = None display = None
_cred = []
custom_start = False
unban = False
log = False
full_log = False
vnc_enabled = False
vnc_port = 0
points_file = "/"
update_version = False
islinux = True
start_time = 0
mot_path = "/"
credential_path = "/"
discord_success_link = "https://example.com"
discord_error_link = "https://example.com"
discord_enabled_error = False
discord_enabled_success = False
avatar_url = ""
fidelity_link = "https://example.com"
discord_embed = False
headless = False
proxy_enabled = False
proxy_address = "0.0.0.0"
proxy_port = "0"
sql_enabled = False
sql_usr = "None"
sql_pwd = "azerty"
sql_host = "https://example.com"
sql_database = "MsRewards"

View File

@ -1,24 +1,32 @@
import argparse
import asyncio import asyncio
import csv import configparser
from os import sys, system, path import pickle
from csv import reader
from datetime import datetime, timedelta
from os import path, sys, system
from random import choice, randint, shuffle, uniform from random import choice, randint, shuffle, uniform
from re import findall, search from re import findall, search
from sys import platform from sys import platform
from time import sleep from time import sleep, time
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, StaleElementReferenceException
from discord import Colour, Embed, File, RequestsWebhookAdapter, Webhook
from pyotp import TOTP from pyotp import TOTP
from pyvirtualdisplay import Display from pyvirtualdisplay import Display
from pyvirtualdisplay.smartdisplay import SmartDisplay from pyvirtualdisplay.smartdisplay import SmartDisplay
import pickle from requests import get
from datetime import timedelta, datetime from selenium import webdriver
from discord import Embed, Colour, File from selenium.common import exceptions
from selenium.common.exceptions import (ElementClickInterceptedException,
NoSuchElementException,
StaleElementReferenceException,
TimeoutException, 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 import expected_conditions as EC
from selenium.webdriver.support.ui import Select, WebDriverWait
try:
import enquiries
except:
system("") # enable colors in windows cmd

View File

@ -1,10 +1,9 @@
from modules.imports import * from modules.imports import *
from modules.config import * from modules.config import *
import modules.globals as g import modules.globals as g
# add the time arround the text given in [text]& # add the time arround the text given in [text]&
def Timer(text: str) -> str: def Timer(text: str) -> str:
return(f"[{g._mail.split('@')[0]} - {datetime.today().strftime('%d/%m')} - {timedelta(seconds = round(float(time() - START_TIME)))}] " + str(text)) return(f"[{g._mail.split('@')[0]} - {datetime.today().strftime('%d/%m')} - {timedelta(seconds = round(float(time() - g.start_time)))}] " + str(text))
# replace the function print, with more options # replace the function print, with more options
@ -32,9 +31,7 @@ def check_ipv4(driver):
def custom_sleep(temps): def custom_sleep(temps):
try : try :
if FAST and temps > 50: if g.log : #only print sleep when user see it
sleep(temps/10)
elif LOG: #only print sleep when user see it
points = ["", "", "", "", "", "", "", ""] points = ["", "", "", "", "", "", "", ""]
passe = 0 passe = 0
for i in range(int(temps)): for i in range(int(temps)):
@ -80,7 +77,7 @@ def save_points_from_file(file):
def select_accounts(multiple = True): def select_accounts(multiple = True):
system("clear") # clear from previous command to allow a clean choice system("clear") # clear from previous command to allow a clean choice
emails = [x[0] for x in Credentials] # list of all email adresses emails = [x[0] for x in g._cred] # list of all email adresses
emails_selected = enquiries.choose(f"quel{'s' if multiple else ''} compte{'s' if multiple else ''} ?", emails, multi=multiple) 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]) return([x for x in g._cred if x[0] in emails_selected])