🤬
  • Worked on bot, API, and util system

  • Loading...
  • George committed 11 months ago
    1c50d9a3
    1 parent 038bb75e
  • ■ ■ ■ ■ ■ ■
    .gitignore
    skipped 158 lines
    159 159  # option (not recommended) you can uncomment the following to ignore the entire idea folder.
    160 160  #.idea/
    161 161   
     162 +.idea/
     163 +.env
     164 +*.iml
  • ■ ■ ■ ■ ■
    __main__.py
     1 +import dotenv
     2 + 
     3 +dotenv.load_dotenv()
     4 + 
     5 +import checker
  • ■ ■ ■ ■ ■ ■
    checker/__init__.py
     1 +import sys
     2 +import time
     3 + 
     4 +from checker.api import checker_api
     5 +from checker.bot import checker_bot
     6 + 
     7 +from concurrent.futures import ThreadPoolExecutor
     8 + 
     9 +MIN_PYTHON_VERSION = (3, 8, 0)
     10 +API_VERSION = (1, 0, 0)
     11 +BOT_VERSION = (1, 0, 0)
     12 + 
     13 +executor = ThreadPoolExecutor(max_workers=2)
     14 + 
     15 +if sys.version_info < MIN_PYTHON_VERSION:
     16 + print('Your python version is too old! Please use Python 3.8.0 or above!')
     17 + sys.exit(-1)
     18 + 
     19 +def init_api():
     20 + print(f'Initializing MSA exploit checker API, version {API_VERSION[0]}.{API_VERSION[1]}.{API_VERSION[2]}')
     21 + 
     22 + app.init_app()
     23 + 
     24 +def init_bot():
     25 + print(f'Initializing MSA checker Discord bot, version {BOT_VERSION[0]}.{BOT_VERSION[1]}.{BOT_VERSION[2]}')
     26 + 
     27 + checker_bot.init_bot()
     28 + 
     29 +executor.submit(init_bot)
     30 +executor.submit(init_api)
     31 + 
     32 +while True:
     33 + time.sleep(10000000)
  • ■ ■ ■ ■ ■ ■
    checker/api/checker_api.py
     1 +import os
     2 + 
     3 +from flask import Flask
     4 +from flask import request
     5 +from flask import jsonify
     6 + 
     7 +from flask_cors import CORS
     8 + 
     9 +from checker.util import email_valid_checker
     10 +from checker.util import exploit_checker
     11 + 
     12 +app = Flask(__name__)
     13 +CORS(app)
     14 + 
     15 +@app.route('/exploit-check')
     16 +def check_exploit():
     17 + query = request.args
     18 + 
     19 + if 'email' not in query or not email_valid_checker.check_email_valid(query['email']):
     20 + return jsonify({
     21 + 'status': 'failed',
     22 + 'message': 'Invalid email address provided!'
     23 + })
     24 + 
     25 + return jsonify({
     26 + 'status': 'success',
     27 + 'result': exploit_checker.check_exploit(query['email'])
     28 + })
     29 + 
     30 + 
     31 +def init_app():
     32 + app.run(os.getenv('HOST'), os.getenv('PORT'))
     33 + 
  • ■ ■ ■ ■ ■ ■
    checker/bot/checker_bot.py
     1 +import os
     2 +import discord
     3 + 
     4 +from discord.ext import commands
     5 + 
     6 +from checker.util import email_valid_checker
     7 +from checker.util import exploit_checker
     8 + 
     9 +intents = discord.Intents.default()
     10 +intents.message_content = True
     11 + 
     12 +client = commands.Bot(command_prefix='.', intents=intents)
     13 + 
     14 +@client.event
     15 +async def on_ready():
     16 + print('Successfully logged into ' + client.user.name + '!')
     17 + print(f'Loaded {len(await client.tree.sync())} commands!')
     18 + 
     19 + await client.change_presence(activity=discord.Game(name='Checking for exploits on MSA accounts'))
     20 + 
     21 +@client.tree.command(name = 'check', description='Checks if the MSA exploit is active on an account')
     22 +async def handle_check(interaction: discord.Interaction, email:str):
     23 + if not email_valid_checker.check_email_valid(email):
     24 + await interaction.response.send_message('The provided email address isn\'t valid!')
     25 + await interaction.response.send_message(f'The exploit was {"" if exploit_checker.check_exploit(email) else "not"} found on that account!')
     26 + 
     27 +def init_bot():
     28 + client.run(os.getenv('BOT_TOKEN'))
     29 + 
  • ■ ■ ■ ■ ■ ■
    checker/util/email_valid_checker.py
     1 +import re
     2 + 
     3 +EMAIL_VALIDATION_REGEX = r'^\S+@\S+\.\S+$'
     4 + 
     5 +def check_email_valid(email:str):
     6 + return len(re.findall(EMAIL_VALIDATION_REGEX, email)) is not 0
  • ■ ■ ■ ■ ■ ■
    checker/util/exploit_checker.py
     1 +import json
     2 +import httpx
     3 + 
     4 +from bs4 import BeautifulSoup
     5 +from requests_html import HTMLSession
     6 + 
     7 +def check_exploit(email: str) -> bool:
     8 + session = HTMLSession()
     9 + 
     10 + response = session.get('https://login.live.com/login.srf')
     11 + response.html.render()
     12 + 
     13 + html = response.html.html
     14 + soup = BeautifulSoup(html, 'html.parser')
     15 + 
     16 + credential_type_url = None
     17 + ua_id = None
     18 + 
     19 + for script in soup.find_all('script'):
     20 + if 'GetCredentialType' in script.text:
     21 + script_text = script.text
     22 + 
     23 + credential_type_url = script_text.split('b6:\'')[1].split('\'')[0]
     24 + ua_id = script_text.split('b0:\'https://account.live.com/query.aspx?uaid=')[1].split('&')[0]
     25 + 
     26 + if credential_type_url is None or ua_id is None:
     27 + raise RuntimeError('Credential type URL or UA id not found!')
     28 + 
     29 + flow_token = soup.find('input', {'id': 'i0327'}).get('value')
     30 + 
     31 + client = httpx.Client()
     32 + 
     33 + for cookie in session.cookies:
     34 + client.cookies.set(cookie.name, cookie.value)
     35 + 
     36 + response = client.post(credential_type_url, headers={
     37 + 'Client-Request-Id': ua_id,
     38 + 'Content-Type': 'application/json; charset=UTF-8',
     39 + 'Origin': 'https://login.live.com',
     40 + 'Referer': 'https://login.live.com/login.srf?',
     41 + 'Host': 'login.live.com'
     42 + }, data={
     43 + 'checkPhones': False,
     44 + 'federationFlags': 3,
     45 + 'flowToken': flow_token,
     46 + 'forceotclogin': False,
     47 + 'isCookieBannerShown': False,
     48 + 'isExternalFederationDisallowed': False,
     49 + 'isFidoSupported': True,
     50 + 'isOtherIdpSupported': True,
     51 + 'isRemoteConnectSupported': False,
     52 + 'isRemoteNGCSupported': True,
     53 + 'isSignup': False,
     54 + 'otclogindisallowed': False,
     55 + 'uaid': ua_id,
     56 + 'username': email
     57 + })
     58 + 
     59 + print(response.json())
     60 + 
     61 + # print(credential_type_url)
     62 + 
     63 + return False
     64 + 
     65 +check_exploit('[email protected]')
     66 +# asyncio.run(check_exploit('[email protected]'))
  • ■ ■ ■ ■ ■ ■
    requirements.txt
     1 +requests-html
     2 +httpx~=0.23.1
     3 +trio
     4 +asyncio
     5 +python-dotenv
     6 +flask~=2.2.3
     7 +pytest
     8 +bs4~=0.0.1
     9 +discord.py==2.2.3
  • ■ ■ ■ ■ ■ ■
    tests/exploit_test.py
     1 +from checker.util import exploit_checker
     2 + 
     3 +def test_exploit_active() -> None:
     4 + assert exploit_checker.check_exploit('[email protected]')
     5 + 
     6 +def test_exploit_inactive() -> None:
     7 + assert not exploit_checker.check_exploit('[email protected]')
     8 + 
Please wait...
Page is in error, reload to recover