Skip to content

Instantly share code, notes, and snippets.

@hottabxp
Created January 31, 2020 16:48
Show Gist options
  • Save hottabxp/bbb633a05ebcc94073c8c1d6766bd5a9 to your computer and use it in GitHub Desktop.
Save hottabxp/bbb633a05ebcc94073c8c1d6766bd5a9 to your computer and use it in GitHub Desktop.
Find bytes in binary files
with open('test.mp3','rb') as file:
data = file.read()
start_png = data.find(bytes.fromhex('89 50 4E 47 0D 0A 1A 0A'))
end_png = data.find(bytes.fromhex('49 45 4E 44 AE 42 60 82'))+8
with open('test.png','wb') as f:
f.write(data[start_png:end_png])
print(start_png)
print(end_png)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment