Git Product home page Git Product logo

Comments (7)

FixTheExchange avatar FixTheExchange commented on June 12, 2024

The original doesn't work on Windows 10 because it is hard coded to use wininit.exe, which is a protected process in Windows 10. It's necessary to find another process to use. Better to check all available processes and find one that works than to use a hard coded process name.

I overlooked the fact that -IncludeUserName is PowerShell 4+ when I modified it. Obviously that breaks it on earlier versions. Will need to figure out another way to accomplish this.

from powersploit.

FuzzySecurity avatar FuzzySecurity commented on June 12, 2024

Understood!

from powersploit.

mmashwani avatar mmashwani commented on June 12, 2024

The below code should get the username for the processes on versions of PowerShell lower than 4:

[psobject]$AllProcessesFromWMI = Get-WmiObject -Class Win32_Process -ErrorAction 'SilentlyContinue'

[psobject[]]$AllProcessUserNames = @()
ForEach ($Process in $AllProcessesFromWMI) {
    Try { $ProcessOwnerInfo = $Process.GetOwner() } Catch { Continue }

    [psobject]$ProcessUserNameInfo = New-Object -TypeName 'PSObject' -Property @{
        PID = $Process.ProcessId
        NTAccount = If ($ProcessOwnerInfo.User) { "$($ProcessOwnerInfo.Domain)\$($ProcessOwnerInfo.User)" } Else { [string]::Empty }
    }
    [psobject[]]$AllProcessUserNames += $ProcessUserNameInfo
}
[string]$LocalSystemNTAccount = (New-Object -TypeName 'System.Security.Principal.SecurityIdentifier' -ArgumentList ([Security.Principal.WellKnownSidType]::'LocalSystemSid', $null)).Translate([Security.Principal.NTAccount]).Value
[int32[]]$AllSystemAccountProcessesIDs = $AllProcessUserNames | Where-Object { $_.NTAccount -eq $LocalSystemNTAccount} | Select-Object -ExpandProperty 'PID'

$SystemTokens = Get-Process | Where { $AllSystemAccountProcessesIDs -contains $_.Id }

I guess a nicer way would be to create a function that extends the results of the Get-Process function by adding a NoteProperty called NTAccount that contains the Domain\Username. But the above does the trick.

from powersploit.

mmashwani avatar mmashwani commented on June 12, 2024

Of course WMI is kind of slow. The Win32 method for getting a process username is much faster. Linking to an article about that here:
http://www.codeproject.com/Articles/14828/How-To-Get-Process-Owner-ID-and-Current-User-SID

from powersploit.

mattifestation avatar mattifestation commented on June 12, 2024

Sorry for the delay on this. Does anyone want to validate the fix?

from powersploit.

FuzzySecurity avatar FuzzySecurity commented on June 12, 2024

Thank you sir, fix verified!

from powersploit.

mattifestation avatar mattifestation commented on June 12, 2024

Thanks for bringing this to our attention!

from powersploit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.