ログイン
編集不可のページディスカッション情報添付ファイル
CTF/Writeup/SECCON 2014 Quals Online Winter/Choose the number

MMA

Choose the number (Programming 100pts)

配列が入力として与えられるので、その最大値あるいは最小値を答える問題。 この手の問題はスクリプト言語が強いと思う。

   1 require_relative 'ctf'
   2 TCPSocket.open('number.quals.seccon.jp' ,31337) do |s|
   3   s.echo = true
   4   while true
   5     ar = s.gets.split(',').map{|a|a.split.join.to_i}
   6     t = s.read_until /number\?/
   7     if /minimum/ =~ t
   8       s.print ar.min.to_s + "\n"
   9       s.flush
  10     elsif /maximum/ =~ t
  11       s.print ar.max.to_s + "\n"
  12       s.flush
  13     end
  14   end
  15 end

$ ruby solve.rb
...
 2373849732, 2148018807, 967760900, -2458619249, 861417957, 903212722, 1088911047, 2116907202, -1795668956, -2060248852, -1514132196, 211229153, -1734719894, -2086474216, 1925818040, -246185466, -1272210548, -1818076701, 2933317222, 2494512663, 2687488533, 2525231782, 531849719, 2279048489, 788148811, 1388455265, 573126549, -2818451841, -2234980827, 3928993570, 3957773265, 3473404644, -2833778029, 3610500361, -681318344, -3602924829, -2055146750, 1869889128, 1915628205, -3689824685, 864539215, 2180138449, -524805557, -1382914163, 4187539134, 514698030, -1139899245, 3992359201, -2739819634, -3663877914, -4173448935, 3428707288, -3700946654, 1770719263, 3932923303, -14277131, -1556777473, 1702109422, -993194067, 2436644134, 3194694465, 2257448446, 4204565891, -3882720472, 3407435621, -1926724176, -3243858876, 1190148323, -396066626, 4159502787, -1731015929, 2739026253, 57372190, -3334186190, -4244958694, 423774751, 2051784010, 2775407689, 2351965214, -1777923452, 143025071, -2883579497, 1093661225, 3301298719, -3928315830, 2175873534, 1029392770, -3555847400, -2178080903, 3405794270, 3152496133, -881122064, -4019529618, 714633952, 1051049226, -3030072125, -1793734069, 398907258, -673416299, -2091214689, 3843286998
The minimum number?-4244958694
 Congratulations!
The flag is SECCON{Programming is so fun!}

CTF/Writeup/SECCON 2014 Quals Online Winter/Choose the number (最終更新日時 2014-12-07 21:06:52 更新者 nomeaning)