33 lines
No EOL
865 B
Python
33 lines
No EOL
865 B
Python
import os
|
|
import io
|
|
|
|
def search_filetype(filePath, magicBytes):
|
|
with io.open(filePath, mode="rb") as file:
|
|
for line in file:
|
|
if magicBytes in line:
|
|
offset = file.tell()
|
|
print(f"Found at {hex(offset)}!")
|
|
|
|
def extract_jpeg(filePath, offset):
|
|
image = b''
|
|
with io.open(filePath, mode="rb") as file:
|
|
file.seek(offset)
|
|
for line in file:
|
|
if jpeg_sig not in line:
|
|
image += line
|
|
|
|
f = open(f"test/{offset}.jpeg", "a")
|
|
f.write(image)
|
|
f.close()
|
|
|
|
xz_sig = b'\x5d\x00\x00'
|
|
#tiff_sig = b'\x49\x49\x2A\x00'
|
|
#jpeg_sig = b'\xFF\xD8\xFF\xE0'
|
|
print("Searching for LZMA..")
|
|
search_filetype("X570PG45.60", xz_sig)
|
|
|
|
#print("Searching for TIFF...")
|
|
#search_filetype("X570PG45.60", tiff_sig)
|
|
|
|
#print("Searching for JPEG...")
|
|
#search_filetype("X570PG45.60", jpeg_sig) |