标签: system.security

PowerShell - Get-Credential解码密码?

我想在我的代码中使用Get-Credential cmdlet.

如何从System.Security.SecureString格式轻松解码密码?

(我必须在代码的一个部分以明文格式使用密码)

$credential = Get-Credential
$credential.Password | ConvertFrom-SecureString
$credential
#How to show password in text format?
Run Code Online (Sandbox Code Playgroud)

我的解决方法,但我认为还有一个正常的方法

$credCachePS = New-Object System.Net.CredentialCache 
$credCachePS.Add("uridummy", "NTLM", $credential) 
$credCachePS | select Password
Run Code Online (Sandbox Code Playgroud)

powershell credentials system.security

28
推荐指数
2
解决办法
3万
查看次数

PowerShell - 将System.Security.SecureString解码为可读密码

我想将System.Security.SecureString中的密码解码为可读密码.

$password = convertto-securestring "TestPassword" -asplaintext -force
$credentials = New-Object System.Net.NetworkCredential("TestUsername", $password, "TestDomain")
Run Code Online (Sandbox Code Playgroud)

这段代码部分工作正常,我可以使用$ credentials对象.但后来在我的代码中,我需要以可读格式输入密码.因为methode需要可读字符串中的密码.所以我必须解密密码.

如何解码$ credentials对象的密码?

更新

不工作:

$password = convertto-securestring "TestPassword" -asplaintext -force
$credentials = New-Object System.Net.NetworkCredential("TestUsername", $password, "TestDomain")

$Ptr = [System.Runtime.InteropServices.Marshal]::SecureStringToCoTaskMemUnicode($credentials.password)
$result = [System.Runtime.InteropServices.Marshal]::PtrToStringUni($Ptr)
[System.Runtime.InteropServices.Marshal]::ZeroFreeCoTaskMemUnicode($Ptr)
$result 
Run Code Online (Sandbox Code Playgroud)

powershell system.security powershell-2.0

21
推荐指数
5
解决办法
4万
查看次数

使用纯.net Framework生成和签署证书请求

我正在尝试使用纯.net代码来创建证书请求,并根据我可用的现有CA证书(在Windows证书存储区中或作为单独的文件)从证书请求创建证书.

我知道我有类X509CertificateX509Certificate2可供加载证书并访问他们的信息,但我没有看到中的任何类或功能System.Security.Cryptography,可以用来创建证书请求或签署这样的证书请求创建命名空间新签名证书.

虽然关于System.Security.Cryptography.Pkcs命名空间文档说:

System.Security.Cryptography.Pkcs命名空间提供公钥加密标准(PKCS)的编程元素,包括签名数据,交换密钥,请求证书,公钥加密和解密以及其他安全功能的方法.

那么,如何创建证书请求并使用纯.net类来签署该请求以创建新的X509证书System.Security.Cryptography


注意:

  • 我不想使用像openssl或MakeCert这样的外部可执行文件
  • 我不想使用BouncyCastle
  • 我不想使用Windows 证书注册API
  • 我不想使用本机Win32 API函数

.net c# cryptography system.security

19
推荐指数
2
解决办法
1万
查看次数

SSRS检查组中的用户是否使用自定义程序集

我为我的SSRS项目创建了一个自定义程序集.

Custom Assembly有2个功能,IsInGroup并且MyTest:

using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Principal;

namespace SSRS_Custom_Fuctions
{
    public class Class1
    {

        public static bool IsInGroup(string user, string group)
        {
            using (var identity = new WindowsIdentity(user))
            {
                var principal = new WindowsPrincipal(identity);
                return principal.IsInRole(group);
            }
        }

