<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/tips/8659

                    0x00 背景


                    NFS(Network File System):是FreeBSD支持的文件系統中的一種,它允許網絡中的計算機之間通過TCP/IP網絡共享資源;

                    NFS配置:(聲明:以下NFS實驗是在RedHat7上完成)

                    首先安裝NFS(我的機子是最小化的系統,需要自己安裝):

                    #!bash
                    yum install nfs-utils.x86_64 -y
                    

                    啟動服務:

                    #!bash
                    systemctl start rpcbind(如果這個服務不啟動,nfs服務會啟動失敗)
                    systemctl start nfs-server
                    systemctl enable rpcbind;systemctl enable nfs-server 開機自啟
                    firewall-cmd --permanent --add-service=nfs 讓防火墻通過NFS服務
                    firewall-cmd --permanent --add-service=rpc-bind 通過rpc服務(如果不開啟,rpcinfo就不能掃描)
                    firewall-cmd --permanent --add-service=mountd 通過mountd服務(如果不開啟,不能遠程showmount)
                    firewall-cmd --reload
                    配置:
                    mkdir /pentest(創建一個共享目錄)
                    vi /etc/exports
                    cat /etc/exports
                    / *(rw,sync,no_root_squash) (注意:問題就出在這個地方,原理在文后解釋)
                    exportfs -r (啟動共享)
                    showmount -e (查看共享)
                    客戶端掛載:
                    mount -t nfs NFS服務器IP:/ /tmp/test (掛載到本地的/tmp/test中)
                    

                    enter image description here

                    enter image description here

                    0x01 檢測


                    對存在NFS配置錯誤的機子進行掃描:rpcinfo -p 192.168.119.131

                    enter image description here

                    查看nfs掛載新型:showmount -e 192.168.119.131

                    enter image description here

                    得到這些信息,我們就可以掛載NFS,并傳輸ssh永久連接文件

                    enter image description here

                    enter image description here

                    0x02 總結


                    其實漏洞形成的原理就是權限不對,/etc/exports這個文件中的權限設置,我們上文采用的是root權限,所以導致服務器被入侵;

                    /etc/exports 文件格式

                    <輸出目錄> [客戶端1 選項(訪問權限,用戶映射,其他)] [客戶端2 選項(訪問權限,用戶映射,其他)]
                    

                    a. 輸出目錄:輸出目錄是指NFS系統中需要共享給客戶機使用的目錄;

                    b. 客戶端:客戶端是指網絡中可以訪問這個NFS輸出目錄的計算機

                    指定ip地址的主機:192.168.0.200

                    指定子網中的所有主機:192.168.0.0/24 192.168.0.0/255.255.255.0

                    指定域名的主機:david.bsmart.cn

                    指定域中的所有主機:*.bsmart.cn

                    所有主機:*

                    c. 選項:選項用來設置輸出目錄的訪問權限、用戶映射等。

                    設置輸出目錄只讀:ro

                    設置輸出目錄讀寫:rw

                    d. 用戶映射選項

                    all_squash:將遠程訪問的所有普通用戶及所屬組都映射為匿名用戶或用戶組(nfsnobody);

                    no_all_squash:與all_squash取反(默認設置);

                    root_squash:將root用戶及所屬組都映射為匿名用戶或用戶組(默認設置);

                    no_root_squash:與rootsquash取反;

                    anonuid=xxx:將遠程訪問的所有用戶都映射為匿名用戶,并指定該用戶為本地用戶(UID=xxx);

                    anongid=xxx:將遠程訪問的所有用戶組都映射為匿名用戶組賬戶,并指定該匿名用戶組賬戶為本地用戶組賬戶(GID=xxx);

                    e. 其它選項

                    secure:限制客戶端只能從小于1024tcp/ip端口連接nfs服務器(默認設置);

                    insecure:允許客戶端從大于1024tcp/ip端口連接服務器;

                    sync:將數據同步寫入內存緩沖區與磁盤中,效率低,但可以保證數據的一致性;

                    async:將數據先保存在內存緩沖區中,必要時才寫入磁盤;

                    wdelay:檢查是否有相關的寫操作,如果有則將這些寫操作一起執行,這樣可以提高效率(默認設置);

                    no_wdelay:若有寫操作則立即執行,應與sync配合使用;

                    subtree:若輸出目錄是一個子目錄,則nfs服務器將檢查其父目錄的權限(默認設置);

                    no_subtree:即使輸出目錄是一個子目錄,nfs服務器也不檢查其父目錄的權限,這樣可以提高效率。

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

                                      这里只有精品视频