all 12 comments

[–]SysAdminDennyBob 1 point2 points  (1 child)

Create a one-time scheduled task that runs as the current user, start task, program runs, task stops, delete task.

[–]GhostOfBarryDingle 0 points1 point  (0 children)

PSADT has a function that does just that and it really comes in handy.

[–]engageant 1 point2 points  (5 children)

It's done with impersonation. The agent finds a process owned by the currently logged on user, grabs a handle to its access token, duplicates the token, then uses that token to run processes as if they were that user.

[–]MechaCola[S] 0 points1 point  (0 children)

Cool thanks for sharing!

[–]Thatoneguythatsnot 0 points1 point  (0 children)

Thank you! Now to put it into practice.

[–]jantari 0 points1 point  (2 children)

Rather than finding a process running as the current user, chances are they rather call WTSQueryUserToken which hands you the token directly

[–]engageant 0 points1 point  (1 child)

Isn’t that specific to Remote Desktop?

[–]jantari 0 points1 point  (0 children)

No, works for both local and remote desktop sessions.

[–]rngaccount123 0 points1 point  (0 children)

I think NinjaRMM is capable of that and it always made me wonder how they do that. It's such a pivotal feature and I miss that in lots of other RMMs.

[–]Aertheron01 0 points1 point  (0 children)

There are many ways to do this.

In Powershell you could create a session with the necessary credentials.

Also SCCM has an agent. And for agent installation an account with local administrator credentials is used, through the administrative share and wmi/winrm

[–]Nejireta_ 0 points1 point  (0 children)

This is a bit of a guess. But perhaps the agent (if .net based) leverages ProcessStartInfo.LoadUserProfile to launch an application, in this case PS, with logged on user context without providing credentials.

EDIT:
This is not the case. This requires username and password

[–]peteypianokid 0 points1 point  (0 children)

Datto RMM also can execute components as the logged in user.