b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

Thinkphp5-x远程代码执行漏洞分析

电脑杂谈  发布时间:2019-06-22 00:07:09  来源:网络整理

thinkphp function.php_韩顺平php thinkphp_php function 写法

摘要

据了解,使用该wifi wpa2加密协议漏洞,攻击者可以解密网络流量中的号码、用户名、密码、照片以及其他敏感信息,通过某些网络配置,攻击者还可以将数据注入网络,远程安装恶意软件和其他恶意软件。可是,6月8日卡巴斯基发布了一份报告,报告名为《dvmap: the first android malware with code injection》(《dvmap:第一种具备代码注入能力的安卓恶意软件》)该报告指出thinkphp function.php,卡巴斯基分析了一种对android系统平台运行库进行恶意代码注入的恶意软件样本,然后在报告中提及该恶意软件所包含的“.root_sh”脚本文件中存在中文注释。值得注意的是,苹果此次着重修复了盘古越狱所利用的两个系统漏洞——一个漏洞能允许恶意应用提升自身权限,另一个漏洞能允许恶意应用通过内核权限执行任何代码。

Thinkphp5.x版本(5.0.20)中没有对路由中的控制器进行严格过滤,在存在admin、index模块、没有开启强制路由的条件下(默认不开启),导致可以注入恶意代码利用反射类调用命名空间其他任意内置类,完成远程代码执行。

THINKPHP 5.0.5-5.0.22

THINKPHP 5.1.0-5.1.30

这里选择对5.0.20版本进行分析,关键函数开头

/thinkphp/library/think/App.php:120

 $dispatch = self::$dispatch;
            // 未设置调度信息则进行 URL 路由检测
            if (empty($dispatch)) {
                $dispatch = self::routeCheck($request, $config);
            }
            // 记录当前调度信息
            $request->dispatch($dispatch);
            // 记录路由和请求信息
            if (self::$debug) {
                Log::record('[ ROUTE ] ' . var_export($dispatch, true), 'info');
                Log::record('[ HEADER ] ' . var_export($request->header(), true), 'info');
                Log::record('[ PARAM ] ' . var_export($request->param(), true), 'info');
            }
            //  app_begin
            Hook::listen('app_begin', $dispatch);
            // 请求缓存检查
            $request->cache(
                $config['request_cache'],
                $config['request_cache_expire'],
                $config['request_cache_except']
            );
            $data = self::exec($dispatch, $config);

进入self::routeCheck函数,进行路由检查

/thinkphp/library/think/App.php:120

php function 写法_thinkphp function.php_韩顺平php thinkphp

 public static function routeCheck($request, array $config)
    {
        $path = $request->path();
        ........................
    }

进入$request->path()函数

/thinkphp/library/think/Request.php:416行

public function path()
    {
        if (is_null($this->path)) {
            $suffix   = Config::get('url_html_suffix');
            $pathinfo = $this->pathinfo();
            if (false === $suffix) {
                // 禁止伪静态访问
                $this->path = $pathinfo;
            } elseif ($suffix) {
                // 去除正常的URL后缀
                $this->path = preg_replace('/\.(' . ltrim($suffix, '.') . ')$/i', '', $pathinfo);
            } else {
                // 允许任何后缀访问
                $this->path = preg_replace('/\.' . $this->ext() . '$/i', '', $pathinfo);
            }
        }
        return $this->path;
    }

进入$this->pathinfo()函数

/thinkphp/library/think/Request.php:384行

    public function pathinfo()
    {
        if (is_null($this->pathinfo)) {
            if (isset($_GET[Config::get('var_pathinfo')])) {
                // 判断URL里面是否有兼容模式参数
                $_SERVER['PATH_INFO'] = $_GET[Config::get('var_pathinfo')];
                unset($_GET[Config::get('var_pathinfo')]);
            } elseif (IS_CLI) {
                // CLI模式下 index.php module/controller/action/params/...
                $_SERVER['PATH_INFO'] = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : '';
            }
            // 分析PATHINFO信息
            if (!isset($_SERVER['PATH_INFO'])) {
                foreach (Config::get('pathinfo_fetch') as $type) {
                    if (!empty($_SERVER[$type])) {
                        $_SERVER['PATH_INFO'] = (0 === strpos($_SERVER[$type], $_SERVER['SCRIPT_NAME'])) ?
                        substr($_SERVER[$type], strlen($_SERVER['SCRIPT_NAME'])) : $_SERVER[$type];
                        break;
                    }
                }
            }
            $this->pathinfo = empty($_SERVER['PATH_INFO']) ? '/' : ltrim($_SERVER['PATH_INFO'], '/');
        }
        return $this->pathinfo;
    }

Config::get('var_pathinfo')是配置文件中的设置的参数,默认值为s,从GET中获取键值,然后赋值给routeCheck中的$path,这里也就是index/think\app/invokefunction。

Thinkphp5-x远程代码执行漏洞分析

/thinkphp/library/think/App.php:120

韩顺平php thinkphp_thinkphp function.php_php function 写法

 public static function routeCheck($request, array $config)
    {
        $path = $request->path();
        $depr = $config['pathinfo_depr'];
        $result = false;
        // 路由检测
        $check = !is_null(self::$routeCheck) ? self::$routeCheck : $config['url_route_on'];
        if ($check) {
            // 开启路由
            if (is_file(RUNTIME_PATH . 'route.php')) {
                // 读取路由缓存
                $rules = include RUNTIME_PATH . 'route.php';
                is_array($rules) && Route::rules($rules);
            } else {
                $files = $config['route_config_file'];
                foreach ($files as $file) {
                    if (is_file(CONF_PATH . $file . CONF_EXT)) {
                        // 导入路由配置
                        $rules = include CONF_PATH . $file . CONF_EXT;
                        is_array($rules) && Route::import($rules);
                    }
                }
            }
            // 路由检测(根据路由定义返回不同的URL调度)
            $result = Route::check($request, $path, $depr, $config['url_domain_deploy']);
            $must = !is_null(self::$routeMust) ? self::$routeMust : $config['url_route_must'];
            if ($must && false === $result) {
                // 路由无效
                throw new RouteNotFoundException();
            }
        }
        // 路由无效 解析模块/控制器/操作/参数... 支持控制器自动搜索
        if (false === $result) {
            $result = Route::parseUrl($path, $depr, $config['controller_auto_search']);
        }
        return $result;
    }


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-107530-1.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...