Skip to content

Instantly share code, notes, and snippets.

@kazikcz kazikcz/dissect.py Secret
Created Apr 14, 2015

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.