25 Commits

Author SHA1 Message Date
550e36b954 less errors 2023-05-31 10:52:45 +02:00
4814dfed46 hotfix, but a nice one 2023-05-30 20:21:25 +02:00
67aad7921f useful untested update 2023-05-12 14:53:52 +02:00
ecd5a9f204 small fixes, testing tomorrow then releasing 2023-05-09 13:09:14 +02:00
2b1c7b985e Create CODE_OF_CONDUCT.md 2023-05-08 21:17:23 +02:00
c9c93e9828 Merge branch 'master' of https://github.com/piair338/MsRewards
what am i breaking ?
2023-05-08 20:58:58 +02:00
1a4ed4f4e7 lang + small error fix 2023-05-08 20:56:55 +02:00
0ba92798ad Update README.md
A better installation tutorial ?
2023-05-08 20:44:51 +02:00
4aef2bf948 added switches 2023-05-07 23:26:27 +02:00
68395f4314 new handeling method for fidelity. Need deeper testing, but should be fine. 2023-05-07 12:51:38 +02:00
2ca2779ec9 fixed a rare error occuring when the cookie creation isn't successful 2023-05-05 11:56:26 +02:00
5ef8d8b7ca some fixes. I believe it's stable. New release tomorrow 2023-05-05 11:40:38 +02:00
f2d08e9137 still dont know 2023-05-04 20:32:19 +02:00
d946298a38 don't know 2023-05-04 17:49:51 +02:00
ed1e91b304 ptite update 2023-04-25 21:56:29 +02:00
710c272659 better logs 2023-04-17 22:28:26 +02:00
6f325c5a6a small fix 2023-04-17 22:00:46 +02:00
3b82419d4d fixed fidelity, but a new version may come sooner or later 2023-04-15 13:10:14 +02:00
9e0514a902 only the number of the config 2023-04-15 11:18:55 +02:00
5c8730dc26 only the number of the config 2023-04-15 11:18:36 +02:00
d11ae4055c euh ué 2023-04-15 11:04:23 +02:00
2dc8cda167 euh ué 2023-04-15 11:03:47 +02:00
fbb2feae31 small but infinite error 2023-04-14 10:31:12 +02:00
8d53a2b30b ok 2023-04-13 22:38:27 +02:00
f8f3ff2382 uéuéué 2023-04-13 22:22:06 +02:00
16 changed files with 700 additions and 474 deletions

3
.gitignore vendored
View File

@ -1,7 +1,6 @@
/old /old
geckodriver.log geckodriver.log
.vscode/ .vscode/
update.sh
/Git /Git
page.html page.html
screenshot.png screenshot.png
@ -11,5 +10,5 @@ data
/user_data /user_data
install.sh install.sh
nohup.out nohup.out
test.py
points.csv points.csv
/dev

127
CODE_OF_CONDUCT.md Normal file
View File

@ -0,0 +1,127 @@
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at piair338@gmail.com.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series
of actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within
the community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.

View File

@ -4,11 +4,11 @@ ENV DEBIAN_FRONTEND noninteractive
ENV GECKODRIVER_VER v0.31.0 ENV GECKODRIVER_VER v0.31.0
ENV FIREFOX_VER 87.0 ENV FIREFOX_VER 87.0
WORKDIR /app WORKDIR /app
RUN set -x \ RUN set -x \
&& apt update \ && apt update \
&& apt upgrade -y \ && apt upgrade -y \
&& apt install -y \ && apt install -y \
tzdata \
wfrench \ wfrench \
git \ git \
libx11-xcb1 \ libx11-xcb1 \
@ -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-* \
@ -31,6 +32,7 @@ RUN set -x \
&& mv geckodriver /usr/bin/ && mv geckodriver /usr/bin/
ENV TZ="Europe/Paris"
WORKDIR /app/MsRewards WORKDIR /app/MsRewards
CMD python main.py CMD python main.py

View File

