Created
November 21, 2022 19:47
-
-
Save meganukebmp/98fe4dc368f962f60d9491043d72c3bc to your computer and use it in GitHub Desktop.
Dump raw images from binaries (with headers)
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
from pathlib import Path | |
import io | |
import sys | |
data = Path(sys.argv[1]).read_bytes() | |
l = len(data) | |
for index, b in enumerate(data): | |
if (b == 0x42 and data[index+1] == 0x4D): | |
x = int.from_bytes(data[index+2:index+6], byteorder="little", signed=False) | |
if not (index + x > l): | |
print("Found data at %02x" % index) | |
with open("out/%x.bmp" % index, "wb") as binary_file: | |
binary_file.write(data[index : index+x]) |
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
from pathlib import Path | |
import io | |
import sys | |
data = Path(sys.argv[1]).read_bytes() | |
l = len(data) | |
for index, b in enumerate(data): | |
if not (index == l-1): | |
if (b == 0xFF and data[index+1] == 0xD8): | |
end = data.find(b'\xff\xd9', index) | |
if not (end == -1): | |
print("Found data at %02x" % index) | |
with open("out/%x.jpg" % index, "wb") as binary_file: | |
binary_file.write(data[index : end+2]) |
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
from pathlib import Path | |
import io | |
import sys | |
data = Path(sys.argv[1]).read_bytes() | |
l = len(data) | |
for index, b in enumerate(data): | |
if not (index == l-3): | |
if (b == 0x89 and data[index+1] == 0x50 and data[index+2] == 0x4E and data[index+3] == 0x47): | |
end = data.find(b'\x49\x45\x4E\x44\xAE\x42\x60\x82', index) | |
if not (end == -1): | |
print("Found data at %02x" % index) | |
with open("out/%x.png" % index, "wb") as binary_file: | |
binary_file.write(data[index : end+8]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment