Jump to content

Process security


Vaner
 Share

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: 3.2.8.1
 Author:         myName

 Script Function:
    Template AutoIt script.

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

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

;sleep(5000)
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()

;MsgBox(4096,"d",$ProcessHwd)

; 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)

_API_CloseHandle($hToken)
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)))
Link to comment
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
 Share

  • Recently Browsing   0 members

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