Powershell - 使 SecureString 可供其他用户使用

标签 powershell securestring

我有一个必须在其中存储密码的应用程序。该应用程序正在由 SYSTEM 用户调用。我已经混淆了脚本并将其存储在安全位置。

现在我的问题是:是否有可能创建一个可由一个或多个其他用户解密的 SecureString?

我读过有关使用 key 对其进行加密,然后将该 key 存储在文件中的可能性,但在我看来,这只不过是一种混淆,因为可以访问 key 文件的每个人都可以解密密码。

感谢您的帮助:)

编辑:
为了澄清我的问题:我想知道除了使用 key 文件之外是否还有其他解决方案。

最佳答案

是的,众所周知,如果您强制用户输入安全字符串,输入者可以使用

来反转它
$credential = Get-Credential
$credential.UserName
$credential.Password

# Results
<#
cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:

$credential.UserName
testuser

$credential.Password
System.Security.SecureString
#>

或者使用.Net命名空间。那么,如何采取将凭据存储在用户计算机上的 Windows 凭据管理器中的方法呢?在应用程序安装中,您可以动态生成信用信息来存储,然后用于执行。每当他们运行您的代码时,您的代码都会从凭据管理器调用凭据,而无需用户交互。

MS PowerShellGallery.com 中有多个模块,当针对凭据管理器使用时,可以轻松访问和部署在系统上。

Find-Module -Name '*credential*'

<#
Version              Name                                Repository           Description                                                                           
-------              ----                                ----------           -----------                                                                           
2.0                  CredentialManager                   PSGallery            Provides access to credentials in the Windows Credential Manager                      
...
1.0.11               pscredentialmanager                 PSGallery            This module allows management and automation of Windows cached credentials.           
4.5                  BetterCredentials                   PSGallery            A (compatible) major upgrade for Get-Credential, including support for storing cred...
0.0.1                SecureCredentials                   PSGallery            This module allow to secure store encrypted credentials for running powershell daemon 
1.1.7                CredentialStore                     PSGallery            CredentialStore saves powershell credentials securely to file                         
...
1.1                  CredentialsManager                  PSGallery            The module Credentials Manager provides you with convenient and safe way to store y...
...
1.0.2                CredentialManagement                PSGallery            Manage Credentials stored in the Windows Credential Manager                           
1.1.0                PSCredentialTools                   PSGallery            PSCredentialTools provides various methods for securely storing and retrieving cred...
1.1                  New-Credential                      PSGallery            Simply creates an object (System.Management.Automation.PSCredential) that can be us...
...
#> 

关于Powershell - 使 SecureString 可供其他用户使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59624029/

相关文章:

PowerShell 理解 Get-Member

powershell - 具有延迟变量扩展的 For 循环中 "!"文字问题的解决方法

powershell - 如何使用 powershell 的 read-host 功能接受外部服务的密码?

java - Java 中的 .Net SecureString

c# - 从我的 WPF 应用程序和 C# 库跟踪内存中的敏感数据

c# - 在 ASP.NET 中使用 SecureString 有什么好处吗?

powershell - 在PowerShell中获取以P开头的目录

powershell - 写主机 “”-替代

powershell - 使用 dbPoweramp Powershell 降低 CPU 使用率

c# - MySQL SecureString作为连接字符串