Windows / AD Enumeration

This shows various checks that need to be performed while solving a machine.

-------------- WINDOWS ENUMERATION ---------------

SMB enumeration (139/445)

If SMB is on then check for shares first with all the tools -> smbmap, smbclient, enum4linux, etc.

If files are huge, then we can use "smbget" command to download them directly. (Check notion)

DNS enumeration (53)

Try finding subdomains or other domain names.

RPC Enumeration (Port 139, 593)

rpcclient can be used in most cases for gathering information but if it is not working then we can use it like this also -

rpcclient <target-ip>
#Normal command to check anonymous access

rpcclient -U '' <target-ip>
#Providing empty user sometimes work!!

rpcclient -U ''%'' <target-ip>
#Empty user with empty passwords (Worked for me in Resourced PG)

Follow the checklist present at this location ->

https://www.hackingarticles.in/active-directory-enumeration-rpcclient/arrow-up-right

#######ADD some more from HTB Forest

Running Processes list -

Using CMD

Using PowerShell

Firewall Enumeration -

Firewall rules can either be enumerated with netsh functionality or Powershell also.

Using netsh to dump all the firewall rules -

Other links for netsh commands -

  1. Check other cheatsheets

Using Powershell to enumerate Firewall rules -

We can also check which ports it is blocking using this rule with this command -

Base64 encoding & decoding to extract file -

Using certutil in cmd -

Using powershell to encode input -

Decoding base64 input into a file -

Replacing strings using PowerShell Set-Content cmdlet -

We can replace a part of string by using Set-Content method in PowerShell like this -

The first part replaces the "Get-Volume" string by "hello" and the "Set-Content" part will make it permanent.

Using mimikatz to dump local passwords & user hashes

http://woshub.com/how-to-get-plain-text-passwords-of-windows-users/arrow-up-right

------------- AD ENUMERATION / EXPLOITATION------------

Enumerating all users & groups -

After getting access to the shell of one of the user, enumerate all the users & the groups they belong to using one of these -

  1. net.exe

  2. Powerview.ps1

  3. Bloodhound

#Most of the machines will be depending upon this enumeration technique for the exploitation.

Looking for SSRF to get Foothold via Responder

If we have SSRF on the website running in the target or something else through which we can trigger a request to responder running in our machine, then we can easily get NTLMv2 hash of the target user. We can crack this hash with hashcat after to retrieve the password.

Explained in detail in Notion notes and taken from PG Heist machine.

Relaying NTLMv2 hashes to other machines

If we aren't able to crack NTLMv2 hashes, then we can relay them to other machines. If the user whose hash we have, is a local-admin on other machine, then we'll be able to get admin privileges on other machine.

Check Notion for more detail.

ldapsearch -> Enumerating LDAP (389, 636, 3268, 3269)

Bloodhound will work if this port is open.

To get base DN, use this command first -

Getting ldap enumeration from target machine using base Domain Name -

Run queries alongwith the ldapsearch command -

To get all usernames with ObjectClass->Person -

Now, we can take these usernames and start brute-forcing their password using crackmapexec -

Parsing sensitive information using ldapsearch

If ldapsearch returns excess output, look for sensitive attributes for valid user or machine accounts.

->Save the whole output of ldapsearch into a file and try looking for strings like "Pwd" or "passwd" or "secrets", etc.

-> Atleast check all attributes of all users from ldapsearch output.

For example, in cascade HTB machine, we had "cascadeLegacyPwd" attribute set for most of the users - to their passwords.

Kerbrute (Brute-forcing usernames & passwords)

Using kerbrute, we may enumerate valid usernames from the active directory network.

We can use "userenum" flag of kerbrute for this ->

Now, through the usernames you received to --> getNPUsers.py for AS-REP Roasting.

smbclient.py - impacket (SMB share enumeration)

This is useful even when NTLM authentication is disabled and kerberos is enabled.

Use "help" command to access multiple options.

We can also use "smbclient" tool in kali like this ->

GetUserSPNs.py --> Kerberoasting

Can work with / without valid AD Credentials (w.r.t. scenario) ->

