views:

345

answers:

4

I'm writing (in C# with .NET 3.5) an administrative application which will poll multiple Windows systems for various bits of data. In many cases it will use WMI, but in some cases it may need to read remote registry or remotely execute some command or script on the polled system. This polling will happen at repeating intervals - usually nightly, but can be configured to happen more (or less) frequently. So the poll could happen as often as every 10 minutes or as rarely as once a month. It needs to happen in an automated way, without any human intervention.

These functions will require admin-level access to the polled systems. Now, I expect that in most use cases, there will be a domain, and the polling application can run as a service with Domain Admin (or equivalent) privileges, which means I do not have to worry about storing passwords - the admin setting up the app will define the service's username/password via standard Windows mechanisms.

But there's always a few black sheep out there. The program may run in nondomain environments, or in cases where some polled systems are not members of the domain. In these cases we will have to define a username and password, store them securely, then invoke this user/pass pair at the time we poll that system. So keep in mind - in this case the program being written is the user who sends password to the authenticating system.

I am not sure whether I will need to use a reversible hash which I then decrypt to plaintext at time of use, or if there is some Windows mechanism which would allow me to store and then reuse the hash only. Obviously the second mechanism is preferable; I'd like my program to either never know the password's plaintext value, or know it for the shortest amount of time possible.

I need suggestions for smart and secure ways to accomplish this.

Thanks for looking!

A: 

Well it seems that your program needs to impersonate a user other than the context under which it is already running. Although, it does look like a pretty automated process, but if it's not, can you simply not ask the administrator to put in username and password at the time this 'black-sheep' computer is being polled?

Vaibhav
A: 

Vaibhav: no, because the polling program is likely to run at night when no user is there. The polling program could potentially poll hundreds or thousands of remote systems for the data it seeks; think of it as an enterprise computer inventory tool.

quux
A: 

1800 INFORMATION suggested DPAPI's CryptProtectData in C++. Looks like the .NET expression of this is the ProtectedData class within the System.Security.Cryptography namespace. Sorry I didn't mention previously - I'm coding in C#. Will edit the question to reflect this.

This is probably the solution to my issue, but I am going to let this question cook (as unanswered) a few more days to generate other possible solutions.

quux