$ sudo nmap -sC -sV -p22,80 10.129.116.95 Starting Nmap 7.94SVN ( https://nmap.org ) at 2026-02-08 18:46 EST Nmap scan report for 10.129.116.95 Host is up (0.14s latency).
PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 9.2p1 Debian 2+deb12u1 (protocol 2.0) | ssh-hostkey: | 256 37:2e:14:68:ae:b9:c2:34:2b:6e:d9:92:bc:bf:bd:28 (ECDSA) |_ 256 93:ea:a8:40:42:c1:a8:33:85:b3:56:00:62:1c:a0:ab (ED25519) 80/tcp open http Apache httpd 2.4.25 ((Debian)) |_http-title: Nothing here yet. | http-robots.txt: 1 disallowed entry |_/writeup/ Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 28.64 seconds
from Email[jkr@writeup.htb], i get the domain i’m going to add it to my hosts file
1 2
$ echo'10.129.116.95 writeup.htb' | sudotee -a /etc/hosts 10.129.116.95 writeup.htb
the website is just a landing page with some text saying the site is DoS protected there’s nothing on there or the page source
our nmap scan found /writeup/ directory it’s a ctf writeup blog going to use whatweb on the directory to get more info
1 2
$ whatweb http://writeup.htb/writeup/ http://writeup.htb/writeup/ [200 OK] Apache[2.4.25], CMS-Made-Simple, Cookies[CMSSESSID9d372ef93962], Country[RESERVED][ZZ], HTML5, HTTPServer[Debian Linux][Apache/2.4.25 (Debian)], IP[10.129.116.95], MetaGenerator[CMS Made Simple - Copyright (C) 2004-2019. All rights reserved.], Title[Home - writeup]
after searching, i found that CMS Made Simple versions <= 2.2.9 are vulnerable to unauthenticated SQL injection i used this PoC but modified it first. i changed the value of TIME to 5 so the requests don’t get blocked by the DoS protection i was able to get the following user credentials
1 2 3 4
[+] Salt for password found: 5a599ef579066807 [+] Username found: jkr [+] Email found: jkr@writeup.htb [+] Password found: 62def4866937f08cc13bab43bb14e6f7
i’m going to add the hashed_password:salt to a file
when we ssh into the machine, root launches a new shell with sh to run /usr/bin/env -i which runs a command with a modified environment. the -i start with an empty environment, then rebuilds PATH with /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin. run-parts then executes executes /update-motd.d
so, with that, i can create a malicious run-parts file in /usr/local/bin, which will be executed when i ssh into the machine
I create an executable payload that will set the SUID bit on /bin/bash binary
now, all i have to do is ssh into the machine, and the payload will trigger and set the bash binary into a SUID binary and run with -p flag to get root