DUMP_SMSA_PASSWORD
Summary
Description
Identification
PowerShell
function Find-DumpSMSAPassword {
[CmdletBinding()]
param (
[string]$Target = $null,
[string]$OutputPath = "sMSA_Host_Report.csv"
)
# Load ActiveDirectory module if not already loaded
if (-not (Get-Module -Name ActiveDirectory)) {
Write-Host "Attempting to load ActiveDirectory module..."
try {
Import-Module ActiveDirectory
Write-Host "ActiveDirectory module loaded successfully."
}
catch {
Write-Error "Failed to load ActiveDirectory module. Please ensure RSAT (Remote Server Administration Tools) for PowerShell is installed."
return
}
}
$foundSMSAHosts = @()
$computers = @()
try {
if ($Target) {
Write-Host "Searching for Service Master Account on specific computer: '$Target'..."
# Get the specific computer object using its name or Distinguished Name
$computer = Get-ADComputer -Identity $Target -Properties 'msDS-HostServiceAccount' -ErrorAction Stop
if ($computer) {
$computers += $computer
} else {
Write-Output "Computer '$Target' not found."
return
}
} else {
Write-Host "Searching for all computers with a configured Service Managed Service Account (sMSA)..."
# Get all computer objects with the 'msDS-HostServiceAccount' property populated
$computers = Get-ADComputer -Filter "msDS-HostServiceAccount -like '*'" -Properties 'msDS-HostServiceAccount' -ErrorAction Stop
}
if (-not $computers) {
Write-Output "No computers with a configured Service Master Account were found."
return
}
# Iterate through the computers and their sMSA entries
foreach ($computer in $computers) {
$computerName = $computer.Name
# The msDS-HostServiceAccount property can contain multiple values
if ($computer.'msDS-HostServiceAccount') {
foreach ($sMSAAccount in $computer.'msDS-HostServiceAccount') {
$foundSMSAHosts += [PSCustomObject]@{
"Message" = "Computer '$computerName's local admins can potentially read the password for sMSA account '$sMSAAccount'."
}
}
}
}
}
catch {
Write-Error "Failed to retrieve Active Directory computers: $($_.Exception.Message)"
return
}
# Export the results to CSV if any were found
if ($foundSMSAHosts.Count -gt 0) {
if ($Target) {
Write-Host "Found $($foundSMSAHosts.Count) entries on computer '$Target'."
} else {
Write-Host "Found $($foundSMSAHosts.Count) entries for computers with configured Service Managed Service Accounts."
}
try {
$foundSMSAHosts | Export-Csv -Path $OutputPath -NoTypeInformation -Encoding UTF8
Write-Output "Results exported successfully to '$OutputPath'"
}
catch {
Write-Error "Failed to export results to CSV file '$OutputPath': $($_.Exception.Message)"
}
} else {
if ($Target) {
Write-Output "Computer '$Target' has no configured Service Master Accounts."
} else {
Write-Output "No computers were found with configured Service Master Accounts."
}
}
}
Active Directory Users and Computers

Exploitation
Windows


Linux

Mitigation

Detection
Event ID
Description
Fields/Attributes
References
References
Last updated
Was this helpful?