Лаборатория TJCTF 2016 - Basic Images [forensics 65]

delimitry
, 1 июня 2016

Check out my shades! If you want the flag, I guess you should be basic like me. Good luck! 

A PNG image file is given.

Quick analysis of pixels, has shown that R,G and B channels are the same. 
Then I've tried to get each pixel's R value (R=G=B) and convert to char. Furtunately the output string was readable and looked like base64.
After decoding this base64 I've got a new PNG file, like the original one, but smaller. I've repeated the steps and have got a new PNG file.
After repeating the steps several times, I've finally got a flag :)
My script in Python to solve this task: 

from PIL import Image


img = Image.open('shades.png')
p = img.load()
w, h = img.size
out = ''
for y in range(h):
    for x in range(w):
        out += chr(p[x, y][0])
with open('shades_out.png', 'wb') as f:
    f.write(out.decode('base64'))

img = Image.open('shades_out.png')
p = img.load()
w, h = img.size
out = ''
for y in range(h):
    for x in range(w):
        out += chr(p[x, y][0])
with open('shades_out_2.png', 'wb') as f:
    f.write(out.decode('base64'))

img = Image.open('shades_out_2.png')
p = img.load()
w, h = img.size
out = ''
for y in range(h):
    for x in range(w):
        out += chr(p[x, y][0])
with open('shades_out_3.png', 'wb') as f:
    f.write(out.decode('base64'))

img = Image.open('shades_out_3.png')
p = img.load()
w, h = img.size
out = ''
for y in range(h):
    for x in range(w):
        out += chr(p[x, y][0])
with open('shades_out_4.png', 'wb') as f:
    f.write(out.decode('base64'))

img = Image.open('shades_out_4.png')
p = img.load()
w, h = img.size
out = ''
for y in range(h):
    for x in range(w):
        out += chr(p[x, y][0])
with open('shades_out_5.png', 'wb') as f:
    f.write(out.decode('base64'))

img = Image.open('shades_out_5.png')
p = img.load()
w, h = img.size
out = ''
for y in range(h):
    for x in range(w):
        out += chr(p[x, y][0])
with open('shades_out_6.png', 'wb') as f:
    f.write(out.decode('base64'))

img = Image.open('shades_out_6.png')
p = img.load()
w, h = img.size
out = ''
for y in range(h):
    for x in range(w):
        out += chr(p[x, y][0])
with open('shades_out_7.png', 'wb') as f:
    f.write(out.decode('base64'))

img = Image.open('shades_out_7.png')
p = img.load()
w, h = img.size
out = ''
for y in range(h):
    for x in range(w):
        out += chr(p[x, y][0])
with open('flag.txt', 'wb') as f:
    f.write(out.decode('base64'))

with open('flag.txt', 'rb') as f:
    print f.read()

And the flag is: tjctf{asc11_c0l0r_inc3pt1on}