CTF challenge 2. Steganography: splitting the single "hair" into four

The enhanced version of

, based on a similar concept but harder.
And again, the flag starts with "CTF_", total length = 21.

:warning: The message is slightly volatile :warning:

Challenge project: :link: CTF_STEG.2 :link:

Spoiler

image

Oooooooh...

Spoiler

When you load the project, no stage is selected.

wrong.

Why don't you go look for your self?

Spoiler

Wrong.
image
The sprite is selected,

I did. thats how I know your wrong.

Spoiler

@helicoptur Its the stage. Look for yourself.

Time for the clues:
  1. Only the current state of the Stage is meaningful
  2. What's split can be linked together ...
  3. The title is not that random as it looks

Another bit of information. See what happens here. You should see something familiar ...
CTF_STEG.2.sol script pic (9)

That C...

If that "C" is the only thing familiarrofl
the more specific hint can be useful
CTF_STEG.2.sol script pic (10)

Solution
The main idea is to spread bits of the unicode of the letter into CTF_STEG.2.sol script pic (26) of a single pixel.

Encoding

  1. Code of the letter is splitted into 2-bit packets.
    CTF_STEG.2.sol script pic (18)
    CTF_STEG.2.sol script pic (17)
  2. With this hyperized expression, 2-bit packets are applied to rgba pixel data.
    CTF_STEG.2.sol script pic (19)
  3. Now the pixel data contains encoded letter data
    CTF_STEG.2.sol script pic (22)

Decoding

  1. Extract the two lowest bits from every element of the pixel
    CTF_STEG.2.sol script pic (20)
  2. Combine bits into a byte
    CTF_STEG.2.sol script pic (21)
  3. Abstract, whole procedure for the single pixel/letter
    CTF_STEG.2.sol script pic (25)

Complete, real decode script

:link: Project :link:

It was too hard for me I'm afraid :frowning:

So, I'm lucky that I do not teach for a living ... :wink:


I will try to explain the general idea once again. I assume that binary notation and bit manipulation is known to the reader

  1. Basic assumptions:
    encoding letter "C" , code 67 CTF_STEG.2.sol script pic (33)
    into gray pixel


    Expressed as binary:
    "C" => 67 =>
    pixel r = g = b = 100, CTF_STEG.2.sol script pic (31)
    pixel alpha=255, CTF_STEG.2.sol script pic (32)

  2. Bits of the letter "C" are spread into the lowest bits of the pixel elements

  3. Pixel elements become (binary then converted to decimal):

  4. New pixel values are stored into the original image.

It's worth noting that depending on the pixel, changes to the original image are almost invisible by the "naked eye".


My implementation of this idea is based on the observation that:
CTF_STEG.2.sol script pic (37) modulo 4, extracts the 2 lowest bits of a number
CTF_STEG.2.sol script pic (38) clears lowest bits
CTF_STEG.2.sol script pic (39) adding 0..3, sets the bits


Generally speaking, CTF_STEG.2.sol script pic (40) extracts the lowest n bits of a number.

.