Skip to content

Lay groundwork for scanning Windows 7 and 8 #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
20 changes: 17 additions & 3 deletions tools/nessus/scan/Modules/UACModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
. .\Utils\RegistryUtils.ps1
. .\Utils\FileUtils.ps1

$CurrentVersion = "Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion"
$SystemPolicies = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
$ConsentPromptBehaviorAdmin_Name = "ConsentPromptBehaviorAdmin"
$PromptOnSecureDesktop_Name = "PromptOnSecureDesktop"
Expand Down Expand Up @@ -94,7 +95,15 @@ function Disable-UserAccountControl
Set-RegistryValue -Key $SystemPolicies -Name "LocalAccountTokenFilterPolicy" -Value 1
Write-Host "LocalAccountTokenFilterPolicy set to 1"

# TODO: For Windows 7 and 8, "EnableLua" in the same registry location must be set to 0
# For Windows 7 and 8, "EnableLua" must be set to 0
$OS_Name = (gcim Win32_OperatingSystem).Caption
$OS_Release = Get-RegistryValue -Key $CurrentVersion -Name "ReleaseID"

if ($OS_Release -match "^6\.1\." -or $OS_Release -match "^6\.[23]\.") {
Write-Host "Detected $OS_Name (Version: $OS_Release)"
Set-RegistryValue -Key $SystemPolicies -Name "EnableLua" -Value 0
Write-BulletPoint -Text "EnableLua set to 0"
}

Set-UACLevel -Level 0
$UACLevelText = Get-UACStateText (Get-UACLevel)
Expand All @@ -110,14 +119,19 @@ function HandleUserAccountControl
)

$LocalAccountTokenFilterPolicy = Get-RegistryValue -Key $SystemPolicies -Name "LocalAccountTokenFilterPolicy"
$EnableLua = Get-RegistryValue -Key $SystemPolicies -Name "EnableLua"

if (($LocalAccountTokenFilterPolicy -eq 1) -and ((Get-UACLevel) -eq [UACState]::NeverNotify)) {
Write-BulletPoint -Text "UAC configuration is correct."
return
if ($EnableLua -eq 1) {
# todo: handle enablelua for windows 8 and 10
Write-BulletPoint -Text "UAC configuration is correct."
return
}
}

$UACConfiguration = @{
"uac" = @{
"EnableLua" = $EnableLua
"LocalAccountTokenFilterPolicy" = $LocalAccountTokenFilterPolicy
"UACLevel" = Get-UACLevel
}
Expand Down
8 changes: 8 additions & 0 deletions tools/nessus/scan/revert_scan_win.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ function UserAccountControl
Remove-ItemProperty -Path $SystemPolicies -Name $RegistryItem
}

$OS_Name = (gcim Win32_OperatingSystem).Caption
$OS_Release = Get-RegistryValue -Key $CurrentVersion -Name "ReleaseID"

if ($OS_Release -match "^6\.1\." -or $OS_Release -match "^6\.[23]\.") {
Set-RegistryValue -Key $SystemPolicies -Name "EnableLua" -Value $Configuration.EnableLua
Write-BulletPoint -Text "EnableLua set to $Configuration.EnableLua"
}

Set-UACLevel -Level $Configuration.UACLevel
$UACText = Get-UACStateText $Configuration.UACLevel
Write-Host "User Account Control (UAC) set to $UACText"
Expand Down