From 586d86e67aa572be0849107db7599c53b6c2c550 Mon Sep 17 00:00:00 2001 From: Bjoern Kerler Date: Mon, 22 Jul 2024 20:37:05 +0200 Subject: [PATCH] Fix dumpbrom --- mtkclient/Library/Exploit/kamakiri2.py | 33 +++++++++++++++++++------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/mtkclient/Library/Exploit/kamakiri2.py b/mtkclient/Library/Exploit/kamakiri2.py index e1dce7ba..4ba4b45f 100755 --- a/mtkclient/Library/Exploit/kamakiri2.py +++ b/mtkclient/Library/Exploit/kamakiri2.py @@ -153,14 +153,31 @@ def newbrute(self, dump_ptr, dump=False): return False, dump_ptr + 4 def dump_brom(self, filename, dump_ptr=None, length=0x20000): - try: - with open(filename, 'wb') as wf: - wf.write(self.newbrute(dump_ptr, True)) - print_progress(100, 100, prefix='Progress:', suffix='Complete', bar_length=50) - return True - except Exception as e: - self.error(f"Error on opening {filename} for writing: {str(e)}") - return False + if dump_ptr is None: + try: + with open(filename, 'wb') as wf: + print_progress(0, 100, prefix='Progress:', suffix='Complete', bar_length=50) + length = self.mtk.port.usbread(4) + length = int.from_bytes(length, 'big') + rlen = min(length, 0x20000) + for i in range(length // rlen): + data = self.mtk.port.usbread(rlen) + wf.write(data) + print_progress(i, length // rlen, prefix='Progress:', suffix='Complete', bar_length=50) + print_progress(100, 100, prefix='Progress:', suffix='Complete', bar_length=50) + return True + except Exception as e: + self.error(f"Error on opening {filename} for writing: {str(e)}") + return False + else: + try: + with open(filename, 'wb') as wf: + wf.write(self.newbrute(dump_ptr, True)) + print_progress(100, 100, prefix='Progress:', suffix='Complete', bar_length=50) + return True + except Exception as e: + self.error(f"Error on opening {filename} for writing: {str(e)}") + return False def dump_preloader(self, filename=None): rfilename = None