[nullcon HACKIM]Programming Question 1 [Prog][200pts]

The “Programming Question1” challenge from HACKIM CTF gives 200 points, here is this description :

The abc.txt file contains the pixels of an image like this [(r,g,b)…(r,g,b)]

The file can be downloaded here : https://s3.amazonaws.com/hackim17/prog1_ABC/abc.txt

It’s abvious that we have to create the image from the text file, we’ll do it with this python script :

#!/usr/bin/env python2
try:
    from PIL import Image
except ImportError:
    import Image


with open('abc.txt', 'r') as myfile:
    pixels=eval(myfile.read())

data = ""
for i in pixels:
	data += chr(i[0]) + chr(i[1]) + chr(i[2])
im = Image.frombytes("RGB", (929,569), data)
im.save("test.png", "PNG")
GenerateImage.py

Here’s the generated image :

The flag is in the right side on the bottom : flag{Pil_PIL_PIL} !

Leave a Reply

Your email address will not be published.