Jump to content

Finding an SID...


koresho
 Share

Recommended Posts

Hey everyone, I'm attempting to modify another users' registry settings in Vista. The straightforward approach would be to launch a script at startup that will do everything for me, but I don't want to make the user approve a UAC consent prompt. I know to do this I need to go to HKEY_USERS\[insert SID here]. Only problem is, is there an easy way to discover an SID for another user using AutoIt?

I found a way to do it in WMI here, and I found a VBScript file (code posted below) but I'm not familiar with translating either of these to AutoIt. Any help is appreciated... thanks!

PS. If push comes to shove I'll just use the VBScript file and read the text file it leaves on the desktop, but I'd rather do it more efficiently.

Thanks!

Below is the VBScript that'll do it, if that helps.

'Author         : Ramesh Srinivasan, Microsoft MVP [Windows Shell/User]
'Description    : Lists all the user accounts, their SIDs and Profile paths.
'Copyright      : Copyright © 2005-2006, Ramesh Srinivasan
'Created on     : Aug 10, 2005
'Revised on     : Sep 16, 2006
'Prerequisite   : For Windows® XP
'Homepage       : http://windowsxp.mvps.org & http://www.winhelponline.com

Set WshShell = CreateObject("Wscript.Shell")
Set fso = Wscript.CreateObject("Scripting.FilesystemObject")
fName = WshShell.SpecialFolders("Desktop") & "\SIDlist.txt"
Set b = fso.CreateTextFile(fName, true)
b.writeblanklines 1
b.writeline string(61,"*")
b.writeline "Lists all the user accounts, their SIDs and Profile paths."
b.WriteLine "SIDList.vbs - Copyright © 2005-2006, Ramesh Srinivasan"
b.WriteLine "WWW: http://windowsxp.mvps.org & http://www.winhelponline.com"
b.writeline string(61,"*")
b.writeblanklines 1

strProfileBranch = "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\"
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colAccounts = objWMIService.ExecQuery _
    ("Select * From Win32_UserAccount")

For Each objAccount in colAccounts
    If objAccount.Name = "HelpAssistant" or objAccount.Name = "SUPPORT_388945a0" then
    else
        b.writeline "Username      : " & objAccount.Name
        b.writeline "SID           : " & objAccount.SID
        b.writeline "Profile dir     : " & GetHomePath(objAccount.SID)
        b.writeblanklines 1
    end if
Next

Function GetHomePath(strSID)
    On Error Resume Next
        GetHomePath = WshShell.ExpandEnvironmentStrings(Trim(WshShell.RegRead (strProfileBranch & strSID & "\ProfileImagePath")))
    On Error Goto 0
End Function

b.writeline string(61,"*")
b.close
WshShell.Run "notepad.exe " & fName

Set fso = Nothing
set Wshshell = Nothing

Also, if anyone has any other way to modify the second user's registry, I'll use that. All I need to do is silence their UAC prompt... thanks.

Edited by koresho
Link to comment
Share on other sites

Global $oAccount, $sComputer = "."
$oWMIService = ObjGet("winmgmts:\\"&$sComputer&"\root\cimv2")
$oColAccounts = $oWMIService.ExecQuery("Select * From Win32_UserAccount")

For $oAccount In $oColAccounts
        ConsoleWrite("Username: " & $oAccount.Name & @CR)
        ConsoleWrite("SID: " & $oAccount.SID & @CR&@CR)
Next

EDIT: Made small change so it outputs all users.

Edited by Simucal
AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
Link to comment
Share on other sites

Here it is an a UDF format in case anyone ever needs this:

; #_GetSid# ;===============================================================================
;
; Name...........: _GetSid
; Description....: Returns a specified users SID (if none specified, will return current users Sid)
; Syntax.........: _GetSid([$sUsername])
; Parameters.....: [Optional] $sUsername - The username of the sid you wish to retrieve
; Return values..: Success - Returns Current/Specified users SID
;                  Failure - Returns 0 and Sets @Error:
;                  |0 - No error.
;                  |1 - Specified username not found on system.
;                  |2 - User running this function does not have permission to access WMIService
; Author.........: Simucal (Matthew McDole)
; Modified.......: 02.09.2008
; Remarks........:
; Related........:
; Link...........:
; Example........:
;
;==========================================================================================

Func _GetSid($sUsername = @UserName)
    Local $oWMIService
    Local $oColAccounts
    
    $oWMIService = ObjGet("winmgmts:\\.\root\cimv2")
    If Not IsObj($oWMIService) Then
        SetError(2)
        Return 0
    EndIf
    $oColAccounts = $oWMIService.ExecQuery("Select * From Win32_UserAccount")

    For $oAccount In $oColAccounts
        If $oAccount.Name = $sUsername Then
            SetError(0)
            Return $oAccount.Sid
        EndIf
    Next
    SetError(1)
    Return 0
EndFunc   ;==>_GetSidoÝ÷ ØLZ^jëh×6ConsoleWrite(_GetSid()&@CR) ; Display current users sid
ConsoleWrite(_GetSid("HelpAssistant")&@CR) ; Display specified users sid

And it would work fine.

Edited by Simucal
AutoIt Scripts:Aimbot: Proof of Concept - PixelSearching Aimbot with several search/autoshoot/lock-on techniques.Sliding Toolbar - Add a nice Sliding Toolbar to your next script. Click the link to see an animation of it in action!FontInfo UDF - Get list of system fonts, or search to see if a particular font is installed.Get Extended Property UDF - Retrieve a files extended properties (e.g., video/image dimensions, file version, bitrate of song/video, etc)
Link to comment
Share on other sites

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...