toc2 (cms made simple 2.1.6 exploit + linux .c program race condition)
https://github.com/sroettger/35c3ctf_chals/blob/master/logrotate/exploit/rename.c
https://www.youtube.com/watch?v=5g137gsB9Wk
Find and retrieve the user.txt flag
Services
Nmap reveals 2 open ports:
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 84:4e:b1:49:31:22:94:84:83:97:91:72:cb:23:33:36 (RSA)
| 256 cc:32:19:3f:f5:b9:a4:d5:ac:32:0f:6e:f0:83:35:71 (ECDSA)
|_ 256 bd:d8:00:be:49:b5:15:af:bf:d5:85:f7:3a:ab:d6:48 (ED25519)
80/tcp open http Apache httpd 2.4.29 ((Ubuntu))
| http-robots.txt: 1 disallowed entry
|_/cmsms/cmsms-2.1.6-install.php
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: Site Maintenance
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernelCMS information
Connecting to the web service’s default page reveals credentials: cmsmsuser:devpass:
Besides, there is also a robots.txt file that discloses the name of a database, as well as a CMS installation URL (CMS Made Simple):
Running Gobuster won’t reveal other locations. At this stage, here is the information collected so far:
DB:
cmsmsdbUsername:
cmsmsuserPassword:
devpass
CMS Made Simple / Reverse Shell
Let’s proceed with the installation of CMS Made Simple, as we have the setup PHP file.
Complete the installation and login to the admin panel. Then go to the file manager and upload a PHP reverse shell.
Start a listener (nc -nlvp 4444) and browse 10.10.215.10/cmsms/uploads/shell.php.
We now have a reverse shell:
User flag
The user flag is located in frank’s home:
Escalate your privileges and acquire root.txt
Lateral move (www-data -> frank)
There is a note left in frank’s home folder, disclosing frank’s password: password.
Let’s connect as frank:
The readcreds binary
There is an interesting folder called root_access in frank’s home:
The sources of the readcreds binary are provided:
Race condition
Providing the root_password_backup file to the readcreds binary will show an error, as the file is owned by root. However, we can run a race condition attack.
Download rename.c. The source of the program is shown below:
Compile the program (gcc rename.c -o rename), create a pwd file and run the rename binary as follows:
Now in another session:
Root flag
We can now log in as root and read the root flag:
Last updated