Password Encryption in MSBuild File

I want to encrypt the password that I provide in the following code:

<Target Name="Default"> <!-- Install a service on a Remote Machine --> <MSBuild.ExtensionPack.Computer.WindowsService TaskAction="Install" ServiceName="__TestService1" User="$(User)" Password="$(password)" ServicePath="c:\WINDOWS\system32\taskmgr.exe" RemoteUser="$(RemoteUser)" RemoteUserPassword="$(RemoteUserPassword)" MachineName="$(RemoteMachine)" /> </Target> 

I do not want to hardcode the password. How can I encrypt it? Please provide your suggestion. I googled, but could not find a solution that would work for me.

Thanks.

+4
source share
1 answer

There are many ways to do this. I describe only two simplest:

Have you ever thought about using the NTFS Encrypting File System feature?

Save the password in the file as plain text and mark the file as encrypted. Then only the user file (by default) has access to the file (if you are more paranoid, you can restrict access using the appropriate ACL setting for this password file). Then you can read the password easily.

 <ReadLinesFromFile File="$(PasswordFile)" > <Output TaskParameter="Lines" ItemName="Password"/> </ReadLinesFromFile> 

Another option is to save the password in the registry (HKLM or HKCU), configure the permission of the selected user for the key. You can easily read registry values

To prevent direct reading of the password with ntuser.dat (registry storage - you can encrypt the password with a built-in task , for example, this way http://msdn.microsoft.com/en-us/library/ff649224.aspx )

+2
source

Source: https://habr.com/ru/post/1481868/


All Articles