        public static string MyTest()
        {
            return "Hello World";
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

1)MyTest返回字符串'Hello World' 的基本函数在使用表达式的Report中完全正常工作=SSRS_Custom_Functions.Class1.MyTest()

2)IsInGroup返回布尔值的函数不起作用.这是使用System.Security.Principal命名空间来检查传递给函数的用户名是否存在于传递给函数的组中.尝试使用表达式调用它时=SSRS_Custom_Functions.Class1.IsInGroup(User.User1, "MyGroupName"),报告正在退出,并显示以下错误消息:

请求System.Security类型的权限失败

我已根据Microsoft KB920769修改了rssrvpolicy.configReportingServices文件路径和RSPreviewPolicy.configVisualStudio文件路径中的配置文件. …

.net c# system.security reporting-services ssrs-2008

8
推荐指数
1
解决办法
1240
查看次数

WCF中基于令牌的身份验证

我正在创建一个包含ASP.NET页面和Flash小程序的网站.我希望将我的业务逻辑封装在WCF服务中,该服务将通过两个端点公开:一个可通过HTTP(S)访问Internet,供Flash客户端使用,另一个可在数据中心内访问,供应用程序服务器使用.如果这似乎不是一个好方法,那么请阻止我; 否则,我会继续......

问题是如何验证来自Flash客户端的请求.由于我不想将用户的密码存储在浏览器cookie中,因此不希望每次请求都发送密码,并且不希望在初次登录后使用HTTPS,我打算使用令牌 - 基于认证系统.我也不希望用户在登录网站后必须登录Flash客户端,因此我计划在启动时使用Javascript将令牌传递给Flash客户端.

我知道WCF支持使用.NET Framework的内置安全框架(System.Security)来强制实施访问控制,我想利用这一点.

那么问题是: 如何在Flash调用令牌时将令牌传递给WCF服务,以及如何在服务器上处理令牌?

  • WCF具有"颁发令牌"身份验证模式,但看起来这应该用于具有安全令牌服务和SAML令牌的完整联合方案 - 这是我真正想要的复杂性.可以将此模式与我自己的"简单随机字符串"令牌一起使用吗?如果是这样,怎么样?请记住,这需要与Flash兼容.
  • 我可能会在标头中传递令牌(SOAP标头或HTTP标头).在这种情况下,一旦我确定了哪个用户正在发出请求,我该如何通知框架以便System.Security检查能够正常工作?
  • 我应该考虑采用不同的方法吗?任何避免在每个请求中发送密码的东西,让我使用System.Security,并且可以使用Flash.

authentication flash wcf token system.security

5
推荐指数
1
解决办法
4855
查看次数

RSA 加密返回不同的输出

我是 RSA 加密的新手,我一直在尝试使用 .Net 的System.Security.Cryptography.

