Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vijayanandrp/ee37a809f9437dbf22fbe58618b5acff to your computer and use it in GitHub Desktop.
Save vijayanandrp/ee37a809f9437dbf22fbe58618b5acff to your computer and use it in GitHub Desktop.
Write up for InCTF 2014 - Stegnography 400 solved using python
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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment