Merge pull request #569 from Dinolek/auth

Add xiaomi empty token(works on <sm8350)
This commit is contained in:
Bjoern Kerler 2024-08-27 17:39:26 +02:00 committed by GitHub
commit d2c585e4cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 46 additions and 32 deletions

View file

@ -7,6 +7,8 @@
# GPLv3 and has to be open sourced under GPLv3 as well. !!!!!
import logging
from functools import cached_property
from edlclient.Library.utils import LogBase
try:
@ -52,25 +54,31 @@ class modules(metaclass=LogBase):
self.__logger.addHandler(fh)
self.options = {}
self.devicemodel = devicemodel
self.generic = None
@cached_property
def generic(self):
try:
self.generic = generic(fh=self.fh, serial=self.serial, args=self.args, loglevel=loglevel)
return generic(fh=self.fh, serial=self.serial, args=self.args, loglevel=self.__logger.loglevel)
except Exception as e:
self.error(e)
pass
self.ops = None
return None
@cached_property
def ops(self):
try:
self.ops = oneplus(fh=self.fh, projid=self.devicemodel, serial=self.serial,
supported_functions=self.supported_functions, args=self.args, loglevel=loglevel)
return oneplus(fh=self.fh, projid=self.devicemodel, serial=self.serial, loglevel=self.__logger.loglevel,
supported_functions=self.supported_functions, args=self.args)
except Exception as e:
self.error(e)
pass
self.xiaomi = None
return None
@cached_property
def xiaomi(self):
try:
self.xiaomi = xiaomi(fh=self.fh)
return xiaomi(fh=self.fh)
except Exception as e:
self.error(e)
pass
return None
def addpatch(self):
if self.ops is not None:
@ -116,7 +124,6 @@ class modules(metaclass=LogBase):
return self.generic.oem_unlock(enable)
elif self.ops is not None and command == "ops":
if self.devicemodel is not None:
enable = False
partition = "param"
if "enable" in options:
enable = True

View file

