diff --git a/src/checker.py b/src/checker.py index 510465a..7a6551a 100644 --- a/src/checker.py +++ b/src/checker.py @@ -300,7 +300,12 @@ def checker(self, username, password): if account.unverifiedmail and account.banuntil is None: self.unverifiedmail += 1 while True: - sys.get_region2(account, proxy) + sys.get_region(account) + if account.region == None: + sys.get_region2(account) + else: + sys.get_country_and_level_only(account) + if account.region != 'N/A' and account.region != '': if account.banuntil is None: self.regions[account.region.lower( diff --git a/src/codeparts/auth.py b/src/codeparts/auth.py index 9fbbfbb..1c7cb3d 100644 --- a/src/codeparts/auth.py +++ b/src/codeparts/auth.py @@ -25,11 +25,10 @@ def init_poolmanager(self, *a: Any, **k: Any) -> None: return super(SSLAdapter, self).init_poolmanager(*a, **k) -class auth(): +class Auth: def __init__(self) -> None: path = os.getcwd() self.useragent = Constants.RIOTCLIENT - self.parentpath = os.path.abspath(os.path.join(path, os.pardir)) def auth(self, logpass: str = None, username=None, password=None, proxy=None) -> Account: account = Account() @@ -44,8 +43,7 @@ def auth(self, logpass: str = None, username=None, password=None, proxy=None) -> session.headers = headers session.mount('https://', SSLAdapter()) if username is None: - username = logpass.split(':')[0].strip() - password = logpass.split(':')[1].strip() + username, password = logpass.split(':')[0].strip(), logpass.split(':')[1].strip() data = {"acr_values": "urn:riot:bronze", "claims": "", @@ -59,136 +57,54 @@ def auth(self, logpass: str = None, username=None, password=None, proxy=None) -> 'Content-Type': 'application/json', 'User-Agent': f'RiotClient/{self.useragent} %s (Windows;10;;Professional, x64)' } - try: - r = session.post(Constants.AUTH_URL, - json=data, headers=headers, proxies=proxy, timeout=20) - data = { - 'type': 'auth', - 'username': username, - 'password': password - } - r2 = session.put(Constants.AUTH_URL, json=data, - headers=headers, proxies=proxy, timeout=20) - # input(r2.text) - # print(session.get('https://api64.ipify.org?format=json',proxies=proxy).text) - except Exception as e: - # input(e) - account.code = 6 - return account - try: - data = r2.json() - except: - account.code = 6 - return account - if "access_token" in r2.text: - pattern = compile( - 'access_token=((?:[a-zA-Z]|\d|\.|-|_)*).*id_token=((?:[a-zA-Z]|\d|\.|-|_)*).*expires_in=(\d*)') - data = pattern.findall( - data['response']['parameters']['uri'])[0] - token = data[0] - token_id = data[1] + r = session.post(Constants.AUTH_URL, json=data, headers=headers, proxies=proxy, timeout=20) + r2 = session.put(Constants.AUTH_URL, json={"type": "auth", "username": username, "password": password}, + headers=headers, proxies=proxy, timeout=20) - elif 'invalid_session_id' in r2.text: + data = r2.json() + if "access_token" in r2.text: + pattern = compile('access_token=((?:[a-zA-Z]|\d|\.|-|_)*).*id_token=((?:[a-zA-Z]|\d|\.|-|_)*).*expires_in=(\d*)') + token, token_id, _ = pattern.findall(data['response']['parameters']['uri'])[0] + elif any(error in r2.text for error in ['invalid_session_id', 'auth_failure', 'rate_limited', 'multifactor', 'cloudflare']): account.code = 6 return account - elif "auth_failure" in r2.text: - account.code = 3 - return account - elif 'rate_limited' in r2.text: - account.code = 1 - return account - elif 'multifactor' in r2.text: - account.code = 3 - return account - elif 'cloudflare' in r2.text: - account.code = 5 - return account else: account.code = 3 return account - headers = { - 'User-Agent': f'RiotClient/{self.useragent} %s (Windows;10;;Professional, x64)', - 'Authorization': f'Bearer {token}', - } - try: - with session.post(Constants.ENTITLEMENT_URL, headers=headers, json={}, proxies=proxy) as r: - entitlement = r.json()['entitlements_token'] - r = session.post(Constants.USERINFO_URL, - headers=headers, json={}, proxies=proxy) - except: - account.code = 6 - return account - # print(r.text) - # input() - # input(r.text) + headers = {'User-Agent': f'RiotClient/{self.useragent} %s (Windows;10;;Professional, x64)', + 'Authorization': f'Bearer {token}'} + with session.post(Constants.ENTITLEMENT_URL, headers=headers, json={}, proxies=proxy) as r: + entitlement = r.json().get('entitlements_token', '') + r = session.post(Constants.USERINFO_URL, headers=headers, json={}, proxies=proxy) data = r.json() - # print(data) - # input() - gamename = data['acct']['game_name'] - tagline = data['acct']['tag_line'] - register_date = data['acct']['created_at'] - registerdatepatched = datetime.utcfromtimestamp( - int(register_date) / 1000.0) - puuid = data['sub'] + gamename, tagline, register_date, puuid = data['acct']['game_name'], data['acct']['tag_line'], data['acct']['created_at'], data['sub'] + try: - # input(data) data2 = data['ban'] - # input(data2) data3 = data2['restrictions'] - # input(data3) typebanned = data3[0]['type'] - # input(typebanned) - # input(typebanned) - if typebanned == "PERMANENT_BAN" or typebanned == 'PERMA_BAN': - # input(True) - account.code = 4 - return account - elif 'PERMANENT_BAN' in str(data3) or 'PERMA_BAN' in str(data3): - # input(True) + if typebanned in ['PERMANENT_BAN', 'PERMA_BAN'] or 'PERMANENT_BAN' in str(data3) or 'PERMA_BAN' in str(data3): account.code = 4 return account - elif typebanned == 'TIME_BAN' or typebanned == 'LEGACY_BAN': + elif typebanned in ['TIME_BAN', 'LEGACY_BAN']: expire = data3[0]['dat']['expirationMillis'] - expirepatched = datetime.utcfromtimestamp( - int(expire) / 1000.0) - # input(expire) + expirepatched = datetime.utcfromtimestamp(int(expire) / 1000.0) banuntil = expirepatched else: banuntil = None - pass - except Exception as e: - # print(e) - # input(e) + except Exception: banuntil = None - pass - try: - # headers={ - # 'Authorization': f'Bearer {token}', - # 'Content-Type': 'application/json', - # 'User-Agent': f'RiotClient/{self.useragent} %s (Windows;10;;Professional, x64)', - # } - - # r=session.get('https://email-verification.riotgames.com/api/v1/account/status',headers=headers,json={},proxies=sys.getproxy(self.proxlist)).text - - # mailverif=r.split(',"emailVerified":')[1].split('}')[0] - mailverif = bool(data['email_verified']) - - except Exception as e: - # input(e) + try: + mailverif = not bool(data['email_verified']) + except Exception: mailverif = True - mailverif = not mailverif # true to false || false to true - account.token = token - account.entt = entitlement - account.puuid = puuid - account.unverifiedmail = mailverif - account.banuntil = banuntil - account.gamename = gamename - account.tagline = tagline - account.registerdate = registerdatepatched + + account.token, account.tokenid, account.entt, account.puuid = token, token_id, entitlement, puuid + account.unverifiedmail, account.banuntil, account.gamename = mailverif, banuntil, gamename + account.tagline, account.registerdate = tagline, datetime.utcfromtimestamp(int(register_date) / 1000.0) return account except Exception as e: - account.errmsg = str(traceback.format_exc()) - account.code = 2 + account.errmsg, account.code = str(traceback.format_exc()), 2 return account diff --git a/src/codeparts/systems.py b/src/codeparts/systems.py index a244367..33718cb 100644 --- a/src/codeparts/systems.py +++ b/src/codeparts/systems.py @@ -27,27 +27,52 @@ def __init__(self) -> None: self.parentpath = os.path.abspath(os.path.join(path, os.pardir)) @staticmethod - def get_region(token: str, entt: str, proxy: dict): + def get_region(account) -> None: session = requests.Session() try: headers = { - 'X-Riot-Entitlements-JWT': entt, - 'Authorization': 'Bearer {}'.format(token) + 'User-Agent': f'RiotClient/{Constants.RIOTCLIENT} %s (Windows;10;;Professional, x64)' } response = session.put( - Constants.REGION_URL, headers=headers, proxies=proxy) + Constants.REGION_URL, headers=headers, data={"id_token": account.tokenid}) - response = response.json() - reg = 'N/A' - lvl = '' - #input(response) + data = response.json() + account.region = data['affinities']['live'].lower() + except Exception as e: + account.region = None + + @staticmethod + def get_country_and_level_only(account) -> None: + session = requests.Session() + headers = {"User-Agent": f"RiotClient/{Constants.RIOTCLIENT} %s (Windows;10;;Professional, x64)", + "Pragma": "no-cache", + "Accept": "*/*", + "Content-Type": "application/json", + "Authorization": f"Bearer {account.token}"} + userinfo = session.post( + Constants.USERINFO_URL, headers=headers) + userinfo = userinfo.json() + country = userinfo['country'].upper() + if account.region in ['latam', 'br']: + progregion = 'na' - return reg, lvl + # lvl + try: + headers = { + 'X-Riot-Entitlements-JWT': account.entt, + 'Authorization': 'Bearer {}'.format(account.token) + } + response = session.get(f"https://pd.{progregion}.a.pvp.net/account-xp/v1/players/{account.puuid}", headers=headers) + lvl = response.json()['Progress']['Level'] + #input(lvl) except Exception as e: - return 'N/A', 'N/A' + lvl = -1 + + account.country = country + account.lvl = lvl @staticmethod - def get_region2(account, proxy: dict={'http':None,'https':None}) -> None: + def get_region2(account) -> None: # reg + country session = requests.Session() headers = {"User-Agent": f"RiotClient/{Constants.RIOTCLIENT} %s (Windows;10;;Professional, x64)", @@ -70,7 +95,7 @@ def get_region2(account, proxy: dict={'http':None,'https':None}) -> None: fixedregion = Constants.COU2REG[cou3] fixedregion = fixedregion.lower() progregion = fixedregion - if fixedregion == 'latam' or fixedregion == 'br': + if account.region in ['latam', 'br']: progregion = 'na' except Exception as e: # input(e) @@ -310,6 +335,7 @@ class Account: logpass: str = None code: int = None token: str = None + tokenid: str = None entt: str = None puuid: str = None unverifiedmail: bool = None diff --git a/src/main.py b/src/main.py index 4864e0a..9d580c9 100644 --- a/src/main.py +++ b/src/main.py @@ -26,7 +26,7 @@ class program(): def __init__(self) -> None: self.count = 0 self.checked = 0 - self.version = '3.15.3.1' + self.version = '3.15.4' self.riotlimitinarow = 0 path = os.getcwd() self.parentpath = os.path.abspath(os.path.join(path, os.pardir)) @@ -44,6 +44,8 @@ def start(self): print('no internet connection') os._exit(0) os.system('cls') + kernel32 = ctypes.windll.kernel32 + kernel32.SetConsoleMode(kernel32.GetStdHandle(-10), 128) codes = vars(colorama.Fore) colors = [codes[color] for color in codes if color not in ['BLACK']] colored_name = [random.choice( @@ -54,13 +56,11 @@ def start(self): self.CheckIfFirstStart() - if 'devtest' in self.version: - print(sys.center(f'{Fore.YELLOW}Hi from liljaba')) - elif 'beta' in self.version: + if 'beta' in self.version: print(sys.center( f'{Fore.YELLOW}You have downloaded the BETA version. It can work unstable and contain some bugs.')) print(sys.center( - f'Follow https://github.com/LIL-JABA/valchecker/releases/latest to download the latest stable release{Fore.RESET}')) + f'Visit https://github.com/LIL-JABA/valchecker/releases/latest to download the latest stable release{Fore.RESET}')) elif self.lastver != self.version: print(sys.center( f'\nnext version {self.lastver} is available!')) @@ -163,7 +163,7 @@ def main(self): ctypes.windll.kernel32.SetConsoleTitleW( f'ValChecker {self.version} by liljaba1337 | Loading Settings') print('loading settings') - settings = sys.load_settings() + settings = sys.load_settings() ctypes.windll.kernel32.SetConsoleTitleW( f'ValChecker {self.version} by liljaba1337 | Loading Proxies') @@ -203,7 +203,6 @@ def main(self): ctypes.windll.kernel32.SetConsoleTitleW( f'ValChecker {self.version} by liljaba1337 | Loading Accounts') print('loading accounts') - accounts = self.get_accounts() print('loading assets')