Windows Vista/Windows 7 privilege: SeDebugPrivilege & OpenProcess Windows Vista/Windows 7 privilege: SeDebugPrivilege & OpenProcess windows windows

Windows Vista/Windows 7 privilege: SeDebugPrivilege & OpenProcess


So after a lot of debugging and bothering a lot of people for information, I was finally able to track down the guy who wrote the RunWithDebugEnabled application and get a rundown of how it operates.

The problem, in this case, is that Debug programs privilege in the local policy for the domain administrator had been removed, and thus the SeDebugPrivilege token was not present in the process's access token. It can't be enabled if it's not present at all, and I still know of no way to add the privilege to an existing access token.


How the current magic works:
So the RunWithDebugEnabled magic application would use its Administrator rights to install itself as a service and start itself, thus running under the SYSTEM user account rather than the Domain Administrator. With SYSTEM privileges, the app then creates a new access token that is identical to the Administrator token, only with the SeDebugPrivilege token present. This new token is used to CreateProcessAsUser() and run the program with the newly enabled SeDebugPrivilege that was missing before.

I actually do not like this "solution" here, and have been continuing my search for a 'cleaner' way to obtain this privilege. I will be posting this as another question here on SO, which I will try to remember to link here as well to help others follow along and for future reference.

EDIT: Impersonate SYSTEM (or equivalent) from Administrator Account



I thank you all for your time and energies in helping to debug and solve this problem. It really is much appreciated!