Advertisement
Guest User

extract.py

a guest
Jun 15th, 2015
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement