PHP代码审计之入门实战
来源:岁月联盟
时间:2020-02-10
$channel = post('channel');
$com_page_id = post('page_id');
$com_email = post('email');
$com_rank = post('rank');
$com_text = post('text');
if($channel == '' || $com_page_id == '' || $com_rank == '' || $com_email == '' || $com_text == '')
{
$info_text = $lang['submit_error_info'];
}
...
...
}
存储XSS 扑gai~
前台用户CSRF判断
思路
网站有留言板和文章评论,如何存在CSRF越权的话可以在评论或者留言处贴构造好的CSRF链接,来进行CSRF攻击。23333 感觉稳了!定位到相关功能代码:
index/module/user/deal.php
function edit_pwd()
{
safe('edit_pwd');
global $global,$smarty,$lang;
$old_pwd = post('old_pwd');
$new_pwd = post('new_pwd');
$re_pwd = post('re_pwd');
if(strlen($old_pwd) 6 || strlen($old_pwd) > 15 || strlen($new_pwd) 6 || strlen($new_pwd) > 15 || $new_pwd != $re_pwd)
{
$info_text = $lang['submit_error_info'];
}else{
$use_password = md5($old_pwd);
$obj = new users();
$obj->set_where('use_id = '.$global['user_id']);
$obj->set_where("use_password = '$use_password'");
if($obj->get_count() > 0)
{
$use_password = md5($new_pwd);
$obj->set_value('use_password',$use_password);
...
...
}
结果
index/moudle/user/deal.php
// 这里需要提供旧密码
$use_password = md5($old_pwd);
$obj = new users();
$obj->set_where('use_id = '.$global['user_id']);
$obj->set_where("use_password = '$use_password'");
if($obj->get_count() > 0)
没有旧密码 是不可能改密码的,所以CSRF攻击其他用户的想法GG
可控变量过滤
虽然作为一个CMS,用户可控变量很多,文章浏览等功能不可避免地要进行数据库操作,但是该系统基本上把所以可控变量都给过滤了。
session 过滤
使用了$filter = 'strict'严格模式,关于strict函数细节可以参考文章上面贴的代码:
include/function.php
function set_session($name,$value,$filter = 'strict')
{
if(S_SESSION)
{
$_SESSION[$name] = $filter($value);
}else{
setcookie($name,$filter($value));
}
}
//获取session
function get_session($name,$filter = 'strict')
{
if(S_SESSION)
{
return $filter(isset($_SESSION[$name])?$_SESSION[$name]:'');
}else{
return $filter(isset($_COOKIE[$name])?$_COOKIE[$name]:'');
}
}
cookie过滤
include/function.php
//获取cookie
function get_cookie($name,$filter = 'strict')
{
return $filter(isset($_COOKIE[$name])?$_COOKIE[$name]:'');
}
管理员登录过滤
admin/module/info_main.php
function admin_login()
{
safe('admin_login');
global $smarty,$lang;
$username = substr(post('username'),0,30);
$password = substr(post('password'),0,30);
if($username == '' || $password == '')
{
unset_session('admin_username');
unset_session('admin_password');
$info_text = '对不起,用户名和密码不能为空';
$link_text = '返回重新登录';
}
...
...
}
普通用户登录过滤
index/module/info_main.php
function user_login()
{
safe('user_login');
global $global,$smarty,$lang;
$info_text = post('info_text');
$link_text = post('link_text');
$link_href = post('link_href');
$username = post('username');
$password = post('password');
上一页 [1] [2] [3] [4] [5] [6] [7] 下一页