@ -1,46 +1,50 @@
# MsReward # MsReward
A Microsoft reward automator, designed to work headless on any server. A Microsoft reward automator, designed to work headless on any x64 server.
Using a discord webhook or SQL to log points everyday. Using a discord webhook or SQL to log points everyday.
Using Selenium and Geckodriver. Using Selenium and Geckodriver.
# Installation instruction
Make sure your contry is [supported by MS Rewards](https://support.microsoft.com/en-us/topic/microsoft-rewards-regions-9795ec47-c0f4-a33e-aede-738903359d63).
Create 5 Microsoft accounts, that the programm will use.
- [linux](#linux)
- [Windows](#windows)
- [MacOS](#macos)
- [Database configuration](#database)
- [Options](#options)
- [Flags](#flags)
## Linux
## If you're using docker (way easier) ### Using docker (Recommended)
to use docker, run Make sure that [docker](https://docs.docker.com/get-docker/) and [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) are installed.
Clone the repository:
``` ```
sudo docker build . git clone https://github.com/piair338/MsRewards
#copy the build id
sudo docker run -ti --name MsRewards [build id]
``` ```
Then, fill the config and start the program everyday with Build the docker container:
``` ```
sudo docker start MsRewards cd MsRewards
sudo docker build -t msrewards .
```
Run the app for the first time to configure it.
```
sudo docker run -ti --name MsRewards msrewards
```
Then to run it everyday, you can use cron and add the line:
```
10 10 * * * sudo docker start MsRewards
``` ```
## Other configuration ### **not** using docker (not recommended)
**This is only a recommandation and shouldn't be used !**
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 :
![B96F2F6D-7257-4F12-BFA7-0BEC3FB72993](https://user-images.githubusercontent.com/74496300/172872979-05396b6b-b682-471a-b71b-41602d816504.jpeg)
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.
You should limit to 6 account per IP, and DON'T USE outlook account, they are banned.
![image](https://user-images.githubusercontent.com/74496300/155960737-061229ca-db8c-4e66-9aef-542d9e709bb2.png)
## If you're **not** using docker
installation recommandation :
``` ```
sudo apt-get install xdg-utils libdbus-glib-1-2 bzip2 wfrench tigervnc-standalone-server -y sudo apt-get install xdg-utils libdbus-glib-1-2 bzip2 wfrench tigervnc-standalone-server xvnc -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 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 tar -xjf firefox-91.9.1esr.tar.bz2
sudo mv firefox /opt/ sudo mv firefox /opt/
sudo ln -s /opt/firefox/firefox /usr/bin/firefox sudo ln -s /opt/firefox/firefox /usr/bin/firefox
curl -sSLO https://github.com/mozilla/geckodriver/releases/download/v0.31.0/geckodriver-v0.31.0-linux64.tar.gz curl -sSLO https://github.com/mozilla/geckodriver/releases/download/v0.31.0/geckodriver-v0.31.0-linux64.tar.gz
tar zxf geckodriver-v0.31.0-linux64.tar.gz tar zxf geckodriver-v0.31.0-linux64.tar.gz
sudo mv geckodriver /usr/bin/ sudo mv geckodriver /usr/bin/
@ -48,3 +52,41 @@ sudo mv geckodriver /usr/bin/
rm geckodriver-v0.31.0-linux64.tar.gz rm geckodriver-v0.31.0-linux64.tar.gz
rm firefox-91.9.1esr.tar.bz2 rm firefox-91.9.1esr.tar.bz2
``` ```
## Windows
Not yet tested, but using docker should work.
## MacOS
I don't have a mac (yet) so i can't test, but again, install docker and follow the linux installation.
# Database
To use the database, I recommend MySql, Create a database with the name `MsRewards` and create a table `daily`, like the one from the image :
![B96F2F6D-7257-4F12-BFA7-0BEC3FB72993](https://user-images.githubusercontent.com/74496300/172872979-05396b6b-b682-471a-b71b-41602d816504.jpeg)
# Options
TODO
# Flags
## Override
Enable you to choose what action to perform on which account. **Linux only**
```
python3 main.py -o
```
## VNC
Enble a vnc to a specific port
```
python3 main.py -v 1234
```
## config
Tell the programm which config to use.
Default to ./user_data/config.cfg
Putting only a number is equivalent to ./user_data/config[number].cfg
```
python3 main.py -c 12
```
## Add points to database
Add points to the database using the credentials provided in the default config file.
argument : file with a list of `account,points`
```
python3 main.py -a file.csv
```

407
V5.py
View File

@ -1,10 +1,11 @@
#!/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 *
from modules.cards import *
import modules.globals as g import modules.globals as g
@ -12,10 +13,6 @@ driver = g.driver
display = g.display display = g.display
# TODO
# handle "panda"'s error: error while logging in preventing some task to be done SadPanda.svg:
# create a webdriver # create a webdriver
def firefox_driver(mobile=False, headless=False): def firefox_driver(mobile=False, headless=False):
PC_USER_AGENT = ( PC_USER_AGENT = (
@ -29,18 +26,16 @@ 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 : if g.fast:
options.set_preference("permissions.default.image", 2) #disable image loading. You shouldn't use it except if really nessecary options.set_preference("permissions.default.image", 2)
if headless: if headless:
options.add_argument("-headless") options.add_argument("-headless")
if mobile : if mobile :
options.set_preference("general.useragent.override", MOBILE_USER_AGENT) options.set_preference("general.useragent.override", MOBILE_USER_AGENT)
driver = webdriver.Firefox(options=options) driver = webdriver.Firefox(options=options)
driver.set_window_size(1070 + hash(g._mail)%20 , 1900 + hash(g._password + "salt")%10) # mobile resolution are crazy high now, right ? driver.set_window_size(1070 + hash(g._mail)%10 , 1900 + hash(g._password + "salt")%20) # mobile resolution are crazy high now, right ?
else : else :
options.set_preference("general.useragent.override", PC_USER_AGENT) options.set_preference("general.useragent.override", PC_USER_AGENT)
driver = webdriver.Firefox(options=options) driver = webdriver.Firefox(options=options)
@ -48,14 +43,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 +76,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
@ -113,10 +108,12 @@ def play_quiz2(override=10) -> None:
if somme + offset == int(correct_answer_value): if somme + offset == int(correct_answer_value):
answer_elem = driver.find_element(By.ID, "rqAnswerOption0") answer_elem = driver.find_element(By.ID, "rqAnswerOption0")
answer_elem.click() answer_elem.click()
if g.log:
progressBar(j, 10, name="quiz 2") progressBar(j, 10, name="quiz 2")
else: else:
answer_elem = driver.find_element(By.ID, "rqAnswerOption1") answer_elem = driver.find_element(By.ID, "rqAnswerOption1")
answer_elem.click() answer_elem.click()
if g.log:
progressBar(j, 10, name="quiz 2") progressBar(j, 10, name="quiz 2")
except exceptions.ElementNotInteractableException as e: except exceptions.ElementNotInteractableException as e:
@ -125,6 +122,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():
@ -147,6 +145,7 @@ def play_quiz8():
for answer_id in correct_answers: for answer_id in correct_answers:
wait_until_visible(By.ID, answer_id, timeout = 20, browser=driver) wait_until_visible(By.ID, answer_id, timeout = 20, browser=driver)
counter += 1 counter += 1
if g.log :
progressBar(counter, 16, name="Quiz 8") progressBar(counter, 16, name="Quiz 8")
try: try:
answer_elem = driver.find_element(By.ID, answer_id) answer_elem = driver.find_element(By.ID, answer_id)
@ -164,6 +163,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 +192,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,117 +209,126 @@ 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)
# finds all task to do, and launch them def all_cards():
def all_cards(): # return to the main page and closes all other tabs driver.get("https://rewards.bing.com")
def reset(part2=False): wait_until_visible(By.CLASS_NAME, "c-card-content", 10, driver)
if len(driver.window_handles) == 1: liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
driver.get("https://www.bing.com/rewardsapp/flyout") custom_sleep(2)
if part2: if "welcometour" in driver.current_url:
row_element = driver.find_elements(By.CSS_SELECTOR, f'[class="i-h rw-sh fp_row"]')[1] welcome_tour_NO(driver)
expanded = row_element.get_attribute("aria-expanded") try :
if expanded != "true": promo()
row_element.click() except Exception as e:
else: printf("no promo card")
if(len(liste) < 10): #most likely an error during loading
if "suspendu" in driver.page_source:
raise Banned()
driver.refresh()
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
if(len(liste) < 10):
log_error("Less than 10 cards. Most likely an error with login.", driver)
return("PAS ASSEZ DE CARTES")
if (len(liste) < 20): # most likely not in france
printf("moins de 20 cartes. Probablement pas en France.")
for i in range(len(liste)):
printf(f"carte {i}")
try :
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
except StaleElementReferenceException :
driver.refresh()
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
printf(f"staled, {len(liste)}")
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
except IndexError:
driver.get("https://rewards.bing.com")
custom_sleep(10)
liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
try :
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
except IndexError :
if i == len(liste) & i > 15 :
checked = False
if checked:
custom_sleep(1.5)
driver.execute_script("arguments[0].scrollIntoView();", liste[i])
custom_sleep(1.5)
liste[i].click()
if len(driver.window_handles) > 1 :
driver.switch_to.window(driver.window_handles[1]) driver.switch_to.window(driver.window_handles[1])
printf(f"fermeture : {driver.current_url}") try_play(driver.title)
driver.close() close_tab(driver.window_handles[1])
driver.switch_to.window(driver.window_handles[0]) try :
if driver.current_url != "https://www.bing.com/rewardsapp/flyout": driver.refresh()
driver.get("https://www.bing.com/rewardsapp/flyout") liste = driver.find_elements(By.CLASS_NAME, "c-card-content")
reset(part2) if ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML")) :
printf(f"carte {i} not okay. Retrying.")
def daily_cards(): # cartes de la premiere partie (renouvelée chaque jour). try :
liste[i].click()
except :
log_error("problème inconnu ? sauf si c'est un element obscure...", driver)
driver.get("https://rewards.bing.com")
checked = ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML"))
driver.switch_to.window(driver.window_handles[1])
try_play(driver.title)
close_tab(driver.window_handles[1])
if ("mee-icon-AddMedium" in liste[i].get_attribute("innerHTML")):
driver.execute_script("arguments[0].scrollIntoView();", liste[i])
log_error(f"Card {i} Can't be completed. Why MS ?", driver)
liste[i].click()
driver.switch_to.window(driver.window_handles[1])
log_error(f"Cart completion - log - 2", driver)
custom_sleep(10)
log_error(f"Cart completion - log - 3 - after 10 sec", driver)
try: try:
# make sure that the daily area is expanded try_play(driver.title) # go back to the main page
row_element = driver.find_elements(By.CSS_SELECTOR, f'[class="i-h rw-sh fp_row"]')[0] except :
expanded = row_element.get_attribute("aria-expanded") driver.get("https://rewards.bing.com")
if expanded != "true": except :
row_element.click() pass
for i in range(3):
custom_sleep(uniform(3, 5))
try:
titre = "Placeholder"
elm = driver.find_elements(By.CLASS_NAME, 'promo_cont')
elm[i].click()
sleep(1)
titre = driver.title
try_play(titre)
sleep(1)
reset()
printf(f"DailyCard {titre} ok")
except Exception as e:
log_error(f"all_cards card `{titre}` error ({format_error(e)})")
break
try : # devrait renvoyer vrai si la carte i est faite ou pas, a l'aide su symbole en haut a droite de la carte
elm = driver.find_elements(By.CLASS_NAME, 'promo_cont')[i]
if not ("correctCircle" in elm.get_attribute("innerHTML")):
printf(f"missed card {i}")
elm.click()
try_play("recovery")
sleep(3)
reset()
else : else :
printf(f'carte OK')
except Exception as e :
printf(format_error(e) + " probablement ok - check card")
# if it fail, it's probably okay -> when all three card are done, the pannel fold
except Exception as e:
log_error(e)
def weekly_cards():
# make sure that the weekly area is expanded
row_element = driver.find_elements(By.CSS_SELECTOR, f'[class="i-h rw-sh fp_row"]')[1]
expanded = row_element.get_attribute("aria-expanded")
if expanded != "true":
row_element.click()
for i in range(20): # Should raise an error whene there is no card left
elm = driver.find_elements(By.CLASS_NAME, 'promo_cont')
try : try :
elm[0].click() welcome_tour(liste[i], driver)
printf(f"Carte {i+1} cliquée.") except Exception as e:
except Exception as e : printf("no new windows" + format_error(e))
printf(f"Plus aucune carte.") driver.get("https://rewards.bing.com")
custom_sleep(3)
def promo():
for i in range(5):
elm = driver.find_element(By.ID, "promo-item")
wait_until_visible(By.ID, "promo-item", 5, driver)
if not elm:
break break
driver.switch_to.window(driver.window_handles[len(driver.window_handles) - 1]) if i > 3 :
sleep(1) log_error("plus de 3 promo cards, probablement une pa skipable", driver)
titre = driver.title.split(" - Recherche")[0]
printf(f"Carte `{titre}` en cours.")
try_play(titre)
reset(True)
sleep(1)
def top_cards():
for _ in range(2):
try : try :
driver.find_elements(By.CSS_SELECTOR, '[class="banner_cont single wpoints"]')[0].click() elm.click()
reset()
except Exception as e: except Exception as e:
printf(format_error(e)) #log_error(e, driver)
break driver.execute_script("arguments[0].click();", elm)
#log_error(e, driver)
printf(f"that should't be there (promo), but the workarround seemed to work {e}")
custom_sleep(3)
if len(driver.window_handles) > 1 :
driver.switch_to.window(driver.window_handles[len(driver.window_handles)-1])
try_play(driver.title)
close_tab(driver.window_handles[1])
else :
try : try :
top_cards() spotify(driver)
except Exception as e: except :
log_error(e) printf("no new windows", driver)
driver.get("https://rewards.bing.com")
try: driver.refresh()
daily_cards() custom_sleep(3)
except Exception as e:
log_error(e)
try :
weekly_cards()
except Exception as e:
log_error(e)
# Find out which type of action to do # Find out which type of action to do
def try_play(nom="inconnu"): def try_play(nom="inconnu"):
# rgpd_popup(driver)
def play(number): def play(number):
if number == 8 or number == 9: if number == 8 or number == 9:
try: try:
@ -346,13 +356,21 @@ def try_play(nom="inconnu"):
except Exception as e: except Exception as e:
printf(f"fail of PlayQuiz 2. Aborted {e}") printf(f"fail of PlayQuiz 2. Aborted {e}")
else: else:
log_error("There is an error. rqAnswerOption present in page but no action to do. skipping.") printf("There is an error. rqAnswerOption present in page but no action to do. skipping.")
if "pas connecté à Microsoft Rewards" in driver.page_source:
driver.find_element(By.CSS_SELECTOR, '[onclick="setsrchusr()"]').click()
custom_sleep(5)
printf("not connected, fixed")
try: try:
if wait_until_visible(By.ID, "rqStartQuiz", 5, driver):
custom_sleep(3)
driver.find_element(By.ID, "rqStartQuiz").click() # start the quiz driver.find_element(By.ID, "rqStartQuiz").click() # start the quiz
answer_number = driver.page_source.count("rqAnswerOption") answer_number = driver.page_source.count("rqAnswerOption")
play(answer_number) play(answer_number)
else :
raise(NameError("going to next part"))
except Exception as e: # if there is no start button, an error is thrown except Exception as e: # if there is no start button, an error is thrown
if "bt_PollRadio" in driver.page_source: if "bt_PollRadio" in driver.page_source:
try: try:
@ -411,7 +429,15 @@ def cookie_login(ldriver):
except FileNotFoundError : except FileNotFoundError :
printf("No cookies file Found.") printf("No cookies file Found.")
return(False) return(False)
except Exception as e:
log_error(f"Error performing cookies login. Trying with password instead. \n{str(e)}", driver)
return(False)
try :
ldriver.refresh() ldriver.refresh()
except Exception as e:
printf(format_error(e))
printf("FIX YOUR SITE MS.......")
return(True) return(True)
@ -420,6 +446,12 @@ def login_part_2(ldriver, cookies = False):
custom_sleep(5) custom_sleep(5)
if ('Abuse' in ldriver.current_url) : if ('Abuse' in ldriver.current_url) :
raise Banned() raise Banned()
if ('identity' in ldriver.current_url) :
raise Identity()
if ('notice' in ldriver.current_url) :
ldriver.find_element(By.ID, "id__0").click()
if ("proof" in ldriver.current_url):
ldriver.find_element(BY.ID, "iLooksGood")
if cookies: if cookies:
save_cookies(ldriver) save_cookies(ldriver)
for id in ["KmsiCheckboxField", "id__0", "iLooksGood", "idSIButton9", "iCancel"]: for id in ["KmsiCheckboxField", "id__0", "iLooksGood", "idSIButton9", "iCancel"]:
@ -431,30 +463,10 @@ def login_part_2(ldriver, cookies = False):
except Exception as e: except Exception as e:
pass pass
wait_until_visible(By.CSS_SELECTOR, '[data-bi-id="sh-sharedshell-home"]', 20, ldriver) wait_until_visible(By.CSS_SELECTOR, '[data-bi-id="sh-sharedshell-home"]', 20, ldriver)
ldriver.get("https://www.bing.com") ldriver.get("https://www.bing.com/")
rgpd_popup(ldriver) rgpd_popup(ldriver)
ldriver.refresh() ldriver.refresh()
rgpd_popup(ldriver) rgpd_popup(ldriver)
ldriver.get("https://account.microsoft.com/")
if wait_until_visible(By.CSS_SELECTOR, '[data-bi-id="sh-sharedshell-home"]', 30, ldriver) :
return(True) #the account logging was successful
else :
log_error("Error during login. Trying to refresh")
ldriver.refresh()
return(wait_until_visible(By.CSS_SELECTOR, '[data-bi-id="sh-sharedshell-home"]', 30, ldriver))
#going to MsRewards
def go_to_msrewards(ldriver):
for i in ["[h='ID=RewardsFlyout,2.1']", f'[title="Rejoindre maintenant"]', f'[title="Rejoindre"]', f'[title="Join now"]'] :
ldriver.get("https://www.bing.com/rewardsapp/flyout")
if ('>Tableau de bord' in ldriver.page_source) :
printf('On MsRewards flyout')
return(True)
try:
ldriver.find_element(By.CSS_SELECTOR, i).click() # depend of the language of the page
except:
printf(f"element {i} not found")
# login() tries to login to your Microsoft account. # login() tries to login to your Microsoft account.
@ -465,9 +477,11 @@ def login(ldriver):
if not success_cookies: if not success_cookies:
pwd_login(ldriver) pwd_login(ldriver)
login_part_2(ldriver, not success_cookies) login_part_2(ldriver, not success_cookies)
go_to_msrewards(ldriver) ldriver.get("https://rewards.bing.com/")
except Banned: except Banned:
raise Banned() raise Banned()
except Identity:
raise Banned()
except Exception as e: except Exception as e:
log_error(e) log_error(e)
ldriver.quit() ldriver.quit()
@ -577,8 +591,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()
) )
@ -587,42 +601,27 @@ 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) try :
add_to_database(account_name, points, g.sql_host, g.sql_usr, g.sql_pwd, g.sql_database)
except Exception as e:
if g.database_error_override:
printf("database error.")
else :
log_error(e)
def fidelity(): def fidelity():
def sub_fidelity():
try: try:
while 1: #close all tabs
try:
close_tab(1)
except:
break
try :
fidelity_link_page = get(FidelityLink) #get the url of fidelity page
except Exception as e :
printf(e)
fidelity_link_page = False
if fidelity_link_page :
fidelity_link = fidelity_link_page.content.decode("UTF-8")
if (fidelity_link.split(":")[0] == "https") or (fidelity_link.split(":")[0] == "http") :
driver.get(fidelity_link)
wait_until_visible(By.CSS_SELECTOR, 'div[class="pull-left spacer-48-bottom punchcard-row"]', browser=driver) wait_until_visible(By.CSS_SELECTOR, 'div[class="pull-left spacer-48-bottom punchcard-row"]', browser=driver)
try :
choix = driver.find_element(By.CSS_SELECTOR, 'div[class="pull-left spacer-48-bottom punchcard-row"]') # pull-left spacer-48-bottom punchcard-row? USELESS ?
except : # tentative de fix
driver.execute_script("location.reload(true);")
wait_until_visible(By.CSS_SELECTOR, 'div[class="pull-left spacer-48-bottom punchcard-row"]', browser=driver)
choix = driver.find_element(By.CSS_SELECTOR, 'div[class="pull-left spacer-48-bottom punchcard-row"]')
answer_number = search("([0-9]) of ([0-9]) completed", driver.page_source) answer_number = search("([0-9]) of ([0-9]) completed", driver.page_source)
if answer_number is None :
answer_number = search("([0-9])&nbsp;défi\(s\) terminé\(s\) sur ([0-9])", driver.page_source)
if answer_number is None: if answer_number is None:
answer_number = search("([0-9]) de ([0-9]) finalisé", driver.page_source) answer_number = search("([0-9]) de ([0-9]) finalisé", driver.page_source)
if answer_number is None : if answer_number is None :
answer_number = search("([0-9]) licence\(s\) sur ([0-9]) disponible\(s\)", driver.page_source) answer_number = search("([0-9]) licence\(s\) sur ([0-9]) disponible\(s\)", driver.page_source)
if answer_number is None :
answer_number = search("([0-9])&nbsp;défi\(s\) terminé\(s\) sur ([0-9])", driver.page_source)
if answer_number is None : if answer_number is None :
answer_number = [0,0,0] answer_number = [0,0,0]
for _ in range(int(answer_number[2]) - int(answer_number[1])): for _ in range(int(answer_number[2]) - int(answer_number[1])):
@ -641,20 +640,42 @@ def fidelity():
log_error(f"fidélité - double erreur - e1 : {format_error(e1)} - e2 {format_error(e2)}") log_error(f"fidélité - double erreur - e1 : {format_error(e1)} - e2 {format_error(e2)}")
break break
custom_sleep(uniform(3, 5)) custom_sleep(uniform(3, 5))
driver.switch_to.window(driver.window_handles[1]) driver.switch_to.window(driver.window_handles[2])
try_play(driver.title) try_play(driver.title)
driver.get(fidelity_link) # USELESS ?
custom_sleep(uniform(3, 5)) custom_sleep(uniform(3, 5))
try: try:
close_tab(driver.window_handles[1]) close_tab(driver.window_handles[2], 1)
except Exception as e: except Exception as e:
printf(e) printf(e)
printf("fidelity - done") printf("fidelity - done")
else :
printf("invalid fidelity link.")
except Exception as e: except Exception as e:
log_error(e) log_error(e)
if driver.current_url != "https://rewards.bing.com":
driver.get("https://rewards.bing.com")
try :
pause = driver.find_element(By.CSS_SELECTOR, f'[class="c-action-toggle c-glyph f-toggle glyph-pause"]') # mettre le truc en pause
pause.click()
except Exception as e:
printf(f"erreur : probablement pas de cartes {e}")
return("no cards")
cartes = driver.find_elements(By.CSS_SELECTOR, f'[ng-repeat="item in $ctrl.transcludedItems"]')
nb_cartes = len(cartes)
checked_list_all = driver.find_elements(By.CSS_SELECTOR, f'[ng-if="$ctrl.complete"]')
for i in range(nb_cartes):
cartes[i].click() # affiche la bonne carte
checked_txt = checked_list_all[i].get_attribute("innerHTML")
ok = checked_txt.count("StatusCircleOuter checkmark")
total = checked_txt.count("StatusCircleOuter")
if (ok != total) :
elm = driver.find_elements(By.CLASS_NAME, 'clickable-link')[i]
if not "moviesandtv" in elm.get_attribute("innerHTML"): # not the film card
elm.click()
driver.switch_to.window(driver.window_handles[len(driver.window_handles)-1])
sub_fidelity()
close_tab(driver.window_handles[1])
custom_sleep(1)
cartes = driver.find_elements(By.CSS_SELECTOR, f'[ng-repeat="item in $ctrl.transcludedItems"]')
checked_list_all = driver.find_elements(By.CSS_SELECTOR, f'[ng-if="$ctrl.complete"]')
def mobile_alert_popup(): def mobile_alert_popup():
try: try:
@ -701,11 +722,17 @@ def daily_routine(custom = False):
if not custom: # custom already login if not custom: # custom already login
login(driver) login(driver)
except Banned : except Banned :
log_error("THIS ACCOUNT IS BANNED. FIX THIS ISSUE WITH -U") log_error("This account is locked. Fix that. (-U ?)", driver)
return()
except Identity :
log_error("This account has an issue. Fix that.", driver)
return() return()
try: try:
all_cards() all_cards()
except Banned:
log_error("banned", driver)
return("BANNED")
except Exception as e: except Exception as e:
log_error(e) log_error(e)
@ -724,7 +751,6 @@ def daily_routine(custom = False):
except Exception as e: except Exception as e:
log_error(e) log_error(e)
try: try:
log_points(g._mail) log_points(g._mail)
except Exception as e: except Exception as e:
@ -732,20 +758,20 @@ def daily_routine(custom = False):
def dev(): def dev():
input("paused") pass
def CustomStart(Credentials):
global START_TIME def CustomStart():
if not LINUX_HOST : if not g.islinux :
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]
@ -755,7 +781,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)
@ -790,34 +815,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:
@ -838,6 +862,7 @@ else:
driver.quit() driver.quit()
display.stop() display.stop()
except Exception as e: except Exception as e:
log_error(f"Error not catched. Skipping this account. " + format_error(e), driver)
printf(f"Error not catched. Skipping this account. {e}") printf(f"Error not catched. Skipping this account. {e}")
driver.quit() driver.quit()

27
main.py
View File

@ -34,7 +34,7 @@ def confirm(texte, default = False):
return False return False
return default return default
lang = "fr" lang = "en"
text = {"fr" : { text = {"fr" : {
"compte" : "entrer l'adresse mail du compte ", "compte" : "entrer l'adresse mail du compte ",
@ -55,6 +55,24 @@ text = {"fr" : {
"proxye" : "voulez vous utiliser un proxy ", "proxye" : "voulez vous utiliser un proxy ",
"proxyl" : "entrez le lien du proxy ", "proxyl" : "entrez le lien du proxy ",
"proxyp" : "entrez le port du proxy " "proxyp" : "entrez le port du proxy "
},
"en" : {
"compte" : "enter email of an account",
"mdp" : "enter password of this account ",
"next" : "Add another account ? ",
"finc" : "Adding accounts ",
"ajout" : "Accounts added ",
"discorde" : "Do you want to use discord ? (Highly recommended as it's untested without)",
"w1" : "Enter Webhook link for sending points everyday",
"w2" : "Enter Webhook link for errors ",
"msqle" : "Do you want to use a database ? ",
"msqll" : "database link ",
"msqlu" : "database username ",
"msqlp" : "database password ",
"msqlt" : "database name (should be MsRewards) ",
"proxye" : "Do you want to use a proxy ",
"proxyl" : "Proxy address ",
"proxyp" : "Proxy port "
} }
} }
@ -92,7 +110,7 @@ def edit_config_txt(ligne, contenu):
txt = f.readlines() txt = f.readlines()
f.close() f.close()
if txt.count(txt) >1: if txt.count(txt) >1:
raise NameError("il y a plus d'une occurence, echec de la modification") raise NameError("Fail")
for i in range(len(txt)) : for i in range(len(txt)) :
name = txt[i].split(" = ")[0] name = txt[i].split(" = ")[0]
@ -106,16 +124,11 @@ def edit_config_txt(ligne, contenu):
def setup_settings(): def setup_settings():
general()
discord() discord()
proxy() proxy()
sql() sql()
def general():
if confirm(t["fidelity"]):
lien = input(t["lien"])
edit_config_txt('FidelityLink',lien)
def discord(): def discord():

View File

@ -1,69 +0,0 @@
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()

34
modules/cards.py Normal file
View File

@ -0,0 +1,34 @@
from modules.imports import *
def welcome_tour(elm, driver):
try :
driver.find_element(By.CSS_SELECTOR, '[class="welcome-tour-next-button c-call-to-action c-glyph"]').click()
except :
pass
driver.find_element(By.CSS_SELECTOR, '[class="quiz-link gray-button c-call-to-action c-glyph f-lightweight"]').click()
sleep(5)
driver.find_element(By.CSS_SELECTOR, '[class="c-glyph glyph-cancel"]').click()
elm.click()
driver.find_element(By.CSS_SELECTOR, '[class="quiz-link gray-button c-call-to-action c-glyph f-lightweight"]').click()
sleep(5)
driver.find_element(By.CSS_SELECTOR, '[class="c-glyph glyph-cancel"]').click()
elm.click()
driver.find_element(By.CSS_SELECTOR, '[class="quiz-link gray-button c-call-to-action c-glyph f-lightweight"]').click()
sleep(5)
driver.find_element(By.CSS_SELECTOR, '[class="c-glyph glyph-cancel"]').click()
def welcome_tour_NO(driver):
try :
driver.find_element(By.CSS_SELECTOR, '[class="welcome-tour-next-button c-call-to-action c-glyph"]').click()
except :
pass
driver.find_element(By.CSS_SELECTOR, '[class="c-glyph glyph-cancel"]').click()
sleep(5)
def spotify(driver):
sleep(5)
driver.find_element(By.CSS_SELECTOR, '[data-bi-id="spotify-premium gratuit"]').click()
sleep(5)
close_tab(driver.window_handles[1])

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,19 +39,12 @@ 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",
"--config", "--config",
help="Choose a specific config file", help="Choose a specific config file",
type=argparse.FileType('r') default=""
) )
parser.add_argument( parser.add_argument(
@ -87,91 +69,111 @@ parser.add_argument(
dest="update_version", dest="update_version",
default="None" default="None"
) )
parser.add_argument(
"--dev",
help="dev option",
dest="dev",
action="store_true"
)
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 g.dev = args.dev
if CUSTOM_START :
LOG = True if g.custom_start :
VNC_ENABLED = args.vnc != "None" g.log = True
VNC_PORT = args.vnc
POINTS_FILE = args.points_file g.vnc_enabled = args.vnc != "None"
UPDATE_VERSION = args.update_version g.vnc_port = args.vnc
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
config_path = f"{path.abspath(path.dirname(path.dirname( __file__ )))}/user_data/config.cfg"
if args.config :
config_path = path.abspath(args.config.name)
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read(config_path)
if args.config :
try :
config_path =f"{path.abspath(path.dirname(path.dirname( __file__ )))}/user_data/config{args.config}.cfg"
config.read(config_path)
g.mot_path = config["PATH"]["motpath"]
except :
config_path = path.abspath(args.config)
config.read(config_path)
else :
config_path = f"{path.abspath(path.dirname(path.dirname( __file__ )))}/user_data/config.cfg"
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") try :
lines = g.readlines() g.database_error_override = config["OTHER"]["database_override"] == "True"
except :
pass
try :
g.fast = config["OTHER"]["fast"] == "True"
except :
pass
h = open(g.mot_path, "r", encoding="utf-8")
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

@ -1,22 +1,19 @@
from modules.imports import * from modules.imports import *
from modules.config import * from modules.config 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: str, port: str) -> None:
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,
"proxyType": "MANUAL", "proxyType": "MANUAL",
} }
#Deal with rgpd popup as well as some random popup like 'are you satisfied' one
#Deal with RGPD popup as well as some random popup like 'are you satisfied' one
def rgpd_popup(driver) -> None: def rgpd_popup(driver) -> None:
for i in ["bnp_btn_accept", "bnp_hfly_cta2", "bnp_hfly_close"] : for i in ["bnp_btn_accept", "bnp_hfly_cta2", "bnp_hfly_close"] :
try: try:
@ -24,12 +21,26 @@ def rgpd_popup(driver) -> None:
except: except:
pass pass
# save webdriver cookies # save webdriver cookies
def save_cookies(driver): def save_cookies(driver) -> None:
if g.dev:
f = open(f"{'/'.join(__file__.split('/')[:-2])}/user_data/cookies/{g._mail}_unsafe.pkl", "w")
for i in driver.get_cookies():
f.write(str(i) + "\n")
f.close()
else :
pickle.dump(driver.get_cookies(), open(f"{'/'.join(__file__.split('/')[:-2])}/user_data/cookies/{g._mail}.pkl", "wb")) pickle.dump(driver.get_cookies(), open(f"{'/'.join(__file__.split('/')[:-2])}/user_data/cookies/{g._mail}.pkl", "wb"))
# load cookies previously saved to the driver # load cookies previously saved to the driver
def load_cookies(driver): def load_cookies(driver) -> None:
if g.dev:
f = open(f"{'/'.join(__file__.split('/')[:-2])}/user_data/cookies/{g._mail}_unsafe.pkl", "r")
lines = f.readlines()
f.close()
cookies = [literal_eval(x) for x in lines]
else :
cookies = pickle.load(open(f"{'/'.join(__file__.split('/')[:-2])}/user_data/cookies/{g._mail}.pkl", "rb")) cookies = pickle.load(open(f"{'/'.join(__file__.split('/')[:-2])}/user_data/cookies/{g._mail}.pkl", "rb"))
for cookie in cookies: for cookie in cookies:
driver.add_cookie(cookie) driver.add_cookie(cookie)
@ -38,12 +49,9 @@ def load_cookies(driver):
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. 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 keys can be an string, but also selenium keys
""" """
def send_keys_wait(element, keys): def send_keys_wait(element, keys: str) -> None:
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))
@ -54,6 +62,6 @@ def wait_until_visible(search_by: str, identifier: str, timeout = 20, browser =
WebDriverWait(browser, timeout).until(EC.visibility_of_element_located((search_by,identifier)), "element not found") WebDriverWait(browser, timeout).until(EC.visibility_of_element_located((search_by,identifier)), "element not found")
return(True) return(True)
except TimeoutException as e: except TimeoutException as e:
print(f"element not found after {timeout}s") printf(f"element {identifier} not found after {timeout}s")
return(False) return(False)

View File

@ -3,3 +3,6 @@ class Banned(Exception):
class NotBanned(Exception): class NotBanned(Exception):
pass pass
class Identity(Exception):
pass

View File

@ -3,3 +3,36 @@ _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 = "None"
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"
dev = False
norvege = False
database_error_override = False
fast = False

View File

@ -1,24 +1,33 @@
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
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
from ast import literal_eval
try:
import enquiries
except:
system("") # enable colors in windows cmd

View File

@ -1,10 +1,10 @@
from modules.imports import * from modules.imports import *
from modules.config import * from modules.config import *
from modules.db 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 +32,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)):
@ -67,20 +65,18 @@ def progressBar(current, total=30, barLength=20, name="Progress"):
def save_points_from_file(file): def save_points_from_file(file):
with open(file) as f: with open(file) as f:
reader = csv.reader(f) read = reader(f)
points_list = list(reader) points_list = list(read)
for item in points_list: for item in points_list:
compte, points = item[0], item[1] compte, points = item[0], item[1]
add_to_database(compte, points, sql_host,sql_usr,sql_pwd,sql_database, save_if_fail=False) add_to_database(compte, points, g.sql_host,g.sql_usr,g.sql_pwd,g.sql_database, save_if_fail=False)
with open(file, "w") as f: with open(file, "w") as f:
f.write("") f.write("")
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])

View File

@ -5,7 +5,6 @@ logpath = /your/path/to/loginandpass.csv
[SETTINGS] [SETTINGS]
FidelityLink = Null
embeds = False embeds = False
Headless = True Headless = True
@ -31,5 +30,8 @@ usr = root
pwd = password pwd = password
[OTHER] [OTHER]
avatar = https://cdn.discordapp.com/icons/793934298977009674/d8055bccef6eca4855c349e808d0d788.webp avatar = https://cdn.discordapp.com/icons/793934298977009674/d8055bccef6eca4855c349e808d0d788.webp
ipv6 = False ipv6 = False
database_override = False
fast = False

View File

@ -1 +1 @@
v5.7.1 v5.10.11