Guest User

extract.py

a guest
Jun 15th, 2015
288
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import binascii, re
  2. start_hex = "89504E470D0A1A0A"
  3. end_hex = "49454E44AE426082"
  4. cursor = 0
  5. filecount = 1
  6. with open("res.bin", "rb") as file:
  7. resources = file.read()
  8. hexed = binascii.hexlify(resources).decode("ascii").upper()
  9. pngends = [a.start() for a in re.finditer(end_hex, hexed)]
  10. for end in pngends:
  11. filename = "img{0}.png".format(filecount)
  12. with open(filename, "wb") as img:
  13. img_data = start_hex + hexed[cursor:end+16]
  14. binary_string = binascii.unhexlify(img_data)
  15. img.write(binary_string)
  16. cursor = end + 16
  17. filecount += 1
RAW Paste Data