Created
December 9, 2017 20:17
-
-
Save mjonasz/60a9b20ce306af42f4dd94408e6e8e3c to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python3 | |
# probuje bit po bicie, pillow mi się wywalał na oryginalnym pliku | |
# https://files-quals.seccon.jp/tktk-892009a0993d079214efa167cda2e7afc85e6b9cb38588cba9dab23eb6eb3d46 | |
from PIL import Image | |
from io import BytesIO | |
file = open("broken.jpg", "rb") | |
data = list(file.read()) | |
for i in range(0, len(data)): | |
for j in range(0, 8): | |
org = data[i] | |
data[i] = data[i]^(1<<j) | |
try: | |
im = Image.open(BytesIO(bytes(data))) | |
im.save(f"good{i}x{j}.jpg", "jpeg") | |
print(f"{i}:{j}") | |
except IOError: | |
pass | |
data[i] = org | |
# best output in good623x1.jpg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment