网站地图    收藏   

主页 > 后端 > 网站安全 >

Stcms sql注射及修复 - 网站安全 - 自学php

来源:自学PHP网    时间:2015-04-17 11:59 作者: 阅读:

[导读] 任意sql语句执行case #39;list#39;: $totalNum = $mysql-numTable(member, $where); $pageNum = 20; $totalPage = intval($totalNum/$pageNum) == $totalNum/$pageNum ? $totalNum/$pageNum......

任意sql语句执行

case 'list':
      
              $totalNum = $mysql->numTable("member", $where);
              $pageNum = 20;
              $totalPage = intval($totalNum/$pageNum) == $totalNum/$pageNum ? $totalNum/$pageNum : intval($totalNum/$pageNum)+1;
              $page = $page ? $page : 1;
              $page = $page>$totalPage ? $totalPage : $page;
              $page = $page<1 ? 1 : $page;
              $members = $mysql->select("member","id,name,time,money,provience,city,picture",$where,array("id DESC"),array(($page-1)*$pageNum,$pageNum)); www.2cto.com
              require(INCLUDE_PATH."page.class.php");
              $pageClass = new page($page,$totalNum,$pageNum, WEB_URL."member/u.php?action=list", true);
              $pageCode = $pageClass->getCode();
              $smarty->assign("webTitle","会员列表");
              $smarty->assign("uList", $members);
              $smarty->assign("pageCode", $pageCode);
              $smarty->display("member/m_u_list.html");
 
function numTable($table='',$wheres=false)
       {
              $table = $this->dbPrefix.$table;
              $sql = "SELECT COUNT(*) AS num FROM `$table`";
              if($wheres)
              {
                     $sql .= " WHERE ";
                     if(is_array($wheres))
                     {
                            foreach($wheres as $key => $val)
                            {
                                   $whr[] = "`$key`='".$val."'";
                            }
                            $sql .= implode(" AND ",$whr);
                     }
                     elseif(is_string($wheres))
                     {
                            $sql .= $wheres;
                     }
              }
              $result = $this->fetch($this->query($sql));
              return $result['num'];
       }
Where 没初始化 导致可执行任意sql语句

测试:
http://www.2cto.com /stcms_html/member/u.php?action=list&where={sql}
修复方案:你懂的吧

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论