Skip to content

Instantly share code, notes, and snippets.

@brunomgalmeida
Created August 1, 2016 15:02
Show Gist options
  • Save brunomgalmeida/8a8f8c9cd838974a292d3736fd0efe2d to your computer and use it in GitHub Desktop.
Save brunomgalmeida/8a8f8c9cd838974a292d3736fd0efe2d to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
import os
def nextSetting(f):
keySize = ord(f.read(1))
key = f.read(keySize)
valueSize = ord(f.read(1)) + (ord(f.read(1))*256)
value= f.read(valueSize)
#sys.stdout.write ('(k=%3d,v=%4d,pos=%6s) %s = %s\n' % (keySize, valueSize, hex(f.tell()), key, value))
sys.stdout.write ('%s = %s\n' % (key, value))
with open ('dd-wrt-nvrambak.bin', 'rb') as f:
print f.read(8) # file format/title
while f.tell() < os.fstat(f.fileno()).st_size:
nextSetting(f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment