I almost missed the Tokyo Westerns CTF. I stumbled across the event on the last day and wasn’t able to spend too long on it. I managed a few of challenges, mainly the PPC category. However, I wanted to write up the ‘Glance’ image manipulation challenge for future reference.
I saw this through a gap of the door on a train.
This image was linked from the challenge page. You can miss it if you’re not careful, but if you look closely, you will see a very tall and thin animated GIF.
Looking at the image we can see it is formed of a blue top section with some white parts and a green lower half. The whole thing wobbles up and down a bit and there is also something darker flickering in the middle. As the clue states, this is just like being in a moving vehicle and viewing the outside world through a narrow slit. At first glance, the colours remind me of the Windows XP default desktop background.
In order to see the whole picture, we need to stitch all the GIF frames together side-by-side to form one image of a ‘sweep’ across the landscape. This is a perfect job for the Python Image Library (PIL).
from PIL import Image, ImageSequence gif = Image.open("glance.gif") canvas = Image.new("RGB", [gif.size * gif.n_frames, gif.size]) x = 0 for frame in ImageSequence.Iterator(gif): canvas.paste(frame, (x, 0)) x+=gif.size canvas.show() canvas.save("glance_output.png")
There’s not much to break down here. Loading and creating images with PIL is very simple. All the image attributes and properties are readily available and moving content between the two images is also very easy.
The show() function invokes the system image viewer, so we don’t need to save off a file to view the results.
As suspected, the image was the XP wallpaper, and we’ve found our flag.