2幎åãç§ã¯CodeFestã«ã³ãã¡ã¬ã³ã¹ã§ãPentest on steroidsã ããã»ã¹ãèªååããŸãããšããã¬ãŒã³ããŒã·ã§ã³ãèšäºãšããŠæžãçŽããŸããã ä»å¹Žãç§ã¯éåžžã«åãã§äŒè°ã«åå ãããBlackBoxã¯ã©ã€ã¢ã³ã/ãµãŒããŒAPIã»ãã¥ãªãã£ãã¹ãããšãããããã¯ã§è¬æŒããŸãããæããã«äŒçµ±ãšããŠãã¹ããŒããèªã£ãŠããŸãã
APIã®è匱æ§ãèŠã€ãããŸããã çå®ã¯ã
äœèšã£ãŠãã®ïŒ
APIã«ã€ããŠè©±ããŸãããAPIã¯ç°ãªãå ŽåããããŸã-ãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ããµã€ãããã¹ã¯ãããããã°ã©ã ã®APIã§ãããå°ãªããšãäœãã§ãã ã€ãŸããAPIã¯ç¹å®ã®ã¡ãœãããä»ããŠäœãã®ã¡ãœããïŒããšãã°ãOSã®å Žåããã¡ã€ã«ã«æžã蟌ãïŒã«ã¢ããŒã«ããŸãã ãããŠãå«ããã¡ã€ã«ã®èµ·åã ã³ãã³ãã®çµæã¯å®å šã«ç°ãªããŸãããéçºã®èŠ³ç¹ãåæ§ã®æ¹æ³ã§ïŒOS APIã¡ãœãããä»ããŠïŒçºçããŸãã Webãã¯ãããžãŒã§ã¯ãå€ãã®äººããããžã§ã¯ãçšã®APIãå®è£ ããŠããŸããæã§æäœããå Žåã¯ããœãŒã·ã£ã«ã«ã¡ãã»ãŒãžãéä¿¡ã§ããŸãã ãµã€ãã«ã¢ã¯ã»ã¹ããŠãããã¯ãŒã¯ãæ§ç¯ããããç¹å¥ãªHTTPãªã¯ãšã¹ããäœæããŠãããã¯ãŒã¯ãæ§ç¯ã§ããŸãã ãŸãããã®ãããªæ©èœã®ä»£æ¿äœ¿çšãå®è£ ãããšãã»ãã¥ãªãã£ãšã©ãŒãçºçããŸãïŒä»ã®å Žæãšåæ§ïŒã ãã®èšäºã§ã¯ãWebãããžã§ã¯ãã«åæ§ã®æ©èœãå®è£ ããéã®ç¹å®ã®ãšã©ãŒã«ã€ããŠã®ã¿èª¬æããŠããŸãã
ã€ã³ã¿ãŒãã§ã€ã¹ããAPIã¡ãœãããž
YouTubeã§ã¯ãåºãç¥ãããŠããŸããããAPIã®è匱æ§ãåæããŸãã YouTubeã§ã¯ãã€ã³ã¿ãŒãã§ãŒã¹ããã®ã¹ãã·ã£ã«ã®äœ¿çšãçŠæ¢ããŠããŸãã ã¯ãªããã®ã¿ã€ãã«ã«ãã<and>ïŒhtmlã¿ã°ãXSSæ»æã«å¿ èŠïŒãªã©ã®æåã ãããïŒ APIãèŠã€ããŠãåããããªã®ååãå€æŽããããšãããšããã¹ãŠãæåããŸãã ãã®çµæãããããxssã¯youtubeããŒãžã§å®è¡ãããŸããã§ããã ããããããã¯Gmailãžã®æçŽã§å®è¡ãããŸããïŒãããªä»ãã®æçŽãå°çãããšãïŒãããã¯ããã«éèŠã§ãã
çµè«ã¯ïŒ è«ççã«-åé¡ã¯ããŸããŸãªæ¹æ³ã«ãããŸãã ãããããªããããèµ·ãã£ãã®ãã¯ãã£ãšèå³æ·±ã質åã§ãã ããã§ã¯ã以äžã匷調ããŸãã
- ã»ãšãã©ãã¹ãŠã®å€§èŠæš¡ãªãããžã§ã¯ãã¯OOPãšMVCã®ãããªãã¿ãŒã³ã䜿çšããŸãã ãŸããAPIã®å®è£ ã¯ãã€ã³ã¿ãŒãã§ã€ã¹ã®ã¡ãœããããåçŽã«ç¶æ¿ãããã®å¶éããã¹ãŠåãé€ãå¿ èŠããããŸãã é¡äŒŒãŸãã¯é¡äŒŒã®ãã³ãã¬ãŒãã§ãããã¡ãœããããŒãããäœæãããïŒãã³ã»ã³ã¹ïŒèª°ãç¥ã£ãŠããïŒããã€ã³ã¿ãŒãã§ãŒã¹ã®ã«ã¹ã¿ã ãããã¯ãã§ããããšãæå³ããŸãã
- ã«ã¹ã¿ã ããã¯ïŒ ãã¡ãããéçºè ã®åé¡ã ããããããŒã ãªãŒããŒã§ããããããã©ãã§äœãå®è£ ããå¿ èŠãããããéçºè ã«åžžã«éç¥ããå¿ èŠããããŸãã ã€ãŸã ãã¹ãŠã®æ°žé ã®ã¹ã¬ãããæ確ã«ç解ããïŒéçºããã»ã¹ã®ã©ãã§ããŒã¿ãæ€èšŒãããïŒã¢ãã«ããµãŒãã¹ãã³ã³ãããŒã©ãŒããã®ä»ïŒã ãããã¯éçºã§è€éãªãã¿ãŒã³ã䜿çšããåé¡ã®çµæã§ãããtimlidã¯éåžžç解ããŠããŸããéçºè ã¯ãããžã§ã¯ãã®æ€èšŒã®äžéšã«ãå¥ã®å Žæã«ãå°éããŸããã APIã¯æ£ããç¶æ¿ãããŠããŸãããè匱æ§ããããŸãã
ãã¹ã¿ãŒã«ââãšã£ãŠã¯ã©ãã§ããïŒ
- ã€ã³ã¿ãŒãã§ã€ã¹ïŒãã®å¶éïŒã«ã€ããŠç¥ã£ãŠãããã¹ãŠãå®å šã«å¿ããŠããããžã§ã¯ããæåãããã¹ãããå¿ èŠããããŸãã
- ãã©ã¡ãŒã¿ãŒã®å€æŽã確èªããŸããããã¯ãFaceBookã«é¢ããç»é¢ã䜿çšããé®®æãªäŸã§ããã€ã³ã¿ãŒãã§ã€ã¹ããã¯éä¿¡è IDã眮ãæããããšã¯ã§ããŸããã§ããããAPIããã¯ã§ããŸããã
- sqli / xssãªã©ã®ãæšæºãæ»æã確èªããŠãã ããã
- èªåãã¹ããããå Žåãããã¯ã¯ãŒã«ã§ãã testValue1ãªã©ã®æšæºãã€ããŒãã 'ã "ã>ã<ãªã©ã®ããŸããŸãªç¹æ®æåã«çœ®ãæããŠãããããäžèŽãããããšãã§ããŸãïŒXSSãæ¢ããŸãïŒã
å§çž®
å€ãã®å Žåãã¢ãã€ã«ããã€ã¹ã§äœ¿çšããAPIã®éçºãéå§ãããŸãã ãŸããå®è£ ããå Žåã¯ãéä¿¡ããåã«ããŸããŸãªå§çž®ãè¿œå ããåãå ¥ããåŸã«è§£åããŸãã ãŸããZIPç匟ã®ãããªå€ãã²ããçãããæ»æïŒããŸããŸãªãã¡ã€ã«ãã¹ãã£ã³ã°ãµãŒãã¹ã圌女ã«ä»ãå ããŸããïŒããããŸãã åé¡ã¯ãé梱æã«42 kbã®ã¢ãŒã«ã€ãã«å°éã§ãããµã€ãºã¯ã©ããããã§ããïŒ 4.5ãã¿ãã€ã ã ãã¡ããšãã¡ãããããŠã³ããŒãããŠãã ãã ã äžçªäžã®è¡ã¯åçŽã§ã-ãŒãã§æºãããããã¡ã€ã«ãäœæãããå§çž®ãããŸãã ãããã£ãŠãå§çž®ããŸãã¯ããã解åã¯å±éºãªããšã§ãã泚æããŠãã ããã
ã€ãŒãã«ã»ãžã§ã€ãœã³
APIã¯ãšã³ããŠãŒã¶ãŒã ãã§ãªãããããžã§ã¯ãå ã§ããŒã¿ãéä¿¡ããããã«æäŸãããããšããããŸãã ããã¯å€ãã®å Žåãç°ãªããã¡ã€ã³ãæã€å€§èŠæš¡ãªãµã€ãã§èŠãããŸãã ãããŠã©ãããããããã¯ã©ã€ã¢ã³ãåŽã§ãã¡ã€ã³éã§ããåãããå¿ èŠããããããã§JSONPãå©ãã«ãªããŸãã ããã¯ããã¡ã€ã³1ã«å¿ èŠãªJSONããããã³ãŒã«ããã¯ã«ãªããŸãã ãã¡ã€ã³1ã«ã¢ã¯ã»ã¹ãããšããŠãŒã¶ãŒã¯Cookieãéä¿¡ããŸãããŠãŒã¶ãŒãæ¿èªãããŠãããã©ããã確èªããå¿ èŠãªããŒã¿ãæäŸã§ããŸãã 2çªç®ã®ãã¡ã€ã³ã§ã¯ãåæ§ã®JSãæ¿å ¥ãããŸã
<script type="application/javascript" src="http://server1.example.com/api/getUserInfo?jsonp=parseResponse"> </script>
parseResponseé¢æ°ãæ¢ã«å®çŸ©ãããŠããŸãã ããããèå¿ãªã®ã¯ãæ»æè ããã®ã¹ã¯ãªãããèªåã®ãã¡ã€ã³ã«è²Œãä»ããŠãã³ãŒã«ããã¯ãå€æããæå³ã®ããããŒã¿ãããå Žåã¯ããããäœããã®æ¹æ³ã§äœ¿çšã§ããããšã§ãã ãã®ãããªè匱æ§ã®åªãã䜿çšäŸã¯ãèšäºãFighting Anonymityãã«ç€ºãããŠããŸãã
æå·å
APIã«ã€ããŠè©±ããšã圌ãã¯ããã«ãªã¯ãšã¹ãã«çœ²åããŸãã APIãžã®ã¢ã¯ã»ã¹ã¯å€ãã®å ŽåãããŸããŸãªãŠãŒã¶ãŒã«çºè¡ãããããããŠãŒã¶ãŒã®èå¥ã¹ããŒã ãå¿ èŠã§ãã ãããŠãã»ãšãã©ã®å Žåã圌ãã¯æ¬¡ã®ã¹ããŒã ã䜿çšããŸããããããã«ç¬èªã®APIããŒãäžããããéçºè ã¯ãã®ããŒã䜿çšããŠãªã¯ãšã¹ãã«çœ²åããŸãã
sign = sha*(... + DATA + ...)
ããŒã¿-çç¥èšå·APIããŒã®ä»£ããã«éä¿¡ããããŒã¿ã
ãããŠåé¡ã¯ãããŒãã©ãã«çœ®ãããå·Šãå³ãã§ãã å³åŽã®ã¿ ïŒåæ§ã®éåžžã«äžè¬çãªã¹ããŒã ã䜿çšããŠãªã¯ãšã¹ãã«çœ²åããããšã«ã€ããŠè©±ããŠããïŒã ãªãã§ïŒ åç·å»¶é·ã«æ»æããããŸãã ããèŠãŠã¿ãŸãããã
ããŒã¿ãA = 1ïŒB = 2ïŒC = 3ã§ããã眲åã07ce36c769ae130708258fb5dfa3d37ca5a67514ã§ããã眲åãééã£ãã¹ããŒã sign = sha1ïŒKEY + DATAïŒã«ãããšããŸãã
ãããŠä»ãç¶æ³ïŒèª°ããã¯ã©ã€ã¢ã³ããããµãŒããŒãžã®ãªã¯ãšã¹ãã1ã€ã ãååãããªã¯ãšã¹ãå ã®ããŒã¿ãå€æŽãããã®ã§ãããæ°ãã眲åãå¿ èŠã§ããã眲åã®ããŒã¯éä¿¡ãããŸããïŒè«ççã§ãïŒã 圌ã¯äœãç¥ã£ãŠããŸããïŒ å ã®ããŒã¿ãšãã®çœ²åã èŠããã«ãè¡ã®æ¡åŒµãäœæããŠïŒããŒã¿ãè¿œå ããïŒãå é ã®Nãã€ããç¥ããªããŠãæ°ãã眲åïŒããã·ã¥ïŒãäœæããæè¡çãªå¯èœæ§ããããŸãã å®éã«ã¯ãå é ãããã·ã¥ããããšãã«Nãã€ãã®ã€ã³ãã³ããèšå®ãããæ°ããããŒã¿ã¯ã A = 1ïŒB = 2ïŒC = 3 \ x80 \ x00 \ x00 ... \ x02ïŒC = 4ã®ããã«ãªããŸãã ã©ãã§
- A = 1ïŒB = 2ïŒC = 3-åæããŒã¿
- \ x80 \ x00 \ x00 ... \ x02-ç¹å¥ã ããã·ã¥æã®ã€ã³ãã³ãïŒçœ²åã®ããŒïŒã®ãã€ã
- ïŒc = 4-æ°ããããŒã¿
åããã©ã¡ãŒã¿ãŒïŒPHPãªã©ïŒãéä¿¡ããå Žåã2çªç®ã®ãã©ã¡ãŒã¿ãŒã䜿çšãããŸãã ããªããæ»æããããã«å¿ èŠãªãã®ã ãã æåãã圱é¿ãäžããããšã¯ã§ããŸãã
Evilãåã¡ãŸããïŒçœ²åããéµãç¥ããªããŠãããªã¯ãšã¹ãã«çœ²åãããã©ã¡ãŒã¿ãå€æŽã§ããŸãã ãããŠãAPI VKãšMail.RUãæäœããããã®ããã¥ã¡ã³ãããã®æç²ã§ãã
VkontakteïŒsig = md5ïŒname1 = value1name2 = value2api_secretïŒ Mail.RU sig = md5ïŒuid + params + private_keyïŒ
ã芧ã®ãšãããããŒã¯å³åŽã«ãããŸãã
1件ã®ãªã¯ãšã¹ãã®çé£ã«ã€ããŠèšåããŸããã å®éã«ã¯ãããã¯æã£ãããå°ãç°¡åã§ãïŒã¹ããŒãªãŒïŒ1ã èšäº ïŒ
å®å šã§ãªãXML
誰ãããç®ç«ããªãããŒã¿åã§ããXMLã«ééãããšæããŸãã
<recipe name="" preptime="5" cooktime="180"> <title> </title> <composition> <ingredient amount="3" unit=""></ingredient> </composition> ... </recipe>
ããããXMLã®ãšã³ãã£ãã£ã«ééãã人ã¯å°ãªã
DTDã®äŸïŒ
<!ENTITY writer "Donald Duck."> <!ENTITY copyright "Copyright W3Schools.">
XMLã®äŸïŒ
<author>&writer;©right;</author>
ããã«ãããäœããå®çŸ©ããŠããåå©çšã§ããŸãã äžèšã®äŸã¯åãªãæååã§ãã
å€éšã®XMLãšã³ãã£ãã£ã«åºãããã人ã¯ããã«å°ãªããªããŸãã...
<!DOCTYPE foo [ <!ELEMENT foo ANY > <!ENTITY xxe SYSTEM "file:///etc/passwd" >]> <foo>&xxe;</foo>
å€éšã®äœããããŒã«ã«ãã¡ã€ã«ãhttpçµç±ã®å€éšãã¡ã€ã«ãªã©ããšã³ãã£ãã£ãšããŠæ©èœããŸãã ã€ãŸã ããã¯æšæºã§ãã æåã¯ãè¯ãç®çã§èããããŠããŸãããããšãã°ãXMLãã¯ã©ã€ã¢ã³ãã«æž¡ããçŸåšã®æéãå¥ã®ãµãŒããŒïŒHTTPçµç±ã§ã¢ã¯ã»ã¹å¯èœãªå¥ã®xmlãã¡ã€ã«ïŒããååŸããå¿ èŠããããŸãã
é·ãè°è«ããªããã°ããã®è匱æ§ã¯æããã§ãã ããŸããŸãªã©ãããŒã®äœ¿çš-ãã¡ã€ã«ïŒ///ãhttpïŒ//æ»æè ã¯ã·ã¹ãã ããããã¯ãŒã¯ãªã©ã«é¢ããæ å ±ãåãåãããšãã§ããŸãã ããã«ãããã³ãã³ãã®ãªã¢ãŒãå®è¡ãè¡ãããå ŽåããããŸããããšãã°ãPHPã«ã¯expectïŒ//ã©ãããŒããããæåã«OSã§ã³ãã³ããå®è¡ãããã®çµæãè¿ããŸãã ãã®ãããããã©ã«ãã§ã¯ããã¹ãŠã®æšæºXMLããŒãµãŒããã®æ»æã®åœ±é¿ãåããŸãã ãã®æ¹æ³ã®1ã€ã¯ãå€éšãšã³ãã£ãã£ã®ãµããŒããç¡å¹ã«ããããšã§ãã ãã®åŸãæ»æè ã¯XMLç匟ã䜿çšã§ããŸãã
<?xml version="1.0"?> <!DOCTYPE lolz [ <!ENTITY lol "lol"> <!ELEMENT lolz (#PCDATA)> <!ENTITY lol1 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;"> <!ENTITY lol2 "&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;"> <!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;"> <!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;"> <!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;"> <!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;"> <!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;"> <!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;"> <!ENTITY lol9 "&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;"> ]> <lolz>&lol9;</lolz>
ãããŠããµãŒããŒãã眮ããã äžçªäžã®è¡ã¯ããšã³ãã£ãã£ããšã³ãã£ãã£ã«åžžã«è»¢éããããšã§ãã
ããã¯ãµãŒããŒã ãã§ãªãã¯ã©ã€ã¢ã³ãã®åé¡ã«ããªãåŸãããšãèŠããŠãã䟡å€ããããŸãïŒããšãã°ãã¯ã©ã€ã¢ã³ãã欺ããœãããŠã§ã¢ãXMLã解æãããªã©ïŒã
ãã®è匱æ§ã䜿çšããæãé¡èãªäŸã¯ã2013幎11æã«çºçããFaceBookããã¯ã§ãã ãOSããã®ã³ãã³ãã®å®è¡ã«ã€ãªããå¯èœæ§ããããŸãã
èŠçŽãããšïŒ
- ãŸããã€ã³ã¿ãŒãã§ã€ã¹ã®ãã¹ãŠã®ãèå³æ·±ããå¶éããã¹ãããŸãã
- å§çž®ã«å¯ŸåŠãã;
- JSã³ãŒã«ããã¯ãããèŠãŸãã
- æå·åã ããã¯ãåç·æ¡åŒµã«å¯Ÿããæ»æã ãã§ãªãã匱ãïŒããšãã°ãçãïŒããŒããŸãã¯äœããã®åœ¢ã§äºæž¬å¯èœãªãã®ã§ããããŸãã
- ãŸããã¢ãã€ã«ã¢ããªã±ãŒã·ã§ã³APIã«åçŽã«æ¥ç¶ãããããŒã¿ãèŠã€ããããšãã§ããŸãã ãšããã§ã圌ãã¯ãµãŒãã¹http://hackapp.comãä»ããŠèŠã€ããããšãã§ããŸãã
- XML-XXE
- ãã以å€ã
ãã¬ãŒã³ããŒã·ã§ã³ïŒ
ãã¢ãããªã®sha paddingãšXXEïŒ
upd 25/04/0214ïŒã¬ããŒãã®èšé²