work first try ? POG

This commit is contained in:
piair 2022-10-09 13:33:13 +02:00
parent b8690dfd05
commit fd7feebca5
3 changed files with 101 additions and 48 deletions

88
V4.py
View File

@ -7,12 +7,12 @@ from random import choice, randint, shuffle, uniform
from re import findall, search
from sys import platform
from time import sleep, time
from tkinter import EXCEPTION
from requests import get
from datetime import timedelta
import discord
from discord import ( # Importing discord.Webhook and discord.RequestsWebhookAdapter
Colour,
Embed,
RequestsWebhookAdapter,
Webhook,
)
@ -65,7 +65,7 @@ if CUSTOM_START :
gloabal variables used later in the code
"""
LINUX_HOST = platform == "linux"
LINUX_HOST = platform == "linux" #if the computer running this programm is linux, it allow more things
START_TIME = time()
global driver
@ -75,35 +75,37 @@ driver = None
if LINUX_HOST:
import enquiries
else:
system("") # enable colors in cmd
system("") # enable colors in windows cmd
#reading configuration
config_path = f"{path.abspath( path.dirname( __file__ ) )}/config"
config = configparser.ConfigParser()
config.read(config_path)
# path comfigurations
MotPath = config["PATH"]["motpath"]
CREDENTIALS_PATH = config["PATH"]["logpath"]
"""
discord configuration
"""
SuccessLink = config["DISCORD"]["successlink"]
ErrorLink = config["DISCORD"]["errorlink"]
discord_enabled = config["DISCORD"]["enabled"]
# discord configuration
DISCORD_SUCCESS_LINK = config["DISCORD"]["successlink"]
DISCORD_ERROR_LINK = config["DISCORD"]["errorlink"]
DISCORD_ENABLED = config["DISCORD"]["enabled"]
if discord_enabled:
webhookFailure = Webhook.from_url(ErrorLink, adapter=RequestsWebhookAdapter())
webhookSuccess = Webhook.from_url(SuccessLink, adapter=RequestsWebhookAdapter())
if DISCORD_ENABLED:
webhookFailure = Webhook.from_url(DISCORD_ERROR_LINK, adapter=RequestsWebhookAdapter())
webhookSuccess = Webhook.from_url(DISCORD_SUCCESS_LINK, adapter=RequestsWebhookAdapter())
# base settings
FidelityLink = config["SETTINGS"]["FidelityLink"]
embeds = config["SETTINGS"]["embeds"] == "True" #print new point value in an embed
Headless = config["SETTINGS"]["headless"] == "True"
# proxy settings
proxy_enabled = config["PROXY"]["enabled"] == "True"
proxy_address = config["PROXY"]["url"]
proxy_port = config["PROXY"]["port"]
# MySQL settings
sql_enabled = config["SQL"]["enabled"] == "True"
sql_usr = config["SQL"]["usr"]
@ -111,6 +113,11 @@ sql_pwd = config["SQL"]["pwd"]
sql_host = config["SQL"]["host"]
sql_database = config["SQL"]["database"]
# Other seetings
IPV6_CHECKED = config["OTHER"]["ipv6"]
CLAIM_AMAZON = config["OTHER"]["claim_amazon"]
g = open(MotPath, "r", encoding="utf-8")
lines = g.readlines()
if len(lines) < 3 :
@ -134,6 +141,38 @@ def check_ipv4():
return False
def claim_amazon(): #only work in french for now
try :
driver.get("https://rewards.microsoft.com/redeem/000803000031")
driver.find_element(By.XPATH, "//span[contains( text( ), 'ÉCHANGER UNE RÉCOMPENSE')]").click()
sleep(5)
driver.find_element(By.XPATH, "//span[contains( text( ), 'CONFIRMER LA RÉCOMPENSE')]").click()
sleep(5)
if ("/rewards/redeem/orderhistory" in driver.page_source) :
driver.get("https://rewards.microsoft.com/redeem/orderhistory")
driver.find_element(By.XPATH, "//span[contains( text( ), 'Détails de la commande')]").click()
sleep(5)
code = driver.find_element(By.CLASS_NAME, "tango-credential-value").get_attribute('innerHTML')
lien = driver.find_elements(By.CLASS_NAME, "tango-credential-key")[1].get_attribute('innerHTML')
lien = search('\"([^\"]+)\"',lien)[1]
driver.get(lien)
sleep(10)
box = driver.find_element(By.ID, "input-45")
box.click()
box.send_keys(code)
driver.find_element(By.XPATH, "//span[contains( text( ), 'Déverrouillez votre récompense')]").click()
sleep(5)
fcode = driver.find_element(By.XPATH, "//div[@data-test-id='rewardCredentialValue-cardNumber']").get_attribute("innerHTML")
amazon = search("> ([^ ]+) <", fcode)[1]
webhookSuccess.send(amazon)
else :
LogError("la recuperation ne peux pas être automatique")
except Exception as e :
LogError('problème dans la recuperation')
def setup_proxy(ip, port) :
PROXY = f"{ip}:{port}"
webdriver.DesiredCapabilities.FIREFOX['proxy'] = {
@ -143,7 +182,6 @@ def setup_proxy(ip, port) :
}
def FirefoxDriver(mobile=False, Headless=Headless):
if proxy_enabled :
setup_proxy(proxy_address,proxy_port)
@ -187,16 +225,7 @@ def CustomSleep(temps):
sleep(temps/10)
return()
if LOG or not LINUX_HOST: #only print sleep when user see it
points = [
" . ",
" . ",
" . ",
" .",
" .",
" . ",
" . ",
" . ",
]
points = ["", "", "", "", "", "", "", ""]
passe = 0
for i in range(int(temps)):
for i in range(8):
@ -230,7 +259,7 @@ def LogError(message, log=FULL_LOG, Mobdriver=None):
else:
gdriver = driver
if LINUX_HOST and discord_enabled:
if LINUX_HOST and DISCORD_ENABLED:
with open("page.html", "w") as f:
f.write(gdriver.page_source)
@ -522,6 +551,7 @@ def send_keys_wait(element, keys):
else :
sleep(uniform(0.1, 0.3))
"""
login() tries to login to your micrososft account.
it uses global variable _mail and _password to login
@ -874,7 +904,7 @@ def LogPoint(account="unknown"): # log des points sur discord
account = account.split("@")[0]
if discord_enabled:
if DISCORD_ENABLED:
if embeds:
embed = discord.Embed(
@ -888,6 +918,9 @@ def LogPoint(account="unknown"): # log des points sur discord
if sql_enabled :
add_to_database(account, points, sql_host, sql_usr, sql_pwd, sql_database)
if CLAIM_AMAZON:
claim_amazon()
def Fidelite():
try:
@ -1069,11 +1102,8 @@ shuffle(Credentials)
if CUSTOM_START:
CustomStart(Credentials)
else:
for i in Credentials:
for _mail, _password in Credentials:
system("pkill -9 firefox")
_mail = i[0]
_password = i[1]
print("\n\n")
print(_mail)
CustomSleep(1)

1
config
View File

@ -32,3 +32,4 @@ pwd = password
[OTHER]
ipv6 = False
claim_amazon = False

52
main.py
View File

@ -43,7 +43,6 @@ text = {"fr" : {
"proxye" : "voulez vous utiliser un proxy",
"proxyl" : "entrez le lien du proxy",
"proxyp" : "entrez le port du proxy"
}
}
@ -74,10 +73,10 @@ def setup_comptes():
print(t["ajout"])
#modifie le fichier de configuration
edit_config(3,f'{os.getcwd()}/login.csv')
edit_config_txt("logpath",f'{os.getcwd()}/login.csv')
def edit_config(ligne, contenu):
def edit_config_ligne(ligne, contenu):
f = open(config_path, "r")
txt = f.readlines()
txt[ligne] = f'{txt[ligne].split("=")[0]}= {contenu}\n'
@ -89,47 +88,70 @@ def edit_config(ligne, contenu):
f.close()
def edit_config_txt(ligne, contenu):
f = open(config_path, "r")
txt = f.readlines()
f.close()
if txt.count(txt) >1:
raise NameError("il y a plus d'une occurence, echec de la modification")
for i in range(len(txt)) :
name = txt[i].split(" = ")[0]
if name == ligne:
txt[i] = name + " = " + contenu
f = open(config_path, "w")
for i in txt :
f.write(i)
f.close()
def setup_settings():
general()
discord()
proxy()
sql()
amazon()
def general():
if confirm(t["fidelity"]):
lien = input(t["lien"])
edit_config(7,lien)
edit_config_txt('FidelityLink',lien)
def discord():
enabled = confirm(t["discorde"], default = True)
if enabled :
edit_config(13, True)
edit_config_ligne(13, True)
w1 = input(t["w1"])
edit_config(14,w1)
edit_config_txt("successlink",w1)
w2 = input(t["w2"])
edit_config(15,w2)
edit_config_txt("errorlink",w2)
def sql() :
enabled = confirm(t["msqle"], default = False)
if enabled :
edit_config(25, True)
edit_config_ligne(25, True)
lien = input(t["msqll"])
edit_config(26,lien)
edit_config_txt("host",lien)
table = input(t["msqlt"])
edit_config(27,table)
edit_config_txt("database",table)
user = input(t["msqlu"])
edit_config(28,user)
edit_config_txt("usr",user)
pwd = input(t["msqlp"])
edit_config(29,pwd)
edit_config_txt("pwd",pwd)
def proxy() :
enabled = confirm(t["proxye"], default = False)
if enabled :
edit_config(19, True)
edit_config_ligne(19, True)
lien = input(t["proxyl"])
edit_config(20,lien)
edit_config_txt("url",lien)
port = input(t["proxyp"])
edit_config(21,port)
edit_config_txt("port",port)
def amazon():
enabled = confirm("claim les recompenses automatiquement sur amazon ?", default = False)
edit_config_txt("claim_amazon",enabled)
LogPath = config["PATH"]["logpath"]