赞
踩
输入框输入<script>alert(document.cookie)</script>
得到结果,存在较为严重的存储型XSS漏洞
$message=escape($link, $message);
$query="insert into message(content,time) values('$message',now())";
$result=execute($link, $query);
$message=escape($link, $message);
$query="insert into message(content,time) values('$message',now())";
$result=execute($link, $query);
$message=str_replace(array("<",">","(",")","/","\\","|",'"',"'"),
array('《','》',"(",")","/","/","|",'`',"`"),
$_POST['message']);
$message=escape($link, $message);
$query="insert into message(content,time) values('$message',now())";
$result=execute($link, $query);
如图所示
$message=preg_replace(array('/<(.*)s(.*)c(.*)r(.*)i(.*)p(.*)t/i',
'/(.*)o(.*)n(.*)c(.*)l(.*)i(.*)c(.*)k/i',
'/(.*)o(.*)n(.*)l(.*)o(.*)a(.*)d/i',
'/(.*)o(.*)n(.*)m(.*)o(.*)u(.*)s(.*)e/i',
'/(.*)o(.*)n(.*)e(.*)r(.*)r(.*)o(.*)r/i',
'/<(.*)a/i',
), '', $_POST['message']);
$message=escape($link, $message);
$query="insert into message(content,time) values('$message',now())";
$result=execute($link, $query);
如图所示
if(array_key_exists('id', $_GET) && is_numeric($_GET['id'])){
//彩蛋:虽然这是个存储型xss的页面,但这里有个delete的sql注入
$query="delete from message where id={$_GET['id']}";
$result=execute($link, $query);
4.1 解决办法
函数名 | 释意 |
---|---|
is_numeric() | 函数用于检测变量是否为数字或数字字符串。 |
is_int() | 判断是否为整型 |
显然,需要将is_numeric()替换为is_int()即可
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。