Skip to content

Commit 2a813fa

Browse files
Merge pull request PowerShellMafia#109 from mmashwani/master
Don't search for SYSTEM token by using hard coded English name
2 parents 9e771d1 + 96ad796 commit 2a813fa

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Exfiltration/Invoke-TokenManipulation.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1685,7 +1685,8 @@ Blog on this script: http://clymb3r.wordpress.com/2013/11/03/powershell-and-toke
16851685
#First GetSystem. The script cannot enumerate all tokens unless it is system for some reason. Luckily it can impersonate a system token.
16861686
#Even if already running as system, later parts on the script depend on having a SYSTEM token with most privileges.
16871687
#We need to enumrate all processes running as SYSTEM and find one that we can use.
1688-
$SystemTokens = Get-Process -IncludeUserName | Where {$_.Username -eq "NT AUTHORITY\SYSTEM"}
1688+
[string]$LocalSystemNTAccount = (New-Object -TypeName 'System.Security.Principal.SecurityIdentifier' -ArgumentList ([Security.Principal.WellKnownSidType]::'LocalSystemSid', $null)).Translate([Security.Principal.NTAccount]).Value
1689+
$SystemTokens = Get-Process -IncludeUserName | Where {$_.Username -eq $LocalSystemNTAccount}
16891690
ForEach ($SystemToken in $SystemTokens)
16901691
{
16911692
$SystemTokenInfo = Get-PrimaryToken -ProcessId $SystemToken.Id -WarningAction SilentlyContinue -ErrorAction SilentlyContinue

0 commit comments

Comments
 (0)