Skip to content

Instantly share code, notes, and snippets.

@captn3m0
Created September 26, 2015 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save captn3m0/d9cc46579ede1d27783a to your computer and use it in GitHub Desktop.
Save captn3m0/d9cc46579ede1d27783a to your computer and use it in GitHub Desktop.
Trend Micro CTF Programming 100 Challenge Solution
#!/bin/bash
ROOT='http://ctfquest.trendmicro.co.jp:43210'
URL="$ROOT/click_on_the_different_color"
function get_coord() {
IMAGE=$1
COLOR=`convert $IMAGE -define histogram:unique-colors=true -format %c histogram:info:- | head -2 | tail -1 | grep -oe '#[A-Z0-9]\{6\}'`
CORDS=`convert $IMAGE txt:- | grep "$COLOR"|head -1|cut -d ':' -f 1`
X=`echo $CORDS|cut -d ',' -f 1`
Y=`echo $CORDS|cut -d ',' -f 2`
}
function decode() {
HASH=`curl --silent $1 | grep -oe "[0-9a-f]\{44\}" | head -n 1`
echo "Hash: $HASH"
IMAGE_URL="$ROOT/img/$HASH.png"
echo "Image: $IMAGE_URL"
wget -q $IMAGE_URL -P "images/"
get_coord "images/$HASH.png"
echo "Cords: $X, $Y"
URL="$ROOT/$HASH?x=$X&y=$Y"
echo "URL: $URL"
decode $URL
}
mkdir -p "images"
decode $URL
# Once it reaches the solution, the script gives out errors. At that point, just open the last URL it found to see the flag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment