ãããã¯ã¼ã¯è¨ºæã®ç¾å ´ããï¼netcatç·¨ã»ãã®2ï¼
ã¯ããã«
ä»åã¯netcatãå©ç¨ãã¦ãWebãµã¼ãã¼ã®ã¬ã¹ãã³ã¹ãããã¼ããå¾ãããæ å ±ãåéãã¦ã¿ã¾ããããã¬ã¹ãã³ã¹ãããã¼å ã«ã¯ãã¾ãã¾ãªæ å ±ãããã¾ãããããã§ã¯ãããã¼åå¾ãããã³ãå é¨IPã¢ãã¬ã¹ã®æ¼ãããã«ã¤ãã¦ç´¹ä»ãã¾ãã
ååã«å¼ãç¶ããæ¬ç¨¿ã®å®è¡ä¾ã§ã¯Linux(CentOS 6)ãå©ç¨ãã¦ãã¾ããã¾ã対象ã®Webãµã¼ãã¼ã¨ãã¦ã¯ãApache HTTP Server(以ä¸Apache)ãæ³å®ãã¦ãã¾ãã
ããã¼åå¾
ããã¼ã¨ã¯ããµã¼ãã¹ãåºåããã¡ãã»ã¼ã¸ã®ãã¡ãã½ããã¦ã§ã¢ã®å称ããã¼ã¸ã§ã³æ å ±ãå«ã¾ãããã®ãæãã¾ããå¤é¨ããããã¼ãåå¾å¯è½ãªå ´åãããã«ã¯æ»æè ã«ã¨ã£ã¦æçãªæ å ±ãå«ã¾ãããã¨ããããã注æãå¿ è¦ã§ãã
ä¾ãè¦ã¦ã¿ã¾ãããã以ä¸ã®å®è¡ä¾ã§ã¯ãWebãµã¼ãã¼ã§ããtest.example.comã®80/tcp(http)ã«netcatã§æ¥ç¶ããHEADãªã¯ã¨ã¹ããéä¿¡ãã¦ã¬ã¹ãã³ã¹ãããã¼ã確èªãã¦ãã¾ãã
$ nc test.example.com 80 HEAD / HTTP/1.0 HTTP/1.1 200 OK Date: Thu, 03 Mar 2016 05:50:45 GMT Server: Apache/2.2.19 (Unix) Last-Modified: Sat, 20 Nov 2004 20:16:24 GMT Accept-Ranges: bytes Content-Length: 44 Connection: close Content-Type: text/html $
ã¬ã¹ãã³ã¹ãããã¼å ã®ãServerãããã¼ã«æ³¨ç®ãã¦ãã ããã Server: Apache/2.2.19 (Unix) ã¨ããæååãããã¼ã§ãããããã¦ããã¼ãåå¾ãããã¨ã§ããã®ãã¹ãã§ã¯Apacheã®ãã¼ã¸ã§ã³2.2.19ãUNIXç°å¢ã§åä½ãã¦ãããã¨ãåããã¾ãã
ãã®ãããªæ å ±ã¯æ»æè ã¸ã®ãã³ãã¨ãªããããããã¼ã表示ãããªãããã«è¨å®ãã¦ã¿ã¾ããããApacheã®ããã¼ãé è½ããã«ã¯ãè¨å®ãã¡ã¤ã«(httpd.conf)ã®ServerTokensãã£ã¬ã¯ãã£ãã«ããProductOnlyãã¨ããå¤ãæå®ãã¾ãã
ServerTokens ProductOnly
ãã®è¨å®ã«ãããServerãããã¼ã®åºåããããã¯ãåã®ã¿ã«ãããã¨ãã§ãã¾ãã
ãªãProductOnlyã¯çç¥ãã¦ã以ä¸ã®ããã«ãProdãã¨ã ãæ¸ãã¦ãæ§ãã¾ãããä¸è¬çã«ã¯ãã®çç¥å½¢ãããå©ç¨ããã¾ãã
ServerTokens Prod
è¨å®ãã¡ã¤ã«ãä¿®æ£ãã¦Apacheãåèµ·åããã°ã以ä¸ã®ããã« Server: Apache ã¨ãããããã¯ãåã®ã¿ã®è¡¨ç¤ºã¨ãªããããã¼ãé è½ã§ãã¦ãããã¨ã確èªã§ãã¾ãã
$ nc test.example.com 80 HEAD / HTTP/1.0 HTTP/1.1 200 OK Date: Thu, 03 Mar 2016 05:57:11 GMT Server: Apache ....(çç¥)....
ãªãè¨å®å¤æ´å¾ãæ£ããããã¼ãé è½ããã¦ãããã確èªããéãWebãã©ã¦ã¶ãå©ç¨ãããã¨ã¯ãã¾ãããããã§ãã¾ããã
Webãã©ã¦ã¶ã§ã¯ãé常ã¯ã¬ã¹ãã³ã¹ã®ããã£é¨ã®ã¿è¡¨ç¤ºããããããã¬ã¹ãã³ã¹ãããã¼ã確èªãããã¨ãã§ãã¾ãããã¬ã¹ãã³ã¹ãããã¼é²è¦§ã®ããã«Webãã©ã¦ã¶ã«çµã¿è¾¼ãéçºãã¼ã«ãã¢ããªã³ãããã©ã¦ã¶ãã£ãã·ã¥ã®å½±é¿ã§è¨å®å¤æ´åã¨åãçµæãè¿ããæãã¬åéãããããã¨ãããããã注æãå¿ è¦ã§ãã
ä¸æ¹ãnetcatãå©ç¨ããã°çãã¼ã¿(raw data)ããã®ã¾ã¾æ±ãã¾ãããä½è¨ãªå å·¥ã¯ããã¾ãããããã©ã¦ã¶ãã£ãã·ã¥ã®å¿é ãç¡ç¨ã§ããã·ã§ã«ã¹ã¯ãªãããå©ç¨ãã¦ãã§ãã¯ãã¼ã«ãä½ããã¨ãç°¡åã§ãããã®ãããããã¼ã確èªããéã«ã¯netcatãããå©ç¨ããã¾ãã
X-Powered-Byãããã¼
Webãµã¼ãã¼ã§æ³¨ç®ãããããã¼ã¨ãã¦ã¯ãå ã»ã©ã®Serverãããã¼ä»¥å¤ã«ãX-Powered-Byãããã¼ãæãããã¾ããããã¤ãã®ã½ããã¦ã§ã¢ããã®ãããã¼ãåºåãã¾ããã主ã«PHPã®ãã¼ã¸ã§ã³æ å ±ãåå¾å¯è½ãªãããã¼ã¨ãã¦ç¥ããã¦ãã¾ãã
$ nc test.example.com 80 HEAD /list.php HTTP/1.0 HTTP/1.1 200 OK Date: Thu, 10 Mar 2016 17:00:23 GMT Server: Apache X-Powered-By: PHP/5.3.11 Connection: close Content-Type: text/html $
ä¸è¨ã®ä¾ã§ã¯ãX-Powered-Byãããã¼ã確èªãããã¨ã§ãPHPã®ãã¼ã¸ã§ã³5.3.11ãå©ç¨ããã¦ãããã¨ãåããã¾ãããªããX-Powered-Byãããã¼ã¯PHPãã¡ã¤ã«(ä¸è¨ã®ä¾ã§ã¯/list.php)ã¸ã®ã¢ã¯ã»ã¹æã«ã®ã¿è¡¨ç¤ºããããããçãããèªåã®ç°å¢ã確èªããéã«ã¯ãPHPãã¡ã¤ã«ã¸HEADãªã¯ã¨ã¹ããéä¿¡ãã¦ãã ããã
PHPã®ããã¼ã¯ãè¨å®ãã¡ã¤ã«(php.ini)ã®expose_phpãã£ã¬ã¯ãã£ãã«ããOffããæå®ãããã¨ã§é è½ã§ãã¾ãã
expose_php = Off
ãã®è¨å®ãè¡ãã¨ã次ã®ããã«X-Powered-Byãããã¼èªä½ãåºåãããªããªããããã¼ãé è½ãããã¨ãã§ãã¾ãã
$ nc test.example.com 80 HEAD /list.php HTTP/1.0 HTTP/1.1 200 OK Date: Thu, 10 Mar 2016 17:03:13 GMT Server: Apache Connection: close Content-Type: text/html $
ããã¼ã®é è½ã«ã¤ãã¦
ããã¾ã§ç´¹ä»ãã¦ããããã«ãåºæ¬çã«ããã¼ã¯é è½ãããã¼ã¸ã§ã³æ å ±ã¯å¤é¨ããåå¾ã§ããªãããã«ãããã¨ããããããã¾ãããããããã¼ãé ãã¹ããã©ããã¨ããã®ã¯æããè³å¦ä¸¡è«ãããé ããã¨ã«ã¯æå³ããªãã¨ãã主張ãããã¾ããä½ãã¨è°è«ã®ç«ç¨®ã«ãªããããããã§è£è¶³ãã¦ããã¾ãããã
ãããã¼ãé ããã¨ããã§ãå©ç¨ãã¦ããã½ããã¦ã§ã¢ã®ãã¼ã¸ã§ã³ãå¤ãå ´åãæ¬è³ªçãªã»ãã¥ãªãã£åé¡ã¯è§£æ±ºããªãã®ã ããæå³ããªããã¨ããã®ã¯ããèãããå対è«ã§ããããã¯ç¢ºãã«ãã®éãã§ãã¾ãã¯ã½ããã¦ã§ã¢ãææ°çã«ãããã¨ãåºæ¬çãªã»ãã¥ãªãã£å¯¾çã¨ãã¦éè¦ã§ãããå¤ããã¼ã¸ã§ã³ã使ã£ã¦ãããã¨ãåãããªãããã«ãããã¼ãé è½ãããã¨ããã®ã§ã¯æ¬æ«è»¢åã§ãã
ãããããã¼ãé ããã¨ã«ããã¡ãªããã«ã¯ããæ»æ対象ã¨ãã¦é¸å®ããã«ãããªããã¨ããç¹ãããã¾ãããã¨ãã°SHODAN(*1)ã«ä»£è¡¨ãããããã«ãç¹å®ã®ããã¼æ å ±ããã¤ã³ã¿ã¼ãããä¸ã«åå¨ãããã¹ããæ¤ç´¢ã§ããWebãµã¼ãã¹ã¯ã2016å¹´ç¾å¨ãæ¢ã«å¤ãåå¨ãã¾ãã
(*1) SHODAN: https://www.shodan.io/
æ»æè ãæ»æ対象ãé¸å®ããéãããã¼ãé è½ããã¦ãããã¹ãã¨ãããã¼ã表示ããããã¹ããããã°ãããã¼ã表示ããã¦ãããã¯ãåããã¼ã¸ã§ã³æ å ±ã詳細ã«åãããã¹ããæ»æ対象ã«é¸ã¶ã®ã¯èªç¶ãªæµãã§ããããã¾ãããã¼ãé è½ããã¦ããå ´åãæ¢ç¥ã®èå¼±æ§ã試ãã«ãã¦ããå½ã¦ãã£ã½ãã«æ»æãè¡ãå¿ è¦ãããå¹ççã§ã¯ããã¾ãããããã¼ãé è½ãããã¨ã§ãæ»æè ã«ããæ»ææ©ä¼ãå°ãã§ãæ¸ãããã¨ãã§ããããã§ãã
ã¾ããããããå¿ è¦ã®ãªãæ å ±ã¯ããªãã¹ãå¤é¨ã«å ¬éããªãã¨ããã®ã¯ã»ãã¥ãªãã£å¯¾çã«ããã¦åºæ¬çãªèãæ¹ã§ãããã¨ãã°ããªãã®èªå® ã®éµã®ã¡ã¼ã«ã¼ãåçªã¯ãå ¬éãã¦ãããã«ä½ãåé¡ãçããã¨ããããã§ã¯ããã¾ããããããããå¿ è¦ããªãã®ãªãå ¬éããªãã«è¶ãããã¨ã¯ãªãã§ããããããã¼ãåæ§ã§ããç©æ¥µçã«é示ããå¿ è¦ããªãæ å ±ã¯ãé è½ããæ¹ãæã¾ããã§ãããã
å é¨IPã¢ãã¬ã¹ã®æ¼ãã
Webãµã¼ãã¼ã®ã¬ã¹ãã³ã¹ãããã¼ããå¾ãããæ å ±ã¨ãã¦ãç¶ãã¦ã¯ãããã¯ã¼ã¯è¨ºæã®ç¾å ´ã§ææè¦ããããå é¨IPã¢ãã¬ã¹ã®æ¼ãããã®ä¾ãç´¹ä»ãã¾ããããããã¯ã¤ã³ã¿ã¼ãããçµç±ã§Webãµã¼ãã¼ã«ã¢ã¯ã»ã¹ããéã«ããã¹ããå é¨ã§å©ç¨ãã¦ãããã©ã¤ãã¼ãIPã¢ãã¬ã¹ãè¦ãã¦ãã¾ãã¨ããäºä¾ã§ãã
ããã§ã¯ä¾ã¨ãã¦ãã¤ã³ã¿ã¼ãããçµç±ã§test.example.comã¨ããWebãµã¼ãã¼ã«ã¢ã¯ã»ã¹ããã±ã¼ã¹ãèãã¾ããã¢ã¯ã»ã¹ããURLã¯ã http://test.example.com/img/ ã¨ãã¾ãããããã®URLã«å¯¾ãã¦ã以ä¸ã®ããã«netcatãå©ç¨ãã¦/imgã¨ãããã¹ã«HEADãªã¯ã¨ã¹ããéã£ã¦ã¿ã¾ãã
$ nc test.example.com 80 HEAD /img HTTP/1.0 HTTP/1.1 301 Moved Permanently Date: Thu, 03 Mar 2016 05:42:05 GMT Server: Apache Location: http://192.168.2.66/img/ Connection: close Content-Type: text/html; charset=iso-8859-1 $
ä¸ã®ä¾ãè¦ãã¨ãtest.example.comå®ã¦ã®ã°ãã¼ãã«IPã¢ãã¬ã¹ã«æ¥ç¶ããã®ã«ãLocationãããã¼ã« 192.168.2.66 ã¨ãããã©ã¤ãã¼ãIPã¢ãã¬ã¹ã表示ããã¦ãã¾ãããããå é¨IPã¢ãã¬ã¹ã®æ¼ããã§ãããã©ã¤ãã¼ãIPã¢ãã¬ã¹ãè¦ããããã¨ãã£ã¦ããã«ä½ãã®æ»æã«çµã³ã¤ãããã§ã¯ããã¾ããããå é¨ã®ãããã¯ã¼ã¯æ§æãæ¨æ¸¬ããããã¨ãããå¤é¨ã«å ¬éããªãæ¹ãè¯ãæ å ±ã§ãããã¨ã¯ç¢ºãã§ãã
ãã®äºè±¡ã®åå ã¨ãã¦ãApacheã®å ´åã§ã¯ServerNameãã£ã¬ã¯ãã£ãã«æ£ããå¤ãè¨å®ãã¦ããªããã¨ãæãããã¾ããServerNameãã£ã¬ã¯ãã£ãã¯ãããã©ã«ãã®httpd.confã§ã¯ä»¥ä¸ã®ããã«ã³ã¡ã³ãã¢ã¦ãããã¦ãã¾ããä¸è¨ã®ä¾ãããã®ããã©ã«ãç¶æ ã§ã®å¿çã示ãããã®ã§ãã
#ServerName www.example.com:80
ãã®ã³ã¡ã³ãã¢ã¦ããå¤ãã¦æ£ãããã¹ãå(ããã§ã¯test.example.com)ãè¨è¿°ããè¨å®ãåæ ãããããã«Apacheãåèµ·åãã¦ãã ããã次ã®ä¾ã§åããããã«ãåããªã¯ã¨ã¹ãã«å¯¾ãã¦ããLocationãããã¼ã«ãã©ã¤ãã¼ãIPã¢ãã¬ã¹ã§ã¯ãªããã¹ãåã表示ãããããã«ãªã£ããã¨ã確èªã§ãã¾ãã
$ nc test.example.com 80 HEAD /img HTTP/1.0 HTTP/1.1 301 Moved Permanently Date: Thu, 03 Mar 2016 05:46:10 GMT Server: Apache Location: http://test.example.com/img/ Connection: close Content-Type: text/html; charset=iso-8859-1 $
å é¨IPã¢ãã¬ã¹ããªã表示ãããã®ã
ä¸è¨ã®ä¾ã¯Internet Explorerãªã©ç¾å¨ã®Webãã©ã¦ã¶ã®ä¸è¬çãªè¨å®ã§ã¯åç¾ãããnetcatãå©ç¨ãã¦ãªã¯ã¨ã¹ããææã¡ããã¨çºçããäºä¾ã§ãããªããããªãã®ããç解ããã«ã¯ã
- URLã®æ«å°¾ã«ã¹ã©ãã·ã¥(/)ãä»ããå ´åã¨ä»ããªãå ´åã§ã®åä½ã®éã
- Hostãããã¼ã®æç¡ã«ããåä½ã®éã
ã¨ãã2ã¤ã®ç¥èãå¿ è¦ã§ããå°ã ç´°ãã話ã«ãªãã¾ãããHTTPãããã³ã«ã¸ã®ç解ãæ·±ããããã®è¯ãææã§ãããã¾ãããã以ä¸ã«è§£èª¬ãã¾ãããã
URLã®æ«å°¾ã¹ã©ãã·ã¥
å ã»ã©ãhttp://test.example.com/img/ ã¨ããURLãèãã¾ããããããã§æ«å°¾ã®ã¹ã©ãã·ã¥ãæãã㦠http://test.example.com/img ã«ã¢ã¯ã»ã¹ããã¨ã©ããªãã§ãããããé常ã®Webãã©ã¦ã¶ã§ã¯éãã¯ãªããhttp://test.example.com/img/ ã¨ããã¹ã©ãã·ã¥ä»ãã®ã¢ã¯ã»ã¹ã¨åæ§ã«è¦ãããã¨ã¨æãã¾ãã
ããããã®éãWebãã©ã¦ã¶ã¨Webãµã¼ãã¼ã®éã§ã¯æ¬¡ã®å³ã®ãããªéä¿¡ãè¡ããã¦ãã¾ãã
ã¤ã¾ãããã£ã¬ã¯ããªã«å¯¾ãã¦æ«å°¾ã®ã¹ã©ãã·ã¥ãæãããã¢ã¯ã»ã¹ã¯ã
- /imgã¨ãããã¡ã¤ã«ããªã¯ã¨ã¹ããã
- ãã®ãããªãã¡ã¤ã«ã¯ãªãããã代ããã«/img/ã¨ãããã£ã¬ã¯ããªã¸Locationãããã¼ãå©ç¨ãã¦ãªãã¤ã¬ã¯ããã
- æ¹ãã¦/img/ã¨ãããã£ã¬ã¯ããªã¸ã¢ã¯ã»ã¹ãã
ã¨ããã®ãå é¨ã®åãã¨ãªã£ã¦ãã¾ããä»åã®ã±ã¼ã¹ã§ã¯ããããã¦Locationãããã¼ã«ãããªãã¤ã¬ã¯ããçºçãããã¨ãéè¦ãªç¹ã§ãã
Hostãããã¼ã®æç¡ã«ããåä½ã®éã
ç¾å¨ãä¸è¬çãªWebãã©ã¦ã¶ã¯HTTPãªã¯ã¨ã¹ããHTTP/1.1ã¨ããè¦æ ¼ã§éä¿¡ãã¾ãããã®HTTP/1.1ã¯Hostãããã¼ãå¿ é ã§ãããããWebãã©ã¦ã¶ã¯å ¥åãããURLãããã¹ãåãåãåºãã¦ãHostãããã¼ãä»ãã¦éä¿¡ãã¾ããLocationãããã¼ã«ãããªãã¤ã¬ã¯ãã§ã¯Hostãããã¼ã®å¤ããã¹ãåã¨ãã¦ä½¿ããããã¨ãä¸è¬çã§ãããããçµæã¨ãã¦HTTP/1.1ã§ã¯ããã®ã±ã¼ã¹ã§ã®å é¨IPã¢ãã¬ã¹ã®æ¼ããã¯çºçãã¾ããã
ä¸æ¹ãHTTP/1.0è¦æ ¼ã§ã¯Hostãããã¼ã¯ä¸è¦ã§ããHostãããã¼ããªãå ´åã«Locationãããã¼ã«ä½¿ããããã¹ãåã¯ãApacheã®å ´åã«ã¯ServerNameãã£ã¬ã¯ãã£ãã§è¨å®ãããå¤ã¨ãªãã¾ããServerNameã¯æªè¨å®æã¯ãã¹ãã®IPã¢ãã¬ã¹ãããã©ã«ãå¤ã¨ãªãã¾ã(*2)ããããã®çµæã¨ãã¦ãå¤é¨ããã®ãªã¯ã¨ã¹ãã«å¯¾ãã¦ãWebãµã¼ãã¼ã®ãã©ã¤ãã¼ãIPã¢ãã¬ã¹ãå ¥ã£ãLocationãããã¼ãçµã¿ç«ã¦ãããããã§ãã
(*2) ãã®IPã¢ãã¬ã¹ãéå¼ãã§ããå ´åã«ã¯ãéå¼ããããã¹ãåã«ãªãã¾ã
ãããã«
ä»åã¯ãnetcatãå©ç¨ãã¦Webãµã¼ãã¼ã®ã¬ã¹ãã³ã¹ãããã¼ããæ å ±åå¾ãè¡ãæ¹æ³ã解説ãã¾ãããçããããèªèº«ã§ç®¡çããã¦ããWebãµã¼ãã¼ãããã©ã®ãããªæ å ±ãåéã§ããã確èªãã¦ã¿ã¦ãã ããã
次åã¯ãnetcatã§è¡ãç°¡åãªãã¼ãéæ¾ãã§ãã¯ã®æ¹æ³ãç´¹ä»ããäºå®ã§ãã
Writer Profile
å¤§è§ ç¥ä»
Tweet