I have an image with a hidden message (Steganography), and my only clue of finding out what the hidden message is, a hint which said: "LSBit Steganography Over Triangular Series". My intuition thought that the message is hidden within the least significant bit on every pixel who's value is one of the triangle series (0,1,3,6,10,15...) but I guess I was wrong since I didn't have a readable message. I post my code for example of what I tried to do:
import numpy as np
from PIL import Image,ImageEnhance
import itertools
def messageToBinary(message):
return format(message,"08b")
def triangle_series():
k = 0
for i in itertools.count(1):
if k>=300:
break
yield k
k += i
def getDataOfImage():
im = Image.open('challenge.bmp')
d = im.getdata()
a = np.array(d, dtype=np.uint8)
# a = a.reshape(d.size[::-1])
return a
def getTriangleSeries():
ts_lst = [k for k in triangle_series() ]
return ts_lst
def dataToBits(pixels):
bits = ''
series_lst= getTriangleSeries()
for pixel in pixels:
if pixel in series_lst:
bits+=messageToBinary(pixel)[-1]
return bits
def bitsToBytes(bits):
bytes = []
for i in range(len(bits)//8):
bytes.append(bits[i*8:(i+1)*8])
return bytes
def bytesToChars(bytes):
decoded_data = ""
for byte in bytes:
decoded_data += chr(int(byte , 2))
return decoded_data
pixels = getDataOfImage()
bits = dataToBits(pixels)
bytes = bitsToBytes(bits)
decoded_data = bytesToChars(bytes)
print(decoded_data)
The grey scale image with the hidden message:
The original image in bmp can be found in this link: https://drive.google.com/file/d/1LCqyk0dRytNAEi-7ql_gBWRGkCYgfa1Z/view If someone solves it and willing to post the answer I'd be most grateful.