Skip to content

Instantly share code, notes, and snippets.

@Nicholaz99
Created June 5, 2020 20:46
Show Gist options
  • Save Nicholaz99/fdf945ef9d6fae83228def0c82e7acdf to your computer and use it in GitHub Desktop.
Save Nicholaz99/fdf945ef9d6fae83228def0c82e7acdf to your computer and use it in GitHub Desktop.
from PIL import Image
from struct import pack, unpack
from typing import List, Tuple
import random
with Image.open('out.png') as image:
seed = b'\xed\xfe\xcb\x10'
random.seed(seed)
image = image.convert("RGB")
pixels = image.load()
available = image.width * image.height * 3
size = 34
valid_spots = []
for channel in range(3):
for y in range(image.height):
for x in range(image.width):
valid_spots.append((x, y, channel))
metadata = b"\x90\xbfhttps://github.com/evil-steganography/evil-stego-1" + bytes(seed) + pack("<I", size)
c = len(metadata)*8
locations = random.sample(valid_spots[c:], size * 8 + 1)
c = 0
flag = ''
for i in range(size):
bit_location = locations[c:c+8]
bit = ''
for x, y, channel in bit_location:
orig = list(pixels[x, y])
bit += str(orig[channel] & 1)
flag += chr(int(bit, 2))
c += 8
print('[+] Flag:', flag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment