Skip to content

Commit

Permalink
Removed unused code section causing flaking errors
Browse files Browse the repository at this point in the history
  • Loading branch information
acabey committed Jan 15, 2020
1 parent c7f8f6c commit 614bae7
Showing 1 changed file with 10 additions and 67 deletions.
77 changes: 10 additions & 67 deletions flash-dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,11 @@

from lib import keys
from lib.image import Image
from lib.smc import SMC


logging.basicConfig()
LOGGER = logging.getLogger('flash-dump-tool')

# Load image
"""
Read from the provided image file
- Check valid image
- Magic bytes (hard)
- Copyright (soft)
- Construct NAND header
"""


def main():
parser = argparse.ArgumentParser(prog='flash-dump',
Expand Down Expand Up @@ -180,6 +169,16 @@ def main():

LOGGER.debug('args: ' + str(args))

# Load image
"""
Read from the provided image file
- Check valid image
- Magic bytes (hard)
- Copyright (soft)
- Construct NAND header
"""

# Load input metadata and populate available sections
"""
============================================================================
Expand Down Expand Up @@ -272,62 +271,6 @@ def main():
else:
LOGGER.warning('Section: ' + section + ' is not available in input file')

"""
============================================================================
DEPRECATED
This is code from prior revisions that I have not refactored.
It will be kept (inaccesible) as a reference until implemented in new structure
============================================================================
"""

"""
============================================================================
NAND Extras
============================================================================
"""
if False:
nandsections = []
nandheader = None

# Check for SMC
if not nandheader.smcoffset == 0:
image.seek(nandheader.smcoffset, 0)
smcdata = image.read(nandheader.smclength)
# Make sure SMC is not null
if not all(b == 0 for b in smcdata):
smc = SMC(smcdata, nandheader.smcoffset)
# nandsections.append(smc)
print('Found valid SMC at ' + str(hex(smc.offset)))
else:
print('SMC is null, skipping SMC')
else:
print('SMC offset is null, skipping SMC')

# Check for Keyvault
# Because the keyvault's length is stored in its header, we first create the header object
if not nandheader.kvoffset == 0:
image.seek(nandheader.kvoffset, 0)
keyvaultheaderdata = image.read(KeyvaultHeader.HEADER_SIZE)
# Make sure KV header is not null
if not all(b == 0 for b in keyvaultheaderdata):
keyvaultheader = KeyvaultHeader(keyvaultheaderdata, nandheader.kvoffset)

image.seek(nandheader.kvoffset, 0)
keyvaultdata = image.read(keyvaultheader.length)
# Make sure KV is not null
if not all(b == 0 for b in keyvaultdata):
keyvault = Keyvault(keyvaultheader, keyvaultdata)
nandsections.append(keyvault)
print('Found valid keyvault at ' + str(hex(keyvault.offset)))
else:
print('Keyvault data is null, skipping keyvault')
else:
print('Keyvault header is null, skipping keyvault')
else:
print('Keyvault offset is null, skipping keyvault')


if __name__ == '__main__':
main()

0 comments on commit 614bae7

Please sign in to comment.