Created
September 2, 2017 19:18
-
-
Save skochinsky/ca02d8deae8d4234b88e4693a5eedc0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# convert Intel firmware update capsules to plain binaries | |
import sys | |
import os.path | |
import struct | |
fn = sys.argv[1] | |
inf = open(fn, "rb") | |
inf.seek(0xC8) | |
e=[] | |
while True: | |
sz, off = struct.unpack("<II", inf.read(8)) | |
print "off: %08X, sz: %08X" % (off, sz) | |
inf.read(32-8) | |
if e: | |
prevsz, prevoff = e[-1] | |
if prevoff+prevsz != off: | |
print " end?" | |
break | |
e.append((sz,off)) | |
base, ext = os.path.splitext(fn) | |
of = open(base+".bin","wb") | |
for sz, off in e: | |
inf.seek(off) | |
of.write(inf.read(sz)) | |
inf.close() | |
of.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment