iwasiblog

イワシブログ - Activity log of an iwasi -

Hack.lu CTF 2015 Writeup

先日のHack.lu CTF 2015でゴルフをしていたのでWriteupを書く.

  • Agenda
    • Perl Golf (Coding 75(+50)pts)
    • PHP Golf (Coding 75(+70)pts)

Perl Golf (Coding 75(+50)pts)

Johnny B. Krad from your local schoolyard gang thinks that you are a poser! The stuff you solved until now was just luck. He bets that you are not able to beat him in Perl golf.
Link

  • Goal

Write a Perl program that takes a parameter as input and outputs a filtered version with alternating upper/lower case letters of the (english) alphabet. Non-letter characters have to be printed but otherwise ignored.

  • Example

Input Hello World! Hallo Welt!
Output HeLlO wOrLd! HaLlO wElT!

  • Rules

You have 1 second.
You have 45 (ASCII) chars.
Do not flood the server.

45文字以内で文章を指定のフォーマットに変換するコードを書く.
変換する対象の文章はいくつか種類があり,試行のたびに変わる.
どれか一つでもちゃんと変換できれば良いので以下のコードを書いた.

$ARGV[0]=~s/(\pl(\w|.{2}))/\u\1/g;print@ARGV

Flag : flag{chosingaflagisthemostdifficultpart}

PHP Golf (Coding 75(+70)pts)

Johnny B. Krad from your local schoolyard gang still thinks that you are a poser! Even if you could beat him in Perl golf, you probably can't in PHP golf...
Link

  • Goal

Write a PHP program that takes a parameter as input and outputs a filtered version with alternating upper/lower case letters of the (english) alphabet. Non-letter characters have to be printed but otherwise ignored.

  • Example

Input Hello World! Hallo Welt!
Output HeLlO wOrLd! HaLlO wElT!

  • Rules

You have 1 second.
You have 62 (ASCII) chars.
Do not flood the server.

同じく65文字以内で最低一つの文章を正しく変換できるコードを書く.

<?=preg_replace("/(\pL.*?\pL)/e","ucfirst('$1')",$argv[1]);

Flag : flag{perlgolfisbetter}