Or, if we have a potential SPN, then we directly check whether it is associated with a user or not (WITHOUT ANY VALID CREDENTIALS) ->

#Store the ticket generated from above ticket in a file and use hashcat to crack it.

#Make note of SPN for which ticket was generated.

The ticket generated above can also be used to perform Silver Ticket Attack (using ticketer.py) or to attack that SPN for which we got the password.

Getting Domain SID value ->

  1. We can use ldapsearch for this (use any basic command listed above)

  2. If the above command doesn't work then we can use this impacket tool -

ticketer.py --> Silver Ticket (TGS) Attack

Now, stored the ticket generated in KRB5CCACHE environment variable ->

Now, try accessing the target service. For example, MSSQL Service can be accessed here as ->

GetNPUsers/Rubeus.exe (AS-REP Roasting -> Cracking hashes)

If user accounts have kerberos pre-authentication disabled then we can use this impacket script (GetNPUsers.py) to get password hashes of those users and then crack them offline -

*Doesn't need valid credentials but valid credentials increase possibility of attack*

Use this command to get TGT of one of the users from above output -

Change format of TGT to hashcat or john for cracking it -

Now, we can use the cracked password to login as that user directly using evil-winrm or psexec or winexe (if we have enough access).

The similar thing can be done with Rubeus.exe binary directly from Windows ->

DCSync Attack - 2 ways -->

1. Secretsdump.py (Dumping creds) -

If we have enough privileges on the target machine or DC, then we can use secretsdump.py to dump secrets like passwords or hashes.

Use psexec.py or wmiexec.py now, to perform pass the hash attack to get administrator shell access.

#PSexec gives -> NT Authority/System privileges

#WmiExec gives -> administrator privileges

2. Mimikatz - DCSync

psexec.py / wmiexec.py / evil-winrm (Pass the Hash or passwd)

#psexec & wmiexec only work if we have write access to one of the shares.##

If we have a user hash, then we can use below tools to perform pass the hash attack to get shell access as the user whose hash we possess.

We can use rc4-hmac hash also for this purpose (it is same as NT HASH).

psexec.py provides us NT Authoriy/System privileges, if we use "administrator" use like this ->

wmiexec.py provides "admin" privileges with the "administrator" hash ->

evil-winrm can also be used to login with user's password or hash -> (Port 5985)

CRACKMAPEXEC (Post Exploitation - Enumeration)

Brute-forcing username & password over multiple services -

Using username & password for enumeration -

Getting password policy -

Getting shares from the target -

Executing commands -

Getting all the shares using spider_plus module in crackmapexec ->

Bloodhound.py (using valid credentials) -

Run neo4j console & then bloodhound GUI and put all .json files in it for evaluation.

Bloodhound needs port 389 (LDAP) to be open.

Getting shell access with .pfx files using evil-winrm -

If we have valid .pfx files then we can extract public (crt) and private keys from it to login using evil-winrm. (This is like logging in with ssh keys without username in linux)

We might need to crack the password of .pfx file first which can be done using john -

Now, using the cracked password we need to extract the keys out of it.

First, extract the private keys -

Now, we can decrypt this key too so that we don't have to remember the password -

Extracting public key (crt) -

Now, we can simply use evil-winrm to login using these 2 keys like this -

"SeBackupPrivilege" Privilege Escalation

We can run "whoami /priv" to check whether we have "SeBackupPrivilege" set. It can be used to drop administrator hashes, which then can be used to perform PTH attack.

If we have low privilege access to the domain controller & we have this privilege set, then it can exploited to get domain admin privileges.

Follow the below link for exploitation ->

https://www.hackingarticles.in/windows-privilege-escalation-sebackupprivilege/arrow-up-right

Useful binaries for further exploitation

Check this repository which has pre-compiled binaries (.exe) for different purposes ->

https://github.com/expl0itabl3/Tooliesarrow-up-right

ReadLAPSPassword Exploitation

If the current user has ReadLAPSPassword privilege then it can be used to read the LAPS password of the target computer account.

To exploit this we can use crackmapexec in this way ->

MSSQLclient.py Exploitation

We can use impacket-mssqlclient.py to login with valid mssql service creds into a machine with following command -

Last updated