Skip to content

Instantly share code, notes, and snippets.

@K0lb3
Created July 7, 2020 09:10
Show Gist options
  • Save K0lb3/ac1f6a2b62ce4f517c32e0557f7520a0 to your computer and use it in GitHub Desktop.
Save K0lb3/ac1f6a2b62ce4f517c32e0557f7520a0 to your computer and use it in GitHub Desktop.
from PIL import Image
fp = "lena.png"
# extrahiere Nachricht vom Bild
extracted_bin = []
with Image.open(fp) as img:
data = img.tobytes()
for i in range(0, len(data)//8):
extracted_bin.append(data[i]&1)
# dekodiere Nachricht (binär zu char via big-endian)
b = bytearray(len(extracted_bin)//8)
for i in range(0, len(extracted_bin)//8, 1):
for j in range(8):
b[i] += extracted_bin[i*8+j]<<(7-j)
text = b.decode("ascii",'ignore')
# parse Parameter
length, text = text.split(":",1)
secret = text[:int(length)]
# finde key in Flag
import re
key = re.search(r"\^FLAG\^(.+?)\^FLAG\^", secret)[1]
# dekodiere Key
import base64
print(base64.b64decode(key))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment