[EN] [CTF] TAMU - Obituary
Write-up for challenge 'Obituary' (Network Pentest, 2 × 500 pts) from TAMU CTF 2020.
Hey, shoot me over your latest version of the code. I have a simple nc session up, just pass it over when you’re ready. You’re using vim, right? You should use it; it’ll change your life. I basically depend on it for everything these days!
NOTE: This challenge is two parts. Flag one belongs to mwazoski. Flag two belongs to root.
|
|
Once the VPN connection is established, we can see that the 172.30.0.2
server exposes a service on port 4321. It is therefore on this port that we will send our files. The challenge description mentioning the use of vim, we suspect that the exploitation of a possible flaw in the text editor will allow us to execute code remotely.
This is precisely what the CVE-2019–12735 allows! The flaw resides in the way how the text editor handles the “modelines” a feature that’s enabled by default to automatically find and apply a set of custom preferences as mentioned by the creator of a file at the starting and ending lines in a document. Therefore, just opening an innocent looking specially crafted malicious file using Vim or Neovim editor could allow attackers to execute commands on Linux system and ultimately take over the target system.
We need to suppose the server uses Vim before version 8.1.1365 and has the modeline option enabled, but it is easy to check it. First, we need to craft a malicious file with our payload :
|
|
When this file is opened by the vulnerable Vim, if will offer us a reverse shell on the server. All we have to do is open port 4444 for listening and send the file with cat revshell.txt | nc 172.30.0.2 4321
.
|
|
gigem{ca7_1s7_t0_mak3_suRe}
As stated above, the user “mwazoski” owns the first flag and root owns the second one. So we need to elevate our privileges. In our home directory, we can see two other files: manually_installed_packages.txt
and note_to_self.txt
.
|
|
We can see here, the user “mwazowski” is only allowed to execute the command apt
to allow him to perform updates on the machine. At least this was the intention…
If we look at the very bottom, we will notice that there is an --option
flag that can be passed into apt
. This allows us to set an “arbitrary configuration option”. In digging into the documentation further, I come across a series of configuration items available to the options parameter of the following kind.
|
|
From here, all we need to do is run apt update
with this --option
flag :
|
|
gigem{y0u_w0u1d_7h1nk_p3opl3_W0u1d_Kn0W_b3773r}
Sources:
Share this post
Twitter
Google+
Facebook
Reddit
LinkedIn
StumbleUpon
Pinterest
Email