Author Topic: Steganography  (Read 11873 times)

EggOfAwesome

  • Posts: 27
  • Turrets: +2/-0
Steganography
« on: August 29, 2016, 08:01:40 pm »
I've recently been messing around with steganography. Can anyone find the message in these colours?

kaziorvb

  • Posts: 234
  • Turrets: +19/-43
Re: Steganography
« Reply #1 on: October 01, 2016, 08:02:35 pm »
Cheers!
Signatures are displayed at the bottom of each post or personal message. BBCode and smileys may be used in your signature.

EggOfAwesome

  • Posts: 27
  • Turrets: +2/-0
Re: Steganography
« Reply #2 on: November 05, 2016, 05:35:06 pm »
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

  • Posts: 743
  • Turrets: +147/-34
Re: Steganography
« Reply #3 on: December 10, 2016, 03:35:09 am »
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:
Code: [Select]
#!/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
Code: [Select]
#!/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
« Last Edit: December 10, 2016, 04:29:56 am by Aelita »

Tr3m

  • Posts: 7
  • Turrets: +0/-0
Re: Steganography
« Reply #4 on: March 13, 2018, 06:13:08 am »
that's cool