From 3a3c8f11eae5a9d90872a4efe0c6d2e080274013 Mon Sep 17 00:00:00 2001 From: LIL-JABA <82034934+LIL-JABA@users.noreply.github.com> Date: Fri, 6 Sep 2024 17:23:45 +0300 Subject: [PATCH] moved to floxay riot client --- src/checker.py | 2 +- src/codeparts/auth.py | 77 ++++++++++++++++-------------- src/codeparts/authclient.py | 94 ++++++++++++++----------------------- src/system/ver.txt | 2 +- 4 files changed, 80 insertions(+), 95 deletions(-) diff --git a/src/checker.py b/src/checker.py index 16bb9d1..1ae9512 100644 --- a/src/checker.py +++ b/src/checker.py @@ -34,7 +34,7 @@ async def main(self) -> None: while True: if self.isDebug: input("hit enter") - logpass = "valcheckerdebug:Fuckyou1337!" + logpass = "valcheckerdebug:hentai123xd??" else: logpass = input('account (login:password) or "E" to exit >>> ') if logpass == "E": diff --git a/src/codeparts/auth.py b/src/codeparts/auth.py index b5f215f..9e1c3ac 100644 --- a/src/codeparts/auth.py +++ b/src/codeparts/auth.py @@ -4,13 +4,16 @@ import traceback from typing import Any from datetime import datetime, timedelta +from secrets import token_urlsafe, token_hex import base64 import json +import aiohttp import sys import asyncio from requests.adapters import HTTPAdapter import httpx +from .authclient import RiotAuth from . import systems from .data import Constants @@ -45,72 +48,76 @@ async def auth(self, logpass: str = None, username: str = None, password: str = account = Account() try: account.logpass = logpass - sslcontext = httpx.create_ssl_context() - sslcontext.set_ciphers(Constants.CIPHERS) - sslcontext.set_ecdh_curve(Constants.ECDH_CURVE) - client = httpx.Client(verify=sslcontext, proxy=proxy["http"] if proxy is not None else None) - if username is None: - username = logpass.split(':')[0].strip() - password = logpass.split(':')[1].strip() + _authclient = RiotAuth() + #sslcontext = httpx.create_ssl_context() + #sslcontext.set_ciphers(Constants.CIPHERS) + #sslcontext.set_ecdh_curve(Constants.ECDH_CURVE) + client = httpx.Client(proxy=proxy["http"] if proxy is not None else None) + _logpass = logpass.split(":") + username = _logpass[0] + password = _logpass[1] try: # R1 + conn = aiohttp.TCPConnector(ssl=_authclient._auth_ssl_ctx) + authsession = aiohttp.ClientSession(connector=conn) + headers = { - "User-Agent": ( - "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X)" - " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.1502.79 Mobile" - " Safari/537.36" - ), - "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", - "Accept-Language": "en-US,en;q=0.9", - "Accept-Encoding": "gzip, deflate" - } + "Accept-Encoding": "deflate, gzip, zstd", + # "user-agent": RiotAuth.RIOT_CLIENT_USER_AGENT % "rso-auth", + "user-agent": RiotAuth.RIOT_CLIENT_USER_AGENT, + "Cache-Control": "no-cache", + "Accept": "application/json", + } + body = { "acr_values": "", "claims": "", "client_id": "riot-client", "code_challenge": "", "code_challenge_method": "", - "nonce": "SYXugqaAL5z7U7iioaTW5Q", + "nonce": token_urlsafe(16), "redirect_uri": "http://localhost/redirect", "response_type": "token id_token", "scope": "openid link ban lol_region account email_verified locale region", } - - r = client.post(Constants.AUTH_URL, json=body, headers=headers) - debugvalue_raw = r.text + r = await authsession.post(Constants.AUTH_URL,json=body,headers=headers,proxy=proxy["http"] if proxy is not None else None) + debugvalue_raw = await r.text() + #print(debugvalue_raw) if self.isDebug: print(debugvalue_raw) # R2 data = { + "language": "en_US", + "password": password, + "region": None, + "remember": False, "type": "auth", "username": username, - "password": password, - "remember": True, } # HUGE thanks to https://github.com/sandbox-pokhara/league-client headers = { - "User-Agent": ( - "Mozilla/5.0 (iPhone; CPU iPhone OS 11_0 like Mac OS X)" - " AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.1502.79 Mobile" - " Safari/537.36" - ), + "User-Agent": "Mozilla/5.0 (iPhone; CU iPhone OS 11_0 like Mac OS X) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.1502.79 Mobile Safari/537.36", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "Accept-Language": "en-US,en;q=0.9", "Accept-Encoding": "gzip, deflate", - "referer":"https://riotgames.com/" + "Content-Type":"application/json", + "Connection":"keep-alive", + "Host":"auth.riotgames.com", + "referer":f"https://{token_hex(5)}.riotgames.com/" } - r = client.put(Constants.AUTH_URL, json=data, headers=headers) - body = r.text - #input(body) + r = await authsession.put(Constants.AUTH_URL, json=data, headers=headers, proxy=proxy["http"] if proxy is not None else None) + r2text = await r.text() + #input(r2text) if self.isDebug: - print(body) - data = r.json() - r2text = r.text + print(r2text) + data = await r.json() + await authsession.close() except Exception as e: - client.close() + #input(e) + await authsession.close() if self.isDebug: print(e) account.code = 6 diff --git a/src/codeparts/authclient.py b/src/codeparts/authclient.py index d673c2d..e14efa9 100644 --- a/src/codeparts/authclient.py +++ b/src/codeparts/authclient.py @@ -6,13 +6,13 @@ import sys import warnings from secrets import token_urlsafe -from typing import Optional, Sequence, Tuple +from typing import Optional import aiohttp -class AuthClient: - RIOT_CLIENT_USER_AGENT = token_urlsafe(111) - CIPHERS13 = ":".join( +class RiotAuth: + RIOT_CLIENT_USER_AGENT = token_urlsafe(111).replace("_", "W").replace("-", "w") + CIPHERS13 = ":".join( # https://docs.python.org/3/library/ssl.html#tls-1-3 ( "TLS_CHACHA20_POLY1305_SHA256", "TLS_AES_128_GCM_SHA256", @@ -21,23 +21,21 @@ class AuthClient: ) CIPHERS = ":".join( ( - "TLS_AES_256_GCM_SHA384", - "TLS_CHACHA20_POLY1305_SHA256", - "TLS_AES_128_GCM_SHA256", - "ECDHE-ECDSA-AES256-GCM-SHA384", - "ECDHE-RSA-AES256-GCM-SHA384", - "ECDHE-ECDSA-AES128-GCM-SHA256", - "ECDHE-RSA-AES128-GCM-SHA256", "ECDHE-ECDSA-CHACHA20-POLY1305", "ECDHE-RSA-CHACHA20-POLY1305", - "ECDHE-ECDSA-AES256-SHA384", - "ECDHE-RSA-AES256-SHA384", - "ECDHE-ECDSA-AES128-SHA256", - "ECDHE-RSA-AES128-SHA256", - "DHE-RSA-AES256-GCM-SHA384", - "DHE-RSA-AES128-GCM-SHA256", - "DHE-RSA-AES256-SHA256", - "DHE-RSA-AES128-SHA256", + "ECDHE-ECDSA-AES128-GCM-SHA256", + "ECDHE-RSA-AES128-GCM-SHA256", + "ECDHE-ECDSA-AES256-GCM-SHA384", + "ECDHE-RSA-AES256-GCM-SHA384", + "ECDHE-ECDSA-AES128-SHA", + "ECDHE-RSA-AES128-SHA", + "ECDHE-ECDSA-AES256-SHA", + "ECDHE-RSA-AES256-SHA", + "AES128-GCM-SHA256", + "AES256-GCM-SHA384", + "AES128-SHA", + "AES256-SHA", + "DES-CBC3-SHA", # most likely not available ) ) SIGALGS = ":".join( @@ -50,12 +48,12 @@ class AuthClient: "rsa_pkcs1_sha384", "rsa_pss_rsae_sha512", "rsa_pkcs1_sha512", - "rsa_pkcs1_sha1", + "rsa_pkcs1_sha1", # will get ignored and won't be negotiated ) ) def __init__(self) -> None: - self._auth_ssl_ctx = AuthClient.create_riot_auth_ssl_ctx() + self._auth_ssl_ctx = RiotAuth.create_riot_auth_ssl_ctx() self._cookie_jar = aiohttp.CookieJar() self.access_token: Optional[str] = None self.scope: Optional[str] = None @@ -69,6 +67,7 @@ def __init__(self) -> None: def create_riot_auth_ssl_ctx() -> ssl.SSLContext: ssl_ctx = ssl.create_default_context() + # https://github.com/python/cpython/issues/88068 addr = id(ssl_ctx) + sys.getsizeof(object()) ssl_ctx_addr = ctypes.cast(addr, ctypes.POINTER(ctypes.c_void_p)).contents @@ -84,7 +83,7 @@ def create_riot_auth_ssl_ctx() -> ssl.SSLContext: libssl = ctypes.CDLL(dll_name) break elif sys.platform.startswith(("linux", "darwin")): - libssl = ctypes.CDLL(ssl._ssl.__file__) + libssl = ctypes.CDLL(ssl._ssl.__file__) # type: ignore if libssl is None: raise NotImplementedError( @@ -93,42 +92,21 @@ def create_riot_auth_ssl_ctx() -> ssl.SSLContext: with warnings.catch_warnings(): warnings.filterwarnings("ignore", category=DeprecationWarning) - ssl_ctx.minimum_version = ssl.TLSVersion.TLSv1 + ssl_ctx.minimum_version = ssl.TLSVersion.TLSv1 # deprecated since 3.10 ssl_ctx.set_alpn_protocols(["http/1.1"]) - ssl_ctx.options |= 1 << 19 - libssl.SSL_CTX_set_ciphersuites(ssl_ctx_addr, AuthClient.CIPHERS13.encode()) - libssl.SSL_CTX_set_cipher_list(ssl_ctx_addr, AuthClient.CIPHERS.encode()) - libssl.SSL_CTX_ctrl(ssl_ctx_addr, 98, 0, AuthClient.SIGALGS.encode()) - - # print([cipher["name"] for cipher in ssl_ctx.get_ciphers()]) - return ssl_ctx - - def __update( - self, - extract_jwt: bool = False, - key_attr_pairs: Sequence[Tuple[str, str]] = ( - ("sub", "user_id"), - ("exp", "expires_at"), - ), - **kwargs, - ) -> None: - predefined_keys = [key for key in self.__dict__.keys() if key[0] != "_"] - - self.__dict__.update( - (key, val) for key, val in kwargs.items() if key in predefined_keys - ) - - if extract_jwt: # extract additional data from access JWT - additional_data = self.__get_keys_from_access_token(key_attr_pairs) - self.__dict__.update( - (key, val) for key, val in additional_data if key in predefined_keys + ssl_ctx.options |= 1 << 19 # SSL_OP_NO_ENCRYPT_THEN_MAC + libssl.SSL_CTX_set_ciphersuites(ssl_ctx_addr, RiotAuth.CIPHERS13.encode()) + libssl.SSL_CTX_set_cipher_list(ssl_ctx_addr, RiotAuth.CIPHERS.encode()) + # setting SSL_CTRL_SET_SIGALGS_LIST + libssl.SSL_CTX_ctrl(ssl_ctx_addr, 98, 0, RiotAuth.SIGALGS.encode()) + # setting SSL_CTRL_SET_GROUPS_LIST + libssl.SSL_CTX_ctrl(ssl_ctx_addr, 92, 0, ":".join( + ( + "x25519", + "secp256r1", + "secp384r1", ) + ).encode()) - async def createSession(self) -> aiohttp.ClientSession: - self._cookie_jar.clear() - - conn = aiohttp.TCPConnector(ssl=self._auth_ssl_ctx) - session = aiohttp.ClientSession( - connector=conn, raise_for_status=True, cookie_jar=self._cookie_jar - ) - return session \ No newline at end of file + # print([cipher["name"] for cipher in ssl_ctx.get_ciphers()]) + return ssl_ctx \ No newline at end of file diff --git a/src/system/ver.txt b/src/system/ver.txt index 16c3c6e..9311f5e 100644 --- a/src/system/ver.txt +++ b/src/system/ver.txt @@ -1 +1 @@ -3.18.4.2 \ No newline at end of file +3.18.4.3 \ No newline at end of file