漏洞分析之thinkPHP反序列化:这就是黑客的世界吗( 七 )

param()方法,参数变化在注释中说明:
    public function param($name = '', $default = null, $filter = '')    {        if (!$this->mergeParam) { //mergeParam初始值为false,所以进入分支            $method = $this->method(true);            // 自动获取请求变量            switch ($method) {                case 'POST':                    $vars = $this->post(false);                    break;                case 'PUT':                case 'DELETE':                case 'PATCH':                    $vars = $this->put(false);                    break;                default:                    $vars = [];            }            // 当前请求参数和URL地址中的参数合并            // 可以按到无论是否是get请求,url中的参数都会被获取到            $this->param = array_merge($this->param, $this->get(false), $vars, $this->route(false));            $this->mergeParam = true;        }        if (true === $name) {            // 获取包含文件上传信息的数组            $file = $this->file();            $data = is_array($file) ? array_merge($this->param, $file) : $this->param;            return $this->input($data, '', $default, $filter);        }  // 调用input方法,$this->param为get与post所有参数,$name为axin,$default=null,$filter=''        return $this->input($this->param, $name, $default, $filter);    }input()方法:
    public function input($data = [], $name = '', $default = null, $filter = '')    {        if (false === $name) {            // 获取原始数据            return $data;        }        $name = (string) $name;        if ('' != $name) {            // 解析name            if (strpos($name, '/')) {                list($name, $type) = explode('/', $name);            }   // 这里调用了getData,调用结果就是$data = $data[$name]            $data = $this->getData($data, $name);            if (is_null($data)) {                return $default;            }            if (is_object($data)) {                return $data;            }        }        // 解析过滤器        $filter = $this->getFilter($filter, $default);        if (is_array($data)) {            array_walk_recursive($data, [$this, 'filterValue'], $filter);            if (version_compare(PHP_VERSION, '7.1.0', '<')) {                // 恢复PHP版本低于 7.1 时 array_walk_recursive 中消耗的内部指针                $this->arrayReset($data);            }        } else {            $this->filterValue($data, $name, $filter);        }        if (isset($type) && $data !== $default) {            // 强制类型转换            $this->typeCast($data, $type);        }        return $data;    }


推荐阅读