    public String Encryption(Byte[] Input, RSAParameters PublicKey)
    {
        RSAC = new RSACryptoServiceProvider();
        RSAC.ImportParameters(PublicKey);
        Byte[] Encrypt = RSAC.Encrypt(Input, false);
        return Convert.ToBase64String(Encrypt);
    }
Run Code Online (Sandbox Code Playgroud)

使用上面的代码,无论何时我重新启动应用程序,我都会为相同的输入获得不同的加密字符串。我想知道这是否是正常行为,如果不是,如何预防。

例如,程序为输入“Hello”返回以下字符串:

NopDAF5FRu....
Run Code Online (Sandbox Code Playgroud)

当我重新启动应用程序时,相同输入的输出将是:

pPPu8x6....
Run Code Online (Sandbox Code Playgroud)

但是,当我为 RSA 加密类创建新对象时,所有对象都返回相同的输出。

c# encryption cryptography rsa system.security

5
推荐指数
1
解决办法
1790
查看次数

xamarin:无法解决程序集:System.Security

当我尝试部署iOS应用程序时,出现以下错误:错误MT2002:无法解析程序集:“ System.Security,版本= 2.0.0.0,文化=中性,PublicKeyToken = b03f5f7f11d50a3a”

该项目除了HelloWorld应用程序中的引用(monotouch,System,System.Core和System.Xml)之外,没有其他引用。

构建总是成功的。

我该如何解决?

.net c# system.security xamarin.ios xamarin

5
推荐指数
1
解决办法
4679
查看次数

ASP.NET WebPermission安全例外

我通常不喜欢发布这些类型的问题,因为通常我发现真正学习的最好方法是自己找出答案.

但是,我需要很快回答这个问题,因为我有一个客户由于这个问题而无法经营她的业务.

昨天,我的ASP.NET主机提供程序将我的应用程序从运行.NET 1.1的服务器移动到运行.NET 1.1和2.0的服务器.我的问题是,当我测试移动时,主站点页面(Default.aspx)将不会加载

"说明:应用程序尝试执行安全策略不允许的操作.要授予此应用程序所需的权限,请与系统管理员联系或在配置文件中更改应用程序的信任级别.

异常详细信息:System.Security.SecurityException:请求类型为'System.Net.WebPermission,System,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'的权限失败."

[SecurityException:请求类型'System.Net.WebPermission,System,Version = 2.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'的权限失败.] System.Security.CodeAccessSecurityEngine.Check(Object demand,StackCrawlMark&stackMark,Boolean isPermSet)+0 System.Security.CodeAccessPermission.Demand()+59 System.Net.HttpWebRequest..ctor(Uri uri,ServicePoint servicePoint)+147 System.Net.HttpRequestCreator.Create(Uri Uri)+26 System.Net.WebRequest .Create(Uri requestUri,Boolean useUriBase)+298 System.Net.WebRequest.Create(Uri requestUri)+28 System.Web.Services.Protocols.WebClientProtocol.GetWebRequest(Uri uri)+30 System.Web.Services.Protocols.HttpWebClientProtocol .GetWebRequest(Uri uri)+12 System.Web.Services.Protocols.SoapHttpClientProtocol.GetWebRequest(Uri uri)+4 System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName,Object [] parameters)+52 PilatesPlusDublin.PilatesPlusDublinws.PilatesPlus.InsertException(String sModuleName,String sException,Int32 iUserID)+97 PilatesPlusDublin.MainDefault.Page_Load(Object sender,EventArgs e)+ 144 System.Web.UI.Control.OnLoad(EventArgs e)+99 System.Web.UI.Control.LoadRecursive()+47 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)+7350 System.Web .UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)+213 System.Web.UI.Page.ProcessRequest()+86 System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)+18 System.Web.UI.Page .ProcessRequest(HttpContext context)+49 ASP.maindefault_aspx.ProcessRequest(HttpContext context)+4 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()+358 System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean&completedSynchronously)+64"

如果主机站点上没有WebPermission,如何配置我的站点以允许访问该页面?是否有一些标签需要放入web.config?注意 - 我们无法访问machine.config或任何其他IIS设置.

我知道人们讨厌阅读和回答这些类型的问题,但是对我或我的托管网站需要做些什么来解决这个问题的任何帮助都会非常感激

asp.net system.security

3
推荐指数
1
解决办法
1万
查看次数

列出 C# 中 System.Security.Claims.ClaimTypes 中存储的所有声明类型

使用 Asp.Net Identity 允许您向用户添加声明。System.Security.Claims.ClaimTypes允许您从各种 ClaimType选择任何 ClaimType。

ClaimTypes是一个静态类,定义了可以分配给主题的众所周知的声明类型的常量。

我想将所有这些声明存储在List<>中,并将它们显示在ListBox中,以便具有Admin角色的用户可以在注册后将 ClaimType 分配给用户。

似乎我可以做到这一点,因为ClaimTypes是一个静态类,并且其中定义的那些常量无法列出。

c# asp.net system.security claims-based-identity asp.net-identity

2
推荐指数
1
解决办法
3156
查看次数

将密码转换为256位密钥

我有一个使用256位(或128位)密钥通过AES加密的文件。传递给文件所有者并要求其保留256位密钥非常困难。

所有者如何使用更友好的密码来记住或检索实际的256位密钥?

cryptography system.security

2
推荐指数
1
解决办法
88
查看次数