<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/3091

            0x00 寫在前面


            在烏云zone里看到了《HFS 2.3x 遠程命令執行(抓雞黑客末日)》的文章,以前只是分析二進制漏洞,這種命令注入漏洞還是第一次分析,從網上下了HFS 2.3.279這個版本,運行起來之后,執行POC,四個calc就執行起來了。

            poc:

            http://localhost:80/?search==%00{.exec|calc.}
            

            PS:分析到最后,google查找可執行模塊中的字符串“parserLib”,才知道這個漏洞是CVE2014-6287。。。。。。一種淡淡的憂傷。不過還是說一下分析的過程吧。

            0x01 準備工作


            首先是分析前的一些準備工作,用PEiD查看了一下文件,加了asp的殼,通過PEiD通用脫殼器簡單的進行脫殼。

            enter image description here

            enter image description here

            通過IDA加載脫殼后的文件,看到一些函數如圖,根據之前對c++中string類實現的認識,看來應該是使用了靜態編譯,字符串處理的庫代碼被靜態鏈接到了可執行文件中。

            enter image description here

            通過PEid對脫殼后的文件進行編譯器識別,識別為Borland Delphi 6.0 - 7.0,通過IDA加載相應的簽名庫,對函數進行簽名,這樣就能識別出大量的內聯函數,方便分析。通過簽名,已經可以識別出5636個內聯函數,這樣分析起來就方便很多。

            enter image description here

            enter image description here

            0x02 分析過程


            通過IDA查看文件導入函數,查找WinExec、ShellExecuteA等進程啟動相關函數,通過交叉引用找到函數調用點,通過windbg設置斷點,觀察參數,確實是由ShellExecuteA啟動了計算器。同時查看程序的調用棧。

            enter image description here

            enter image description here

            通過調用棧,可已找到sub_531438函數,該函數解釋了exec|calc命令,并啟動了calc。對函數進行分析,可知該函數是對用戶的命令進行解釋執行的函數,相關代碼如下。

            enter image description here

            繼續通過調用棧,結合IDA對“exec|calc”的傳遞過程進行分析,找到

            int __stdcall sub_51E268(signed char *** a1, int a2)
            

            函數,**a1指向需要解釋的字符串“\x00{.exec|calc.}”,其中int __cdecl sub_51DFA0(int a1)函數對“\x00{.exec|calc.}”對其進行分析并執行。

            enter image description here

            enter image description here

            對于

            http://localhost:80/?search=%20{.exec|calc.}
            

            通過對比sub_51E268處**a1指向需要解釋的字符串,可以看到{.|等字符都被編碼了。

            enter image description here

            可見

            http://localhost:80/?search=%00{.exec|calc.}
            

            %00導致了{.exec|calc.}中的特殊字符轉換失敗,因此需要對轉換函數進行定位。在模塊中對“&#”字符串進行查找,定位得到

            int __fastcall sub_528EB0(int a1, int a2)
            

            完成對{|等字符進行轉換。

            enter image description here

            sub_51E390做正則表達式匹配,查找{|等字符,當%20{.exec|calc.}傳遞給該函數時,該函數返回值為2。下面由

            sub_4B827C、Sysutils::IntToStr
            

            將字符轉換為10進制字符串形式,最終替換掉原始字符串中的{。

            enter image description here

            enter image description here

            對于

            http://localhost:80/?search=%00{.exec|calc.}
            

            sub_51E390返回值為0,因此后面的{|等字符不會被轉換,最終導致了后面的命令執行。

            enter image description here

            查看

            int __fastcall sub_51E390(int a1, int a2)
            

            函數,可以看到“\\{[.:]|[.:]\\}|\\|”和“m!”,在分析的過程中,看到過字符串“parserLib”,就google一下。。。。。。。

            enter image description here

            enter image description here

            查看該漏洞詳情,可以看到和分析的結果一致,由于正則表達式的問題,導致了最終的遠程代碼執行。

            enter image description here

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

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

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

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

                      亚洲欧美在线