[CSAW '23] 1black0white
Converting Binary Data into a QR code.
Distribution
We were provided a data file with some decimal data.
Solution
Based on the challenge title, I knew I wanted to use the data to visualize a QR code, where is black and is white. There were some initial issues with this approach:
The data was in decimal, not binary
Not all the lines were the same length.
We can fix this by converting the data to binary and then padding the lines until they are all the same length. It turns out the longest line is binary digits long so we can pad to this length.
Now, we can use PIL (the Python Imaging Library) to create an image from the binary data. I made a new image and then looped through the binary data, setting each pixel to black or white based on the value of the binary digit.
To ensure my phone could scan the image, I resized it to be times the original size.
This generates an image that gives us the flag when we scan it.
Full Solution
Last updated
Was this helpful?