最新消息:图 床

MetInfo 任意文件讀取漏洞的修復與繞過

COOL IAM 93浏览 0评论

Author: Badcode@知道創宇404實驗室
Date: 2018/08/20

Update: 目前WAM已開源 https://github.com/knownsec/wam

404實驗室內部的WAM(Web應用監控程序,文末有關於WAM的介紹)監控到 MetInfo 版本更新,並且自動diff了文件,從diff上來看,應該是修復了一個任意文件讀取漏洞,但是沒有修復完全,導致還可以被繞過,本文就是記錄這個漏洞的修復與繞過的過程。

漏洞簡介

MetInfo是一套使用PHP和Mysql開發的內容管理系統。 MetInfo 6.0.0~6.1.0版本中的 old_thumb.class.php文件存在任意文件讀取漏洞。攻擊者可利用漏洞讀取網站上的敏感文件。

漏洞影響

  • MetInfo 6.0.0
  • MetInfo 6.1.0

漏洞分析

看到/MetInfo6/app/system/include/module/old_thumb.class.php

<?php
# MetInfo Enterprise Content Management System
# Copyright (C) MetInfo Co.,Ltd (http://www.metinfo.cn). All rights reserved.

defined('IN_MET') or exit('No permission');

load::sys_class('web');

class old_thumb extends web{

      public function doshow(){
        global $_M;

        $dir = str_replace('../', '', $_GET['dir']);

        if(strstr(str_replace($_M['url']['site'], '', $dir), 'http')){
            header("Content-type: image/jpeg");
            ob_start();
            readfile($dir);
            ob_flush();
            flush();
            die;
        }
......

從代碼中可以看到,$dir直接由$_GET['dir']傳遞進來,並將../置空。目標是進入到第一個 if 裡面的readfile($dir);,讀取文件。看看 if 語句的條件,裡面的是將$dir中包含$_M['url']['site']的部分置空,這裡可以不用管。外面是一個strstr函數,判斷$dirhttp字符串的首次出現位置,也就是說,要進入到這個 if 語句裡面,$dir中包含http字符串即可。

從上面的分析可以構造出 payload,只要$dir里包含http字符串就可以進入到readfile函數從而讀取任意函數,然後可以使用..././來進行目錄跳轉,因為../會被置空,所以最終payload 如下

?dir=..././http/..././config/config_db.php

转载请注明:IAMCOOL » MetInfo 任意文件讀取漏洞的修復與繞過

0 0 vote
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x