Skip to content

Instantly share code, notes, and snippets.

@hottabxp
Created February 19, 2020 16:47
Show Gist options
  • Save hottabxp/afe76eb72ac1283d2d18c958bbad5784 to your computer and use it in GitHub Desktop.
Save hottabxp/afe76eb72ac1283d2d18c958bbad5784 to your computer and use it in GitHub Desktop.
Поиск png в бинарных файлах
import random
with open('wiatArms.is','rb') as file:
data = file.read()
def save_File(data,filename):
with open(f'{filename}.png','wb') as file:
file.write(data)
start_png = -1
end_png = 0
i = 0
while True:
start_png = data.find(bytes.fromhex('89 50 4E 47 0D 0A 1A 0A'),start_png+1)
end_png = data.find(bytes.fromhex('49 45 4E 44 AE 42 60 82'),end_png)+8
if start_png == -1:
break
print(f'Start:{start_png}')
print(f'End:{end_png}')
save_File(data[start_png:end_png],i)
i = i + 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment