UPDATED: 5/30/2013 to cover same flaw in EnSc.exe.
There is a reason that the RunAs program doesn’t accept credentials on the command line…because people would embed passwords. Microsoft developer Raymond Chen writes:
If this offends you and you want to be insecure and pass the password on the command line anyway (for everyone to see in the command window title bar), you can write your own program that calls the
Enter the many products that offer a way to "securely" embed credentials in a shortcut or file in order to launch an executable as an administrator.
Wingnut Software offers their commercial 'Encrypted RunAs' application as a way for administrators to created encrypted shortcut commands that will launch applications with Administrative credentials. The selling point is that these credentials (which an administrator would provide when creating the shortcut) are protected in an encrypted command.
So I thought I'd download it and take a look at how it protects against the username and password being monitored and captured by a user with only standard USER rights. Note that I am *not* testing how well ERunAs encrypts the command...it appears to encrypt the command and credentials as strongly as advertised. However, I'm looking to see what happens after ERunAs decrypts everything and has to pass data to the operating system (and if I can capture that).
Spoiler, as a standard user I could monitor the parameters passed by ERunAs to the CreateProcessWithLogonW API and see the administrator's username and password that were encrypted in the shortcut:
Encrypted RunAs is a small utility that is designed to make the job of Administrators a little easier, it can be used to run applications or software installations with access rights a standard user does not have.
I created an encrypted shortcut to run "notepad.exe" as the local administrator named "ALincoln" with a password of "Fubard123".
Using the free API Monitor application, I was able to run it as a standard user (see below, I'm demonstrating I'm a standard user and that API Monitor is not elevated, but running with limited user rights), and I set a filter within API Monitor on the CreateProcessWithLogonW API.
From there I called ERunAs.exe, supplying the "Notepad.eras" file as it's parameter (just like the shortcut does that Encrypted RunAs creates):
And seconds after clicking OK, I can see that the CreateProcessWithLogonW API was called by ERunAs.exe and I can see the parameters passed in clear text:
This means that if a standard user can access ERunAs.exe and the command it uses, the user can capture the administrative credentials used.
Now, I've been picking on 1 product so far, but I've confirmed this same method works to capture credentials from JoeWare's CPAU, and Quimeras' TqcRunas. I would expect this to work with any application that passes credentials to the CreateProcessWithLogonW API.
Based on feedback from a commenter, I also looked at EnSc (Encrypted Shortcut Creator). I found that using the same method as above, I can still capture the administrator's credentials at the time the process is called. This can be done by a user without administrative rights...meaning any user that runs an EnSc created shortcut or has access to the shortcut, and the "ensc.db" file created by the program on first run (when master password is set).