漏刻有时采用PHP-MVC结构,在参数传递过程中,已做参数过滤。
如正常的访问路径如下:
http://test.com/?m=Surveyor&a=apply
在实际进行脚本攻击的时候会使用
http://test.com/?m=Surveyor&a=apply
如果调用的方法未进行安全过滤,则在访问的过程中会弹出javascript弹窗,则表明存在漏洞。
解决参数在传送的过程中,使用
/**
* 安全过滤函数
*
* @param $str
* @return $string
*/
function safe_replace($str)
{
$string = str_replace('%20', '', $str);
$string = str_replace('%27', '', $string);
$string = str_replace('%2527', '', $string);
$string = str_replace('*', '', $string);
$string = str_replace('"', '"', $string);
$string = str_replace("'", '', $string);
$string = str_replace('"', '', $string);
$string = str_replace(';', '', $string);
$string = str_replace('<', '', $string);
$string = str_replace('>', '', $string);
$string = str_replace("{", '', $string);
$string = str_replace('}', '', $string);
$string = str_replace('\\', '', $string);
return $string;
}
/*
* 变量传递值函数
* @param $str 变量值
*/
function get_param($str)
{
$string = safe_replace($_GET[$str]);
if ($string == '0') {
$val = '0';
} else {
$val = !empty($string) ? $string : null;
}
return $val;
}
http://test.com/index.php?m=Manager&a=examineAdmin&act=examine&pro_id=914&pro_types=1
//判断是否是整数类型
function get_safe($str)
{
$num = $_GET[$str];
if (is_numeric($num)) {
return $num;
} else {
redirect("index.php?m=Pop&a=tips&act=tips&tips_id=7");
}
}
漏洞说明:使用默认密码登录系统后,在强制修改密码时,存在手机验证码验证机制,但手机验证码可以使用bp拦截工具进行获取。从而得到修改密码的功能。获取验证码时抓包再进行抓回包
在登录平台、忘记密码时,系统采用手机短信验证码功能。系统生成验证码是,采用的cookies,而非session全局变量,由此导致浏览器端可以通过F12或bp拦截工具获取系统的验证码而不通过手机。
解决方案:
session_start();
$rmdCode = rand(111111, 999999);//随机验证码
$_SESSION['code'] = $rmdCode;
//登录成功后自动销毁;
session_destroy();
增加密码强度,强制注册时必须包含必须同时包含字母和数字且至少6位。
,pass: [/(?=.*[0-9])(?=.*[a-zA-Z]).{6,30}/, '密码必须同时包含字母和数字且至少6位']
@lockdata.cn