InCTF 2014 - Stegnography 400

Give an image, the flag is hidden in the Blue plane.
import os,sys
import Image

modi_bin = Image.open("modi.png").convert('RGB')

bin = ''

R = open('r.txt','w')
G = open('g.txt','w')
B = open('b.txt','w')

# By Analysing the text docs I found blue Plane First column is embedded with data 
flag = ''
flag1 = ''

for h in range(modi_bin.size[1]): # Fetches Height
 count = 0
 binR = ''
 binG = ''
 binB = ''
 
 for w in range(modi_bin.size[0]): # Fetches Width
  count += 1
  binR += str(modi_bin.getpixel((w,h))[0] & 1)
  binG += str(modi_bin.getpixel((w,h))[1] & 1)
  binB += str(modi_bin.getpixel((w,h))[2] & 1)
  if w == 0: # blue plane first bit 
   flag += str(modi_bin.getpixel((w,h))[2] & 1)
  if count == 8:
   R.write(binR)
   G.write(binG)
   B.write(binB)
   binR=' ';binG=' ';binB=' '
   count = 0
 R.write(binR+'\n')
 G.write(binG+'\n')
 B.write(binB+'\n')


print flag

flag_value = [ str(int(i)^1) for i in flag]

flag = ''.join(flag_value)

print ''.join(chr(int(flag[i:i+8], 2)) for i in xrange(0, len(flag), 8))

1010010010111001101100111011111010111000110111111100010111011111100100101100111110011011110011101010000010001011100101111011101010100000101100011001101010101000101000001010111110010010101000101101111110100100101110011011001110111110101110001101111111000101110111111001001011001111100110111100111010100000100010111001011110111010101000001011000110011010101010001010000010101111100100101010001011011111101001001011100110110011101111101011100011011111110001011101111110010010110011111001101111001110101000001000101110010111101110101010000010110001100110101010100010100000101011111001001010100010110111111010 

 [FLAG : m0d1_thE_NeW_Pm] [FLAG : m0d1_thE_NeW_Pm] [FLAG : m0d1_thE_NeW_Pm]

Comments

Popular posts from this blog

Python Speech recognition for Mac OS X

Baby Step Giant Step Algorithm Python Code

Simple Automation using Python - Atomac in Mac OS X