Sysinternals Homepage
Forum Home Forum Home > Windows Discussions > Development
  New Posts New Posts RSS Feed - How does psexec run with elevated privileges
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How does psexec run with elevated privileges

 Post Reply Post Reply
Author
Message
dzonka View Drop Down
Newbie
Newbie


Joined: 22 February 2012
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote dzonka Quote  Post ReplyReply Direct Link To This Post Topic: How does psexec run with elevated privileges
    Posted: 22 February 2012 at 12:07pm
Hi,

How does psexec run with elevated privileges (-h option)? Does it hack the Windows? Which Win API is used to work around the UAC mechanism.

Pawel


Back to Top
MagicAndre1981 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 January 2007
Location: Germany
Status: Offline
Points: 709
Post Options Post Options   Thanks (0) Thanks(0)   Quote MagicAndre1981 Quote  Post ReplyReply Direct Link To This Post Posted: 22 February 2012 at 12:19pm
it starts a service which runs the software but it doesn't workaround the UAC. Run it from filtered token (normal cmd.exe) and you get an access denied error.


Edited by MagicAndre1981 - 22 February 2012 at 12:21pm
Back to Top
dzonka View Drop Down
Newbie
Newbie


Joined: 22 February 2012
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote dzonka Quote  Post ReplyReply Direct Link To This Post Posted: 22 February 2012 at 12:24pm
I think it is not enough to start a process with elevated privileges. It UAC is enabled the process will run with restricted privileges after impersonalization.
Back to Top
dzonka View Drop Down
Newbie
Newbie


Joined: 22 February 2012
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote dzonka Quote  Post ReplyReply Direct Link To This Post Posted: 22 February 2012 at 12:28pm
-h         If the target system is Vista or higher, has the process run with the account's elevated token, if available.

So the process can run as Administrator
Back to Top
MagicAndre1981 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 January 2007
Location: Germany
Status: Offline
Points: 709
Post Options Post Options   Thanks (0) Thanks(0)   Quote MagicAndre1981 Quote  Post ReplyReply Direct Link To This Post Posted: 22 February 2012 at 12:54pm
elevated means running with full token and not the restricted/filtered token.
Back to Top
dzonka View Drop Down
Newbie
Newbie


Joined: 22 February 2012
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote dzonka Quote  Post ReplyReply Direct Link To This Post Posted: 22 February 2012 at 1:08pm
I understand that. The issue is:

Before -h switch was introduced, psexec remote processes run with filtered token on machines where UAC was enabled. That was even though the process was created by a service.

The -h switch changes this behavior. If the switch is enabled, the remote process is created by the same service although somehow the token is full.

The question is what changes in the source code was introduced to support -h switch.
Back to Top
MagicAndre1981 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 January 2007
Location: Germany
Status: Offline
Points: 709
Post Options Post Options   Thanks (0) Thanks(0)   Quote MagicAndre1981 Quote  Post ReplyReply Direct Link To This Post Posted: 22 February 2012 at 1:33pm
I have no idea. I've only used the -h option once and so I don't know when it was added.

Wait what wj32 can tell you about it.
Back to Top
wj32 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 16 January 2009
Location: Australia
Status: Offline
Points: 971
Post Options Post Options   Thanks (1) Thanks(1)   Quote wj32 Quote  Post ReplyReply Direct Link To This Post Posted: 22 February 2012 at 8:20pm
You can call GetTokenInformation with TokenLinkedToken to get the elevated version of the token.
MCTS: Windows Internals
Process Hacker, a free and open source process viewer.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down