@ -6,6 +6,7 @@
# !!!!! If you use this code in commercial products, your product is automatically
# GPLv3 and has to be open sourced under GPLv3 as well. !!!!!
import base64
import logging
from edlclient.Library.utils import LogBase
@ -14,19 +15,20 @@ class xiaomi(metaclass=LogBase):
def __init__(self, fh, projid="18825", serial=123456, ATOBuild=0, Flash_Mode=0, cf=0, supported_functions=None,
loglevel=logging.INFO):
self.fh = fh
self.xiaomi_authdata = b"\x93\x6E\x3A\x8E\x57\x3C\xAD\x07\xC1\x67\x64\x4B\x61\x21\x78\x35\xD8\x5A\xD4\xFD" + \
b"\xDB\x7D\x84\x0A\x2B\x72\x25\x43\x2F\xCD\xA1\x3A\x7C\x19\x2C\xFA\x97\x9E\xD1\x65" + \
b"\x17\xE6\x97\x0B\x1B\x07\xDF\x6C\x51\x6F\xEC\x81\xF6\x96\x8F\xCF\x7F\xFD\xDB\xC3" + \
b"\x97\xA1\x62\xC2\xCA\x3E\x5D\x76\x12\x4A\xA1\x76\x9F\x1B\x21\x64\xB3\x9B\x76\x93" + \
b"\x0B\x4C\xC6\x75\x19\xF7\xF3\x39\x87\x76\x77\xF4\xE8\xAF\x25\x82\x86\x82\xBC\xBF" + \
b"\x4E\x59\x3A\x57\xE7\xE3\x05\x32\x69\x92\x53\xE0\xB1\xCC\x5D\x9D\x0D\x55\x4A\xF2" + \
b"\xBD\x46\xD5\x6F\x18\xD6\xE5\x29\x0B\xA4\xA0\xCA\xC2\x43\x1F\x9F\x19\xC4\xC1\xA3" + \
b"\x9D\x76\x64\xFF\xAB\x48\xA9\xE1\x1A\x55\x93\x86\x81\x98\x35\xB8\x4D\xF5\x67\x5E" + \
b"\x70\xD2\x5F\xDB\x51\x23\xE7\xB0\x40\xFE\x21\x10\x8F\x0A\xE6\xD7\xD9\xD2\x67\xF2" + \
b"\xC9\xC6\x1A\xD0\x54\xC6\x84\x93\xDC\x4D\x33\xF7\x4D\x0C\xF2\xD4\xAA\xDC\xD4\x30" + \
b"\x15\x2D\xB6\x7C\x22\xA1\x81\xAD\x6D\x77\x61\x63\x7F\x70\xCB\xDA\x88\x4C\xDC\x11" + \
b"\x33\x72\x03\x83\x77\x90\xE6\x84\x5C\xA5\xA8\x76\x79\x30\xB9\xC2\x6F\xDA\x71\x27" + \
b"\x25\x64\xCA\x34\x76\x3D\x35\x2F\x5F\xE4\x2A\xB7\x38\xFB\x38\xA5"
self.xiaomi_authdata = [
# "QlJORVVnSXVRSTJscjhrU1dDQ3E1dWM3ZnpoRw=="
"k246jlc8rQfBZ2RLYSF4Ndha1P3bfYQKK3IlQy/NoTp8GSz6l57RZRfmlwsbB99sUW/sgfaWj89//dvDl6Fiwso"
"+XXYSSqF2nxshZLObdpMLTMZ1GffzOYd2d/ToryWChoK8v05ZOlfn4wUyaZJT4LHMXZ0NVUryvUbVbxjW5SkLpKDKwkMfnxnEwaOddmT"
"/q0ip4RpVk4aBmDW4TfVnXnDSX9tRI+ewQP4hEI8K5tfZ0mfyycYa0FTGhJPcTTP3TQzy1Krc1DAVLbZ8IqGBrW13YWN"
"/cMvaiEzcETNyA4N3kOaEXKWodnkwucJv2nEnJWTKNHY9NS9f5Cq3OPs4pQ==",
# "\0"
"vzXWATo51hZr4Dh+a5sA/Q4JYoP4Ee3oFZSGbPZ2tBsaMupn"
"+6tPbZDkXJRLUzAqHaMtlPMKaOHrEWZysCkgCJqpOPkUZNaSbEKpPQ6uiOVJpJwA"
"/PmxuJ72inzSPevriMAdhQrNUqgyu4ATTEsOKnoUIuJTDBmzCeuh/34SOjTdO4Pc+s3ORfMD0TX+WImeUx4c9xVdSL/xirPl"
"/BouhfuwFd4qPPyO5RqkU/fevEoJWGHaFjfI302c9k7EpfRUhq1z+wNpZblOHuj0B3/7VOkK8KtSvwLkmVF"
"/t9ECiry6G5iVGEOyqMlktNlIAbr2MMYXn6b4Y3GDCkhPJ5LUkQ=="
]
self.__logger.setLevel(loglevel)
if loglevel == logging.DEBUG:
logfilename = "log.txt"
@ -38,12 +40,16 @@ class xiaomi(metaclass=LogBase):
Redmi A1, Poco F1, Redmi 5 Pro, 6 Pro, 7 Pro, 7A, 8, 8A, 8A Dual, 8A Pro, Y2, S2
"""
authcmd = b"<?xml version=\"1.0\" ?><data> <sig TargetName=\"sig\" size_in_bytes=\"256\" verbose=\"1\"/></data>"
rsp = self.fh.xmlsend(authcmd)
if rsp.resp:
rsp = self.fh.xmlsend(self.xiaomi_authdata)
if rsp.resp:
if "value" in rsp.resp:
if rsp.resp["value"] == "ACK":
if 'authenticated' in rsp.log[0].lower() and 'true' in rsp.log[0].lower():
return True
for authdata in self.xiaomi_authdata:
rsp = self.fh.xmlsend(authcmd)
if not rsp.resp:
continue
rsp = self.fh.xmlsend(base64.b64decode(authdata))
if not rsp.resp:
continue
if 'authenticated' in rsp.log[0].lower():
return True
return False

View file

@ -915,6 +915,7 @@ class firehose(metaclass=LogBase):
except Exception as err: # pylint: disable=broad-except
self.modules = None
if self.modules.edlauth():
self.info("EDL Authenticated successfully.")
rsp = self.xmlsend(connectcmd)
return rsp.resp
else: