Thursday, July 8, 2010

Run as admin, when not an admin

We have a development group here at work requesting RDP access to a certification server in order to run the ANT profiler against their code.  Sure, drop their account in the Remote Desktop Users group and off they go.  A few minutes go by and a new email shows up in my inbox:

"Could you please add us to the local admin group?  Apparently ANT requires local admin rights in order to run."

Hmmm, let me ponder this question for a moment, NO.  So, what do we do.  Again, .NET comes to the rescue with the Process class.  Whip up a few lines of C# code, obfuscate the exe, then ask them to run the executable which worked wonderfully.  They were now running this particular process as a local admin, without being an admin.

 static void Main(string[] args)  
     {  
       string pw = "*****";  
       SecureString secureString = new SecureString();  
       foreach (char ch in pw)  
       {  
         secureString.AppendChar(ch);  
       }  
       Process procLaunch = new Process();  
       procLaunch.StartInfo.UseShellExecute = false;  
       procLaunch.StartInfo.UserName = "localadminaccount";  
       procLaunch.StartInfo.Password = secureString;  
       procLaunch.StartInfo.FileName = @"pathtoexe";  
       procLaunch.Start();  
     }  

No comments:

Post a Comment