mirror of
https://github.com/bkerler/mtkclient.git
synced 2024-11-14 19:25:05 -05:00
Fix payload to show com port, other minor fixes
This commit is contained in:
parent
ab31065ffd
commit
11ca4bdb90
5 changed files with 27 additions and 16 deletions
1
mtk
1
mtk
|
@ -663,6 +663,7 @@ if __name__ == '__main__':
|
|||
parser_plstage.add_argument('--skipwdt', help='Skip wdt init')
|
||||
parser_plstage.add_argument('--offset', help='Peek ram offset using patched preloader')
|
||||
parser_plstage.add_argument('--length', help='Peek ram length using patched preloader')
|
||||
parser_plstage.add_argument('--filename', help='Filename for peek ram using patched preloader')
|
||||
parser_plstage.add_argument('--wdt', help='Set a specific watchdog addr')
|
||||
parser_plstage.add_argument('--mode', help='Set a crash mode (0=dasend1,1=dasend2,2=daread)')
|
||||
parser_plstage.add_argument('--var1', help='Set kamakiri specific var1 value')
|
||||
|
|
|
@ -342,6 +342,10 @@ class usb_class(DeviceClass):
|
|||
self.device.attach_kernel_driver(0)
|
||||
except Exception as err:
|
||||
self.debug(str(err))
|
||||
if reset:
|
||||
if not self.device.is_kernel_driver_active(0):
|
||||
# self.device.attach_kernel_driver(self.interface) #Do NOT uncomment
|
||||
self.device.attach_kernel_driver(0)
|
||||
pass
|
||||
usb.util.dispose_resources(self.device)
|
||||
del self.device
|
||||
|
@ -387,28 +391,24 @@ class usb_class(DeviceClass):
|
|||
self.verify_data(bytearray(command), "TX:")
|
||||
return True
|
||||
|
||||
def usbread(self, resplen=None, maxtimeout=10):
|
||||
if maxtimeout == 0:
|
||||
timeout = 10
|
||||
else:
|
||||
timeout = maxtimeout
|
||||
def usbread(self, resplen=None, maxtimeout=100):
|
||||
if resplen is None:
|
||||
resplen = self.maxsize
|
||||
if resplen <= 0:
|
||||
self.info("Warning !")
|
||||
res = bytearray()
|
||||
timeout = 0
|
||||
loglevel = self.loglevel
|
||||
epr = self.EP_IN.read
|
||||
wMaxPacketSize = self.EP_IN.wMaxPacketSize
|
||||
extend = res.extend
|
||||
|
||||
while len(res) < resplen:
|
||||
try:
|
||||
extend(epr(resplen))
|
||||
except usb.core.USBError as e:
|
||||
error = str(e.strerror)
|
||||
if "timed out" in error:
|
||||
if timeout is None:
|
||||
return b""
|
||||
self.debug("Timed out")
|
||||
if timeout == maxtimeout:
|
||||
return b""
|
||||
|
@ -427,6 +427,7 @@ class usb_class(DeviceClass):
|
|||
self.verify_data(res[:resplen], "RX:")
|
||||
return res[:resplen]
|
||||
|
||||
|
||||
def ctrl_transfer(self, bmRequestType, bRequest, wValue, wIndex, data_or_wLength):
|
||||
ret = self.device.ctrl_transfer(bmRequestType=bmRequestType, bRequest=bRequest, wValue=wValue, wIndex=wIndex,
|
||||
data_or_wLength=data_or_wLength)
|
||||
|
|
|
@ -53,7 +53,7 @@ class Mtk(metaclass=LogBase):
|
|||
i += 1
|
||||
if patched:
|
||||
import sys
|
||||
with open(sys.argv[1]+".patched","wb") as wf:
|
||||
with open("preloader.patched","wb") as wf:
|
||||
wf.write(data)
|
||||
print("Patched !")
|
||||
self.info(f"Patched preloader security: {hex(i)}")
|
||||
|
|
|
@ -831,7 +831,6 @@ class DALegacy(metaclass=LogBase):
|
|||
self.config.bmtsettings(self.config.hwcode)
|
||||
self.usbwrite(pack("B", self.config.bmtflag))
|
||||
self.usbwrite(pack(">I", self.config.bmtpartsize))
|
||||
# self.usbwrite(pack(">I", bmtblockcount))
|
||||
# unsigned char force_charge=0x02; //Setting in tool: 0x02=Auto, 0x01=On
|
||||
force_charge = 0x02
|
||||
self.usbwrite(pack("B", force_charge))
|
||||
|
|
|
@ -426,7 +426,7 @@ class Main(metaclass=LogBase):
|
|||
self.info(f"Sent preloader to {hex(daaddr)}, length {hex(len(dadata))}")
|
||||
if mtk.preloader.jump_da(daaddr):
|
||||
self.info(f"PL Jumped to daaddr {hex(daaddr)}.")
|
||||
time.sleep(2)
|
||||
time.sleep(1)
|
||||
mtk = Mtk(config=mtk.config, loglevel=self.__logger.level)
|
||||
res = mtk.preloader.init()
|
||||
if not res:
|
||||
|
@ -438,16 +438,26 @@ class Main(metaclass=LogBase):
|
|||
if self.args.startpartition is not None:
|
||||
partition = self.args.startpartition
|
||||
self.info("Booting to : " + partition)
|
||||
# if data[0:4]!=b"\x88\x16\x88\x58":
|
||||
# data=0x200*b"\x00"+data
|
||||
mtk.preloader.send_partition_data(partition, mtk.patch_preloader_security(pldata))
|
||||
status = mtk.preloader.jump_to_partition(partition) # Do not remove !
|
||||
if self.args.offset is not None and self.args.length is not None:
|
||||
with open("peek.bin","wb") as wf:
|
||||
for pos in range(0,self.args.offset,self.args.length):
|
||||
if self.args.offset is not None and self.args.length is not None:
|
||||
offset = getint(self.args.offset)
|
||||
length = getint(self.args.length)
|
||||
rlen = min(0x200, length)
|
||||
status=0
|
||||
mtk.preloader.get_hw_sw_ver()
|
||||
if self.args.filename is not None:
|
||||
with open(self.args.filename,"wb") as wf:
|
||||
for pos in range(offset, offset+length,rlen):
|
||||
print("Reading pos %08X" % pos)
|
||||
res = mtk.preloader.read32(pos, self.args.length//4)
|
||||
res = mtk.preloader.read32(pos, rlen//4)
|
||||
wf.write(b"".join([pack("<I",val) for val in res]))
|
||||
else:
|
||||
for pos in range(offset, offset+length,rlen):
|
||||
print("Reading pos %08X" % pos)
|
||||
res = mtk.preloader.read32(pos, rlen // 4)
|
||||
print(hexlify(b"".join([pack("<I",val) for val in res])).decode('utf-8'))
|
||||
|
||||
#for val in res:
|
||||
# print(hex(val))
|
||||
if status != 0x0:
|
||||
|
|
Loading…
Reference in a new issue