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
#!/usr/bin/python | |
# | |
# usage: python this.py < qca61xx.bin | |
# unpacks qca61xx.bin files | |
# creates fw-x.bin files in current work dir (overwrites existing files!) | |
# | |
import sys | |
buf = sys.stdin.read() | |
head = 'SGMT' | |
tail = '\xfd\xff\xff\xff\x00\x00\x00\x00\xff\xff\xff\xff' | |
i = 1 | |
while True: | |
start = buf.find(head) | |
buf = buf[start:] | |
end = buf.find(tail) | |
if start == -1 or end == -1: | |
break | |
end += len(tail) | |
fname = 'fw-%d.bin' % i | |
i += 1 | |
print "writing %s (%d bytes)" % (fname, end) | |
with open(fname, "wb") as f: | |
f.write(buf[:end]) | |
f.close() | |
buf = buf[end:] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment