Skip to content

Commit

Permalink
Fixed regressions in extraction and decryption
Browse files Browse the repository at this point in the history
  • Loading branch information
acabey committed Sep 30, 2017
1 parent 1b40dda commit bce919f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bootloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def replace(self, replacement, plaintext=False):
self = type(self)(replacementdata.read(replacementheader.length), replacementheader)

"""
Write current (encrypted) contents to file
Write current (encrypted) contents to file at intended offset
"""
def write(self, output):
with open(output, 'r+b') as originaldata:
Expand Down
2 changes: 1 addition & 1 deletion common.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Constants():
SHADOWBOOT_SIZE = 851968 # Seems to be the max size (bytes) for a shadowboot ROM based on official samples. Don't where limit is imposed
HV_SIZE = 0x40000
SECRET_ZERO = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
SECRET_1BL = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
SECRET_1BL = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
CPUKEY = None

# BL4 Key stuff
Expand Down
Empty file modified flash-dump.py
100644 → 100755
Empty file.
17 changes: 15 additions & 2 deletions image.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ def identifyBL2(image):
if bl2header:
try:
Image.cb = CB(image.read(bl2header.length), bl2header)
dbgprint(bl2header)
except ValueError as e:
dbgprint('Failed CB header check: ' + str(e))
except Exception as e:
raise
try:
image.seek(bl2header.offset, 0)
Image.sb = SB(image.read(bl2header.length), bl2header)
dbgprint(bl2header)
except ValueError as e:
dbgprint('Failed SB check: ' + str(e))
except Exception as e:
Expand All @@ -73,13 +76,15 @@ def identifyCD(image):
bl4header = None
offset = image.tell()
bl4header = BootloaderHeader(image.read(BootloaderHeader.HEADER_SIZE), currentoffset=offset)
dbgprint(bl4header)
except ValueError as e:
dbgprint('Failed CD header check: ' + str(e))
except Exception as e:
raise

if bl4header:
try:
image.seek(bl4header.offset, 0)
Image.cd = CD(image.read(bl4header.length), bl4header)
except ValueError as e:
dbgprint('Failed CD check: ' + str(e))
Expand All @@ -93,14 +98,16 @@ def identifyCE(image):
bl5header = None
offset = image.tell()
bl5header = BootloaderHeader(image.read(BootloaderHeader.HEADER_SIZE), currentoffset=offset)
dbgprint(bl5header)
except ValueError as e:
dbgprint('Failed CE header check: ' + str(e))
except Exception as e:
raise

if bl4header:
if bl5header:
try:
Image.ce = CD(image.read(bl5header.length), bl5header)
image.seek(bl5header.offset, 0)
Image.ce = CE(image.read(bl5header.length), bl5header)
except ValueError as e:
dbgprint('Failed CE check: ' + str(e))
except Exception as e:
Expand All @@ -113,13 +120,15 @@ def identifySC(image):
bl3header = None
offset = image.tell()
bl3header = BootloaderHeader(image.read(BootloaderHeader.HEADER_SIZE), currentoffset=offset)
dbgprint(bl3header)
except ValueError as e:
dbgprint('Failed SC header check: ' + str(e))
except Exception as e:
raise

if bl3header:
try:
image.seek(bl3header.offset, 0)
Image.sc = SC(image.read(bl3header.length), bl3header)
except ValueError as e:
dbgprint('Failed SC check: ' + str(e))
Expand All @@ -133,13 +142,15 @@ def identifySD(image):
bl4header = None
offset = image.tell()
bl4header = BootloaderHeader(image.read(BootloaderHeader.HEADER_SIZE), currentoffset=offset)
dbgprint(bl4header)
except ValueError as e:
dbgprint('Failed SD header check: ' + str(e))
except Exception as e:
raise

if bl4header:
try:
image.seek(bl4header.offset, 0)
Image.sd = SD(image.read(bl4header.length), bl4header)
except ValueError as e:
dbgprint('Failed SD check: ' + str(e))
Expand All @@ -153,13 +164,15 @@ def identifySE(image):
bl5header = None
offset = image.tell()
bl5header = BootloaderHeader(image.read(BootloaderHeader.HEADER_SIZE), currentoffset=offset)
dbgprint(bl5header)
except ValueError as e:
dbgprint('Failed SE header check: ' + str(e))
except Exception as e:
raise

if bl5header:
try:
image.seek(bl5header.offset, 0)
Image.se = SE(image.read(bl5header.length), bl5header)
except ValueError as e:
dbgprint('Failed SE check: ' + str(e))
Expand Down

0 comments on commit bce919f

Please sign in to comment.