【问题标题】:Powershell - Make SecureString available for other userPowershell - 使 SecureString 可供其他用户使用
【发布时间】:2020-01-07 07:33:51
【问题描述】:

我有一个应用程序,我必须在其中存储密码。这个应用程序被 SYSTEM 用户调用。我已经对脚本进行了模糊处理并将其存储在安全位置。

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

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

感谢您的帮助:)

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

【问题讨论】:

  • 问:有什么方法可以创建一个可以被一个或多个其他用户解密的 SecureString?答:当然。使用密钥对其进行加密,并为“其他用户”提供对密钥的安全访问权限。问:有什么方法可以在没有密钥的情况下加密和解密 SecureString?答:据我所知没有;)

标签: powershell securestring


【解决方案1】:

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

将其反转
$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...
...
#> 

【讨论】:

  • 还有一个“密钥”,它仍然存储在文件系统中……但这是一个很好的建议!
  • 是的,但密钥在每个新用例中都是唯一的,因为您可以在初始启动时生成密钥。
  • 非常感谢您的回答@postanote。 CredentialManager 方法是一个不错的建议。我一定会看看它?
  • 我现在使用的解决方案是使用密钥加密 SecureString,然后使用 CredentialManager 包将此密钥存储在 Windows 凭据存储中。它仍然在某种程度上不安全,但这不可能是 100% 安全的。它只是给它增加了一层额外的晦涩。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-10
  • 1970-01-01
  • 2016-03-09
相关资源
最近更新 更多