Tags: stego 

Rating: 5.0

With challz, each RGB pixel in the figure corresponds to hex code. Example RGB :` (137 ,80,78)` is equivalent to hex code `89504E` . It can be checked [here](https://htmlcolorcodes.com/).

And this hex code value could be equivalent for hex codes of other formats. For this challenge it is the format for another image file.

So we need to find the RGB code that starts for the signature of an image file. Then extract the next hex codes until the image file end sign is met.

This is my code solving:
#usage : python3 sol.py
from PIL import Image
from colormap import rgb2hex
import re
import binascii

rex = "89504E.*AE426082"
new_im = "89504E"
wp = open("flag.png","wb")
an_image = Image.open("pip.png")
sequence_of_pixels = an_image.getdata()

sequence_of_pixels = an_image.getdata()
list_of_pixels = list(sequence_of_pixels)

wr = False
for item in list_of_pixels:
if wr == True:
hex_ = rgb2hex(item[0], item[1], item[2])
new_im += hex_
# finding start hex code for image
if str(item[0]) == "137" and str(item[1]) == "80" and str(item[2]) == "78":
wr = True

new_im = new_im.replace("#","")
new_im = re.findall(rex,new_im)
#get hex code correct with format of image
data = binascii.a2b_hex(new_im[0])


NightNashoFeb. 22, 2021, 10:16 p.m.

Could you explain why there is "AE426082" part in the rex?

DangKhaiFeb. 23, 2021, 8:12 a.m.

This is a byte `*IEND*` , end of image. rely on it to remove the trailing 00 bytes!