Codehead's Corner
Random ramblings on hacking, coding, fighting with infrastructure and general tech
Tokyo Western CTF 2016 – Glance - Misc 50
Posted: 5 Sep 2016 at 21:04 by Codehead

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 ="glance.gif")

canvas ="RGB", [gif.size[0] * gif.n_frames, gif.size[1]])
x = 0

for frame in ImageSequence.Iterator(gif):
	canvas.paste(frame, (x, 0))

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.

Categories: Hacking CTF

Site powered by Hugo.
Polymer theme by pdevty, tweaked by Codehead