From 345ba7e6ed37801ae9552770a104455f6a2bb256 Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Wed, 24 May 2023 17:12:34 +0400 Subject: [PATCH] Other SEC token generating algorithm --- python_aternos/atconnect.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/python_aternos/atconnect.py b/python_aternos/atconnect.py index acd39df..58fe912 100644 --- a/python_aternos/atconnect.py +++ b/python_aternos/atconnect.py @@ -2,8 +2,12 @@ import re import time + +import string import secrets + import logging + from functools import partial from typing import Optional @@ -27,6 +31,8 @@ SCRIPT_TAG_REGEX = ( rb'' ) +SEC_ALPHABET = string.ascii_lowercase + string.digits + class AternosConnect: @@ -151,8 +157,8 @@ class AternosConnect: Random SEC `key:value` string """ - randkey = secrets.token_hex(8) - randval = secrets.token_hex(8) + randkey = self.generate_sec_part() + randval = self.generate_sec_part() self.sec = f'{randkey}:{randval}' self.session.cookies.set( f'ATERNOS_SEC_{randkey}', randval, @@ -160,6 +166,11 @@ class AternosConnect: ) return self.sec + + def generate_sec_part(self) -> str: + """Generates a part for SEC token""" + + return ''.join(secrets.choice(SEC_ALPHABET) for _ in range(11)) + ('0' * 5) def request_cloudflare( self, url: str, method: str,