Jump to content
Sign in to follow this  

Process security

Recommended Posts


I am trying to start a process (autoit.EXE) from a another autoit EXE. then upgrade the security token from, the second process . can it be done or iam dead wrong on my way of doing it?

u will need to fix the $job to correct path if u want to try it

my laucher look like this:

#cs ----------------------------------------------------------------------------

 AutoIt Version:
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

#include <A3LWinAPI.au3>
#include <A3LSecurity.au3>

dim $hProcess, $tOwner, $tSID, $hToken

$Startup = DllStructCreate($tagSTARTUPINFO)
$Process = DllStructCreate($tagPROCESS_INFORMATION)

$job = '"\\mysrv\test\logon2.exe"'

$ProcessHwd  = _API_CreateProcess("", $job, 0, 0, true, 0, 0, @TempDir, DllStructGetPtr($Startup), DllStructGetPtr($Process))

; Get the current process handle
$ProcessHwd = _API_GetCurrentProcess()


; Get a token to the current process
$hToken = _Security_OpenProcessToken($Processhwd, $TOKEN_QUERY)
if $hToken = 0 then _Lib_ShowError("Unable to retrieve token")
; Get the owner information for the token
$tOwner = _Security_GetTokenInformation($hToken, $TOKENOWNER)
$hToken = _Security_OpenProcessToken($Processhwd, $TOKEN_QUERY)
_Security_AdjustTokenPrivileges($hToken,False,$PROCESS_ALL_ACCESS ,10,0,0)
_Security_SetPrivilege($hToken, "localsystem", True)

if $tOwner = 0 then _Lib_ShowError("Unable to retrieve owner")
; Show the SID for the token owner
$tSID = DllStructCreate("ptr", DllStructGetPtr($tOwner))
_Lib_ShowMsg(_Security_SidToStringSid(DllStructGetData($tSID, 1)))

Share this post

Link to post
Share on other sites

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
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.