News:

Come Chat with us live! Learn how HERE!

Main Menu

Steganography

Started by EggOfAwesome, August 29, 2016, 08:01:40 PM

EggOfAwesome

I've recently been messing around with steganography. Can anyone find the message in these colours?

kaziorvb

Signatures are displayed at the bottom of each post or personal message. BBCode and smileys may be used in your signature.

EggOfAwesome

If I'm reading that right, it says:
Hi. I bet you must be pretty suprised that someone actually decided to decode your message. In fact, I couldn't help myself and had to write a Python script to easily do the encoding and decoding. Take care!

To you, I reply:

Aelita

#3
I'm gonna pick a nit here, this isn't strictly steganography since the message isn't embedded in the picture, it IS the picture. You're just doing some funky encoding ;)

Here's my implementations

Decoder:
#!/bin/bash
FILE="$1"
DIMS="$(identify $FILE | awk '{print$3}')"
DIM_X="$(($(echo $DIMS | awk -Fx '{print$1}') - 1))"
DIM_Y="$(($(echo $DIMS | awk -Fx '{print$2}') - 1))"

for cp_y in $(seq 0 $DIM_Y); do
  for cp_x in $(seq 0 $DIM_X); do
    PIX_VAL="$(convert $FILE -format '%[pixel:p{'${cp_x}','${cp_y}'}]' info:)"
    C1="$(echo $PIX_VAL | awk -F, '{print$1}' | tr -d 'srgb(')"
    C2="$(echo $PIX_VAL | awk -F, '{print$2}')"
    C3="$(echo $PIX_VAL | awk -F, '{print$3}' | tr -d ')')"
    test -n "$C1" && test -z "${C1//[0-9]}" && awk 'BEGIN{ printf"%c",'$C1'}'
    test -n "$C2" && test -z "${C2//[0-9]}" && awk 'BEGIN{ printf"%c",'$C2'}'
    test -n "$C3" && test -z "${C3//[0-9]}" && awk 'BEGIN{ printf"%c",'$C3'}'
  done
done

echo


Encoder: call as ./enc "filename" "Message to encode in image" - will choose random dimensions for output image & pads tail with black pixels

#!/bin/bash
DEST="$1"
MESSAGE="$2"

MSG_LEN="$(($(echo -n $MESSAGE | wc -c) / 3))"
MSG_LEN_HALF="$((MSG_LEN / 2))"
DIVISORS=()

for i in $(seq 2 $MSG_LEN_HALF); do test "$((MSG_LEN_HALF % $i))" -eq 0 && DIVISORS+=($i); done

DIM_X="${DIVISORS[$RANDOM % ${#DIVISORS[@]}]}"
DIM_Y="$((MSG_LEN / DIM_X))"
DIMS="${DIM_X}x${DIM_Y}"

# creates the base image
convert -size $((DIM_X + 1))x${DIM_Y} xc:black $DEST

CUR_X=0
CUR_Y=0

while IFS='' read -n3 CHUNK; do
  PIX_R=$(printf '%d' "'${CHUNK:0:1}")
  PIX_G=$(printf '%d' "'${CHUNK:1:1}")
  PIX_B=$(printf '%d' "'${CHUNK:2:1}")

  convert $DEST -fill "rgb(${PIX_R},${PIX_G},${PIX_B})" -draw "color ${CUR_X},${CUR_Y} point" $DEST

  ((CUR_X++))
  if [ "${CUR_X}" -gt "${DIM_X}" ]; then
    CUR_X=0
    ((CUR_Y++))
  fi
done <<< "$MESSAGE"

exit

Tr3m