Created
January 31, 2020 16:48
-
-
Save hottabxp/bbb633a05ebcc94073c8c1d6766bd5a9 to your computer and use it in GitHub Desktop.
Find bytes in binary files
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
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