@@ -1390,6 +1390,7 @@ Outputs a custom object containing the token privilege (name/attributes) for the
1390
1390
if ($PSBoundParameters['Special']) {
1391
1391
if ($SpecialPrivileges -Contains $_.Privilege) {
1392
1392
$_ | Add-Member Noteproperty 'ProcessId' $ProcessID
1393
+ $_ | Add-Member Aliasproperty Name ProcessId
1393
1394
$_
1394
1395
}
1395
1396
}
@@ -2086,6 +2087,7 @@ https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/wind
2086
2087
$Out | Add-Member Noteproperty 'StartName' $Service.startname
2087
2088
$Out | Add-Member Noteproperty 'AbuseFunction' "Write-ServiceBinary -Name '$($Service.name)' -Path <HijackPath>"
2088
2089
$Out | Add-Member Noteproperty 'CanRestart' ([Bool]$CanRestart)
2090
+ $Out | Add-Member Aliasproperty Name ServiceName
2089
2091
$Out.PSObject.TypeNames.Insert(0, 'PowerUp.UnquotedService')
2090
2092
$Out
2091
2093
}
@@ -2145,6 +2147,7 @@ PowerUp.ModifiablePath
2145
2147
$Out | Add-Member Noteproperty 'StartName' $ServiceStartName
2146
2148
$Out | Add-Member Noteproperty 'AbuseFunction' "Install-ServiceBinary -Name '$ServiceName'"
2147
2149
$Out | Add-Member Noteproperty 'CanRestart' ([Bool]$CanRestart)
2150
+ $Out | Add-Member Aliasproperty Name ServiceName
2148
2151
$Out.PSObject.TypeNames.Insert(0, 'PowerUp.ModifiableServiceFile')
2149
2152
$Out
2150
2153
}
@@ -2192,6 +2195,7 @@ PowerUp.ModifiablePath
2192
2195
$Out | Add-Member Noteproperty 'StartName' $ServiceDetails.startname
2193
2196
$Out | Add-Member Noteproperty 'AbuseFunction' "Invoke-ServiceAbuse -Name '$($ServiceDetails.name)'"
2194
2197
$Out | Add-Member Noteproperty 'CanRestart' ([Bool]$CanRestart)
2198
+ $Out | Add-Member Aliasproperty Name ServiceName
2195
2199
$Out.PSObject.TypeNames.Insert(0, 'PowerUp.ModifiableService')
2196
2200
$Out
2197
2201
}
@@ -3157,6 +3161,7 @@ http://www.greyhathacker.net/?p=738
3157
3161
ForEach ($ModifidablePath in $ModifidablePaths) {
3158
3162
if ($Null -ne $ModifidablePath.ModifiablePath) {
3159
3163
$ModifidablePath | Add-Member Noteproperty '%PATH%' $_
3164
+ $ModifidablePath | Add-Member Aliasproperty Name '%PATH%'
3160
3165
$ModifidablePath.PSObject.TypeNames.Insert(0, 'PowerUp.HijackableDLL.Path')
3161
3166
$ModifidablePath
3162
3167
}
@@ -3587,6 +3592,7 @@ Custom PSObject containing results.
3587
3592
$Out | Add-Member Noteproperty 'Key' "$ParentPath\$Name"
3588
3593
$Out | Add-Member Noteproperty 'Path' $Path
3589
3594
$Out | Add-Member Noteproperty 'ModifiableFile' $_
3595
+ $Out | Add-Member Aliasproperty Name Key
3590
3596
$Out.PSObject.TypeNames.Insert(0, 'PowerUp.ModifiableRegistryAutoRun')
3591
3597
$Out
3592
3598
}
@@ -3659,6 +3665,7 @@ Custom PSObject containing results.
3659
3665
$Out | Add-Member Noteproperty 'TaskName' $TaskName
3660
3666
$Out | Add-Member Noteproperty 'TaskFilePath' $_
3661
3667
$Out | Add-Member Noteproperty 'TaskTrigger' $TaskTrigger
3668
+ $Out | Add-Member Aliasproperty Name TaskName
3662
3669
$Out.PSObject.TypeNames.Insert(0, 'PowerUp.ModifiableScheduledTaskFile')
3663
3670
$Out
3664
3671
}
@@ -3669,6 +3676,7 @@ Custom PSObject containing results.
3669
3676
$Out | Add-Member Noteproperty 'TaskName' $TaskName
3670
3677
$Out | Add-Member Noteproperty 'TaskFilePath' $_
3671
3678
$Out | Add-Member Noteproperty 'TaskTrigger' $TaskTrigger
3679
+ $Out | Add-Member Aliasproperty Name TaskName
3672
3680
$Out.PSObject.TypeNames.Insert(0, 'PowerUp.ModifiableScheduledTaskFile')
3673
3681
$Out
3674
3682
}
@@ -3733,6 +3741,7 @@ Custom PSObject containing results.
3733
3741
$SearchLocations | Where-Object { Test-Path $_ } | ForEach-Object {
3734
3742
$Out = New-Object PSObject
3735
3743
$Out | Add-Member Noteproperty 'UnattendPath' $_
3744
+ $Out | Add-Member Aliasproperty Name UnattendPath
3736
3745
$Out.PSObject.TypeNames.Insert(0, 'PowerUp.UnattendedInstallFile')
3737
3746
$Out
3738
3747
}
@@ -4681,9 +4690,14 @@ Required Dependencies: None
4681
4690
4682
4691
Executes all functions that check for various Windows privilege escalation opportunities.
4683
4692
4693
+ .PARAMETER Format
4694
+
4695
+ String. Format to decide on what is returned from the command, an Object Array, List, or HTML Report.
4696
+
4684
4697
.PARAMETER HTMLReport
4685
4698
4686
- Switch. Write a HTML version of the report to SYSTEM.username.html.
4699
+ DEPRECATED - Switch. Write a HTML version of the report to SYSTEM.username.html.
4700
+ Superseded by the Format parameter.
4687
4701
4688
4702
.EXAMPLE
4689
4703
@@ -4693,25 +4707,26 @@ Runs all escalation checks and outputs a status report for discovered issues.
4693
4707
4694
4708
.EXAMPLE
4695
4709
4696
- Invoke-PrivescAudit -HTMLReport
4710
+ Invoke-PrivescAudit -Format HTML
4697
4711
4698
4712
Runs all escalation checks and outputs a status report to SYSTEM.username.html
4699
4713
detailing any discovered issues.
4700
4714
4701
- .OUTPUTS
4702
-
4703
- System.String
4704
4715
#>
4705
4716
4706
4717
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSShouldProcess', '')]
4707
- [OutputType('System.String')]
4708
4718
[CmdletBinding()]
4709
4719
Param(
4720
+ [ValidateSet('Object','List','HTML')]
4721
+ [String]
4722
+ $Format = 'Object',
4710
4723
[Switch]
4711
4724
$HTMLReport
4712
4725
)
4713
4726
4714
- if ($HTMLReport) {
4727
+ if($HTMLReport){ $Format = 'HTML' }
4728
+
4729
+ if ($Format -eq 'HTML') {
4715
4730
$HtmlReportFile = "$($Env:ComputerName).$($Env:UserName).html"
4716
4731
$Header = "<style>"
4717
4732
$Header = $Header + "BODY{background-color:peachpuff;}"
@@ -4722,153 +4737,101 @@ System.String
4722
4737
ConvertTo-HTML -Head $Header -Body "<H1>PowerUp report for '$($Env:ComputerName).$($Env:UserName)'</H1>" | Out-File $HtmlReportFile
4723
4738
}
4724
4739
4725
- # initial admin checks
4726
-
4727
- "`n[*] Running Invoke-AllChecks"
4728
-
4729
- $IsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
4730
-
4731
- if ($IsAdmin){
4732
- "[+] Current user already has local administrative privileges!"
4733
-
4734
- if ($HTMLReport) {
4735
- ConvertTo-HTML -Head $Header -Body "<H2>User Has Local Admin Privileges!</H2>" | Out-File -Append $HtmlReportFile
4740
+ Write-Verbose "Running Invoke-PrivescAudit"
4741
+
4742
+ $Checks = @(
4743
+ # Initial admin checks
4744
+ @{
4745
+ Type = 'User Has Local Admin Privileges'
4746
+ Command = { if (([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")){ New-Object PSObject } }
4747
+ },
4748
+ @{
4749
+ Type = 'User In Local Group with Admin Privileges'
4750
+ Command = { if ((Get-ProcessTokenGroup | Select-Object -ExpandProperty SID) -contains 'S-1-5-32-544'){ New-Object PSObject } }
4751
+ AbuseScript = { 'Invoke-WScriptUACBypass -Command "..."' }
4752
+ },
4753
+ @{
4754
+ Type = 'Process Token Privileges'
4755
+ Command = { Get-ProcessTokenPrivilege -Special | Where-Object {$_} }
4756
+ },
4757
+ # Service checks
4758
+ @{
4759
+ Type = 'Unquoted Service Paths'
4760
+ Command = { Get-UnquotedService }
4761
+ },
4762
+ @{
4763
+ Type = 'Modifiable Service Files'
4764
+ Command = { Get-ModifiableServiceFile }
4765
+ },
4766
+ @{
4767
+ Type = 'Modifiable Services'
4768
+ Command = { Get-ModifiableService }
4769
+ },
4770
+ # DLL hijacking
4771
+ @{
4772
+ Type = '%PATH% .dll Hijacks'
4773
+ Command = { Find-PathDLLHijack }
4774
+ AbuseScript = { "Write-HijackDll -DllPath '$($_.ModifiablePath)\wlbsctrl.dll'" }
4775
+ },
4776
+ # Registry checks
4777
+ @{
4778
+ Type = 'AlwaysInstallElevated Registry Key'
4779
+ Command = { if (Get-RegistryAlwaysInstallElevated){ New-Object PSObject } }
4780
+ AbuseScript = { 'Write-UserAddMSI' }
4781
+ },
4782
+ @{
4783
+ Type = 'Registry Autologons'
4784
+ Command = { Get-RegistryAutoLogon }
4785
+ },
4786
+ @{
4787
+ Type = 'Modifiable Registry Autorun'
4788
+ Command = { Get-ModifiableRegistryAutoRun }
4789
+ },
4790
+ # Other checks
4791
+ @{
4792
+ Type = 'Modifiable Scheduled Task Files'
4793
+ Command = { Get-ModifiableScheduledTaskFile }
4794
+ },
4795
+ @{
4796
+ Type = 'Unattended Install Files'
4797
+ Command = { Get-UnattendedInstallFile }
4798
+ },
4799
+ @{
4800
+ Type = 'Encrypted web.config Strings'
4801
+ Command = { Get-WebConfig | Where-Object {$_} }
4802
+ },
4803
+ @{
4804
+ Type = 'Encrypted Application Pool Passwords'
4805
+ Command = { Get-ApplicationHost | Where-Object {$_} }
4806
+ },
4807
+ @{
4808
+ Type = 'McAfee SiteList.xml files'
4809
+ Command = { Get-SiteListPassword | Where-Object {$_} }
4810
+ },
4811
+ @{
4812
+ Type = 'Cached GPP Files'
4813
+ Command = { Get-CachedGPPPassword | Where-Object {$_} }
4736
4814
}
4737
- }
4738
- else{
4739
- "`n`n[*] Checking if user is in a local group with administrative privileges..."
4740
-
4741
- $CurrentUserSids = Get-ProcessTokenGroup | Select-Object -ExpandProperty SID
4742
- if ($CurrentUserSids -Contains 'S-1-5-32-544') {
4743
- "[+] User is in a local group that grants administrative privileges!"
4744
- "[+] Run 'Invoke-WScriptUACBypass -Command `"...`"' to elevate privileges to admin."
4745
- if ($HTMLReport) {
4746
- ConvertTo-HTML -Head $Header -Body "<H2> User In Local Group With Administrative Privileges</H2>" | Out-File -Append $HtmlReportFile
4815
+ )
4816
+
4817
+ ForEach($Check in $Checks){
4818
+ Write-Verbose "Checking for $($Check.Type)..."
4819
+ $Results = . $Check.Command
4820
+ $Results | Where-Object {$_} | ForEach-Object {
4821
+ $_ | Add-Member Noteproperty 'Check' $Check.Type
4822
+ if ($Check.AbuseScript){
4823
+ $_ | Add-Member Noteproperty 'AbuseFunction' (. $Check.AbuseScript)
4747
4824
}
4748
4825
}
4749
- }
4750
-
4751
- "`n`n[*] Checking current process token permissions..."
4752
- $Results = Get-ProcessTokenPrivilege -Special | Where-Object {$_}
4753
- $Results | Format-List
4754
- if ($HTMLReport) {
4755
- $Results | ConvertTo-HTML -Head $Header -Body "<H2>Cached GPP Files</H2>" | Out-File -Append $HtmlReportFile
4756
- }
4757
-
4758
- # Service checks
4759
-
4760
- "`n`n[*] Checking for unquoted service paths..."
4761
- $Results = Get-UnquotedService
4762
- $Results | Format-List
4763
- if ($HTMLReport) {
4764
- $Results | ConvertTo-HTML -Head $Header -Body "<H2>Unquoted Service Paths</H2>" | Out-File -Append $HtmlReportFile
4765
- }
4766
-
4767
- "`n`n[*] Checking service executable and argument permissions..."
4768
- $Results = Get-ModifiableServiceFile
4769
- $Results | Format-List
4770
- if ($HTMLReport) {
4771
- $Results | ConvertTo-HTML -Head $Header -Body "<H2>Service File Permissions</H2>" | Out-File -Append $HtmlReportFile
4772
- }
4773
-
4774
- "`n`n[*] Checking service permissions..."
4775
- $Results = Get-ModifiableService
4776
- $Results | Format-List
4777
- if ($HTMLReport) {
4778
- $Results | ConvertTo-HTML -Head $Header -Body "<H2>Modifiable Services</H2>" | Out-File -Append $HtmlReportFile
4779
- }
4780
-
4781
-
4782
- # DLL hijacking
4783
-
4784
- "`n`n[*] Checking %PATH% for potentially hijackable DLL locations..."
4785
- $Results = Find-PathDLLHijack
4786
- $Results | Where-Object {$_} | Foreach-Object {
4787
- $AbuseString = "Write-HijackDll -DllPath '$($_.ModifiablePath)\wlbsctrl.dll'"
4788
- $_ | Add-Member Noteproperty 'AbuseFunction' $AbuseString
4789
- $_
4790
- } | Format-List
4791
- if ($HTMLReport) {
4792
- $Results | ConvertTo-HTML -Head $Header -Body "<H2>%PATH% .dll Hijacks</H2>" | Out-File -Append $HtmlReportFile
4793
- }
4794
-
4795
-
4796
- # registry checks
4797
-
4798
- "`n`n[*] Checking for AlwaysInstallElevated registry key..."
4799
- if (Get-RegistryAlwaysInstallElevated) {
4800
- $Out = New-Object PSObject
4801
- $Out | Add-Member Noteproperty 'AbuseFunction' "Write-UserAddMSI"
4802
- $Results = $Out
4803
-
4804
- $Results | Format-List
4805
- if ($HTMLReport) {
4806
- $Results | ConvertTo-HTML -Head $Header -Body "<H2>AlwaysInstallElevated</H2>" | Out-File -Append $HtmlReportFile
4826
+ switch($Format){
4827
+ Object { $Results }
4828
+ List { "`n`n[*] Checking for $($Check.Type)..."; $Results | Format-List }
4829
+ HTML { $Results | ConvertTo-HTML -Head $Header -Body "<H2>$($Check.Type)</H2>" | Out-File -Append $HtmlReportFile }
4807
4830
}
4808
4831
}
4809
4832
4810
- "`n`n[*] Checking for Autologon credentials in registry..."
4811
- $Results = Get-RegistryAutoLogon
4812
- $Results | Format-List
4813
- if ($HTMLReport) {
4814
- $Results | ConvertTo-HTML -Head $Header -Body "<H2>Registry Autologons</H2>" | Out-File -Append $HtmlReportFile
4815
- }
4816
-
4817
-
4818
- "`n`n[*] Checking for modifidable registry autoruns and configs..."
4819
- $Results = Get-ModifiableRegistryAutoRun
4820
- $Results | Format-List
4821
- if ($HTMLReport) {
4822
- $Results | ConvertTo-HTML -Head $Header -Body "<H2>Registry Autoruns</H2>" | Out-File -Append $HtmlReportFile
4823
- }
4824
-
4825
- # other checks
4826
-
4827
- "`n`n[*] Checking for modifiable schtask files/configs..."
4828
- $Results = Get-ModifiableScheduledTaskFile
4829
- $Results | Format-List
4830
- if ($HTMLReport) {
4831
- $Results | ConvertTo-HTML -Head $Header -Body "<H2>Modifidable Schask Files</H2>" | Out-File -Append $HtmlReportFile
4832
- }
4833
-
4834
- "`n`n[*] Checking for unattended install files..."
4835
- $Results = Get-UnattendedInstallFile
4836
- $Results | Format-List
4837
- if ($HTMLReport) {
4838
- $Results | ConvertTo-HTML -Head $Header -Body "<H2>Unattended Install Files</H2>" | Out-File -Append $HtmlReportFile
4839
- }
4840
-
4841
- "`n`n[*] Checking for encrypted web.config strings..."
4842
- $Results = Get-Webconfig | Where-Object {$_}
4843
- $Results | Format-List
4844
- if ($HTMLReport) {
4845
- $Results | ConvertTo-HTML -Head $Header -Body "<H2>Encrypted 'web.config' String</H2>" | Out-File -Append $HtmlReportFile
4846
- }
4847
-
4848
- "`n`n[*] Checking for encrypted application pool and virtual directory passwords..."
4849
- $Results = Get-ApplicationHost | Where-Object {$_}
4850
- $Results | Format-List
4851
- if ($HTMLReport) {
4852
- $Results | ConvertTo-HTML -Head $Header -Body "<H2>Encrypted Application Pool Passwords</H2>" | Out-File -Append $HtmlReportFile
4853
- }
4854
-
4855
- "`n`n[*] Checking for plaintext passwords in McAfee SiteList.xml files..."
4856
- $Results = Get-SiteListPassword | Where-Object {$_}
4857
- $Results | Format-List
4858
- if ($HTMLReport) {
4859
- $Results | ConvertTo-HTML -Head $Header -Body "<H2>McAfee's SiteList.xml's</H2>" | Out-File -Append $HtmlReportFile
4860
- }
4861
-
4862
- "`n`n[*] Checking for cached Group Policy Preferences .xml files..."
4863
- $Results = Get-CachedGPPPassword | Where-Object {$_}
4864
- $Results | Format-List
4865
- if ($HTMLReport) {
4866
- $Results | ConvertTo-HTML -Head $Header -Body "<H2>Cached GPP Files</H2>" | Out-File -Append $HtmlReportFile
4867
- }
4868
- "`n"
4869
-
4870
- if ($HTMLReport) {
4871
- "[*] Report written to '$HtmlReportFile' `n"
4833
+ if ($Format -eq 'HTML') {
4834
+ Write-Verbose "[*] Report written to '$HtmlReportFile' `n"
4872
4835
}
4873
4836
}
4874
4837
0 commit comments