Lightweight
Executive summary — Lightweight is an exercise in plaintext OpenLDAP combined with Linux capabilities as a privilege primitive. Initial access requires guessing no credential at all: the web application itself provisions an SSH account whose username and password are the visitor's IP address. From there, a
tcpdumpbinary carryingcap_net_rawallows sniffing the LDAP bind the web app performs on every page load, leaking a service account's password in the clear; an encrypted backup in its home directory reveals the source code that in turn leaks a second user's credential, and that user owns a copy ofopensslwith every capability — includingcap_setuid— enough to run arbitrary code as root through a malicious engine.
| Platform | Hack The Box |
| Operating system | CentOS 7 (Linux) |
| Difficulty | Medium |
| Status | Retired |
| Target IP | <TARGET_IP> |
Attack map
[HTTP] user.php creates an SSH account -- username=password=<YOUR_IP>
|
v
[SSH] low-privilege shell -- tcpdump has cap_net_raw without being root
| sniffs 389/loopback while status.php performs a bind
v
[LDAP] plaintext simple bind captured -> ldapuser2 : 8bc8251332abe1d7f105d3e53ad39ac2
| su ldapuser2 -> user.txt + backup.7z (7zAES, password "delete" via rockyou)
v
[backup.7z] status.php source leaks ldapuser1's credential
| su ldapuser1
v
[CAPABILITIES] custom openssl with "=ep" (incl. cap_setuid) -> malicious .so engine
v
[ROOT] setuid(0) in the engine's constructor -> SUID bash -> root.txt
1. Reconnaissance
The response TTL (63, i.e. 64 minus one hop) points at Linux before touching a single service.
sudo nmap -p- --min-rate 3000 -T4 -Pn -oN nmap-allports.txt <TARGET_IP>
Only three open ports, but one of them is unusual for a Linux box:
| Port | Service | Note |
|---|---|---|
| 22 | OpenSSH 7.4 | Standard |
| 80 | Apache 2.4.6 (CentOS, PHP/5.4.16) | "Lightweight slider evaluation page" |
| 389 | OpenLDAP 2.2.X–2.3.X | The directory service, exposed straight to the outside — the pivot point of the whole box |
sudo nmap -p22,80,389 -sCV -Pn -oN nmap-services.txt <TARGET_IP>
22/tcp ssh OpenSSH 7.4
80/tcp http Apache 2.4.6 ((CentOS) ... PHP/5.4.16) — title: "Lightweight slider evaluation page - slendr"
389/tcp ldap OpenLDAP 2.2.X - 2.3.X
| ssl-cert: Subject: commonName=lightweight.htb
Every other port answers host-prohibited — the signature of firewalld on RHEL/CentOS, and, as it turns out shortly, a firewall that does more than just filter ports.
echo "<TARGET_IP> lightweight.htb" | sudo tee -a /etc/hosts
Root Access unlocks the content you can't see — everything else on the site is already open.
See Root Access plansNo account? Create one free then upgrade from your console.