Info

Hilbert curve

Tools

https://pypi.org/project/hilbertcurve/

Example Challenge

VolgaCTF 2020 - Curved (https://ctftime.org/writeup/19158)

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/b13d0149-f3f7-4cb6-b83f-6f66c8ecb30e/stego.png

from BitVector import BitVector
from PIL import Image
from hilbertcurve.hilbertcurve import HilbertCurve
import math

img  = Image.open("stego.png")

# build a list of hilbert curve coordinates
hc = HilbertCurve(int(math.log2(img.height)), 2)
locations = [hc.coordinates_from_distance(i) for i in range(hc.max_h+1)]

# iterate the pixels in transposed hilbert curve order
bitlist = [img.getpixel((y,x))[2] & 1 for (x,y) in locations]
BitVector(bitlist=bitlist).write_to_file(open("out.png", "wb"))

Image.open("out.png")