ã»ãã¥ãªãã£ï¼ããã°ã©ãã³ã°ãã£ã³ããRubyã®ãã°ãæ¢ããåé¡
ããã¯ã»ãã¥ãªãã£ï¼ããã°ã©ãã³ã°ãã£ã³ãã®CTF競æ(ã¿ã¤ã ãã©ã¤ã¢ã«ã®ãã¼ã æ¦)ã§åºé¡ãããåé¡ã§ããRubyå¦çç³»ã¸ã®ãã°ã®ä»è¾¼ã¿ã¨åé¡æã®å稿ãåãæ¸ãã竹迫ããã競æç°å¢ã§å®è¡ããããã®èª¿æ»ãå çãè¡ã£ã¦ããã¾ãããåå è ã®Shota Fukumori (sora_h)ãã21æ¥ã«ãã»ããã£ã³è¡ã£ã¦ãããã¼ã¯ãããããæ©ãå ¬éãããã¨ããã®ã§ãåãæ¥ãå ¬éãã¾ãã
åé¡æ
ããã¯ããã°ã©ãã³ã°è¨èªã¯ã©ã¹ã§ã®ã¿ã¤ã ãã©ã¤ã¢ã«å¦çç³»ãããã°æ¼ç¿ã®ããã«ä½ãããããã°ã®æ··å ¥ãã¦ããRubyå¦çç³»ã®ã½ã¼ã¹ã³ã¼ãã§ããCè¨èªã§æ¸ããã¦ãã¾ãã誰ãçæããªãã£ããveryhardãã®åé¡ãªã®ã§ã解説ãå çãã¦CTFã®åé¡ã¨ãã¾ãã
è¨èªã¯ã©ã¹ã§ã¯Rubyå¦çç³»ã®ãã«ãã®ä»æ¹ããã¹ãã®ããã®ãã¼ã«ã2æ¥ç®ã«æ¼ç¿ãã3æ¥ç®ã®æã«ã1æéã§8åã®ãã°ãæããé ã«åãæ¼ç¿ã(ã¿ã¤ã ãã©ã¤ã¢ã«å¦çç³»ãããã°)ãããã¾ãããæ¼ç¿ãåãã¦ããªã人ã§ãçæã§ããããã«ãRubyã®ãã«ãæ¹æ³ãæ¹ãã¦æ¸ãã¦ããã¾ãã
$ mkdir build $ cd build $ ../configure --disable-gems --disable-install-docs $ make
ããã§æ¬æ¥ã¯makeã«æåããã¯ãã§ãããrubyã³ãã³ãããã«ããããå¾ãRubyã«ãã°ãå ¥ã£ã¦ããããmakeä¸ã«èªåã§èµ°ãmake testã失æãã¾ãã
$ make /.../veryhard/lib/fileutils.rb:1399:in `quote': can't convert NilClass to String (TypeError) from /.../veryhard/lib/fileutils.rb:1399:in `<class:Entry_>' from /.../veryhard/lib/fileutils.rb:1092:in `<module:FileUtils>' from /.../veryhard/lib/fileutils.rb:85:in `<top (required)>' from ../tool/mkconfig.rb:11:in `require' from ../tool/mkconfig.rb:11:in `<main>' make: *** [.rbconfig.time] Error 1
make runãmake gdbã使ãã¨(src)/test.rbãå®è¡ããã¾ããèªåã§å¥½ããªå 容ãtest.rbã«æ¸ãã¦make runãã¦ã¿ã¦ãã ãããã§ããã®ãã°å ¥ãå¦çç³»ã¯ãªã«ãã常èçã«èãã¦ããããã ããããã¨ããæåãããã¯ããªã®ã§ãåå ã¨ãªããã°ãè¦ã¤ãåºããå¦çç³»ãæ£ããåãããã«Cã§æ¸ãããã³ã¼ããä¿®æ£ãã¦ãã ããã
æ·»ä»ããtest.rbã¯ããããªæåã®ä¸ã¤ã®ä¾ã¨ãã¦ãä¸è¨ã®ããã«ãç´ æ°ãè¨ç®ãããã¨ãã¦Thread.rbãã¨ã©ã¼ãåããã¨ããæå³ä¸æãªãã®ã«ãã¦ããã¾ãããããtest.rbã¯ããã°ãåç¾ããããã®æå°éã®ã³ã¼ããã«ããæ¹ãããã§ãããã
$ make run ./miniruby -I../lib -I.ext/common -I./- -r../ext/purelib.rb ../test.rb /.../veryhard/lib/thread.rb:11:in `<top (required)>': Thread not available for this ruby interpreter (RuntimeError) from /.../veryhard/lib/singleton.rb:63:in `require' from /.../veryhard/lib/singleton.rb:63:in `<top (required)>' from /.../veryhard/lib/prime.rb:14:in `require' from /.../veryhard/lib/prime.rb:14:in `<top (required)>' from ../test.rb:1:in `require' from ../test.rb:1:in `<main>' make: *** [run] Error 1
ãã®Rubyå¦çç³»ã®ãã°ãç´ãããã«ä¿®æ£ãããã¹ããã¡ã¤ã«åã¨è¡çªå·ãåçãã¦ãã ããããã¨ãã°spcamp.cã®2403è¡ç®ã§ããã°ãspcamp.c:2403ããåçã¨ãªãã¾ãã2è¡ä»¥ä¸ã®ä¿®æ£ãå¿ è¦ãªå ´åã¯ãä¿®æ£ãéå§ããè¡ç®ãåçã¨ãã¦ãã ããã
ãªããVMç°å¢ã§èµ°ããã¦ãããã¨ãªã©ãåå ã§gcå¨ãã§ã®ãã¹ãã«ã³ã±ããã¨ãããã¾ãããããã¯ãã®èª²é¡ã®æå³ãããã®ã§ã¯ããã¾ãããã¾ãmakeããrubyãmake installããªãã§ä½¿ãã¨gems(ããã±ã¼ã¸ç®¡ç)å¨è¾ºã§ã³ã±ããã¨ãããã¾ããããããæå³ãããã®ã§ã¯ããã¾ããã
â»BackTrack 4 Live CD (Ubuntu8.10) ã§ãã«ãã§ããããã«ãã¦ãã¾ãã
ãã¡ã¤ã«
ä½è«
大éæã«è¨ã£ã¦ã10å以å ã«è§£ãããmoriyoshiç´ã§ã10æé以å ã§è§£ãããsora_hç´ã(sora_hã¯ä»ã®åé¡ã解ãã¤ã¤6æéæãã¦è§£ããªãã£ããããã®å¾å¸°ã£ã¦ãã¦åã®ã( https://gist.github.com/1145883 )ãã¨ãããã³ããèãã¦ãã¼ã¿ã¤ã ã§ãâ¯â¯ãï¼ãã¨çããã®ã§ãªã¼ãã¼ã¨ãã¦ã¯10æéã£ã¦ãã¨ã§ããããªã¼ã¨ã)
ä»ã®å¤§äººã®æè¦æé:
knu:ãRubyã®ãã°ãæ¢ããã¯ã½ã¼ã¹åå¾ãã10åæãããªãã£ããããã¼ã ã ãå½ç¶ããå®éã®ãã°ã¯ãããªåç´ãããªãããªâ¦ http://twitter.com/#!/knu/status/103037840899846144
mrkn: 解ãããã©15åãããã£ã¡ãã£ããhttp://twitter.com/#!/mrkn/status/103062497954775040
znz: 40åãããã§åºæ¥ããããã°ãåç¾ããããã®æå°éã®ã³ã¼ããã¯ç°¡åã«ä½ãã¦ããç´ãã®ã¯è¦æ £ããªãã¨ããã対象ã ã£ãããæéãããã£ãã http://twitter.com/#!/znz/status/103084755758755840
ä½è«2
è¨èªã¯ã©ã¹å ã§ã®æ¼ç¿ã®éã®ãå çã®ãªãåé¡æ
å8 (å ¨é¨ã¯ãªã¢ãã人åã)
ããã§ã¨ãï¼
ããã¾ã§ã®åé¡ãã¯ãªã¢ãã¦æéãä½ã£ã¦ãã¾ã£ã人ã®ããã«ãveryhard.zipãç¨æããã¦ãã¾ãããã³ãã¯ä¸åããã¾ããã
ä½è«3
test.rbã®å 容
require 'prime' p Prime.prime? 2403
ããã¦ãã®çµæ:
/.../veryhard/lib/thread.rb:11:in `<top (required)>': Thread not available for this ruby interpreter (RuntimeError)