mirror of
https://github.com/vxunderground/MalwareSourceCode.git
synced 2024-12-19 09:56:10 +00:00
155 lines
6.7 KiB
C#
155 lines
6.7 KiB
C#
|
// Decompiled with JetBrains decompiler
|
|||
|
// Type: Microsoft.InfoCards.RequestSecurityToken
|
|||
|
// Assembly: infocard, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
|
|||
|
// MVID: 516D8B44-4448-4D2C-8B8E-FFBB3FFE472B
|
|||
|
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00000-msil\Virus.Win32.Expiro.w-69bb73081eac86b8cf86f45e33515d0095855636967076e2b593d7a30cd80a07.exe
|
|||
|
|
|||
|
using Microsoft.InfoCards.Diagnostics;
|
|||
|
using System;
|
|||
|
using System.Globalization;
|
|||
|
using System.ServiceModel.Channels;
|
|||
|
using System.ServiceModel.Security.Tokens;
|
|||
|
using System.Xml;
|
|||
|
|
|||
|
namespace Microsoft.InfoCards
|
|||
|
{
|
|||
|
internal abstract class RequestSecurityToken : BodyWriter
|
|||
|
{
|
|||
|
protected RequestSecurityTokenParameters m_rstParams;
|
|||
|
protected RequestSecurityTokenSerializer m_serializer;
|
|||
|
protected XmlDictionaryWriter m_xmlWriter;
|
|||
|
|
|||
|
protected ProtocolProfile ProtocolVersionProfile => this.m_rstParams.Profile;
|
|||
|
|
|||
|
protected InfoCardPolicy Policy => this.m_rstParams.Policy;
|
|||
|
|
|||
|
protected RequestSecurityTokenSerializer Serializer
|
|||
|
{
|
|||
|
get => this.m_serializer;
|
|||
|
set => this.m_serializer = value;
|
|||
|
}
|
|||
|
|
|||
|
protected XmlDictionaryWriter Writer
|
|||
|
{
|
|||
|
get => this.m_xmlWriter;
|
|||
|
set => this.m_xmlWriter = value;
|
|||
|
}
|
|||
|
|
|||
|
protected string WstPrefix => this.ProtocolVersionProfile.WSTrust.DefaultPrefix;
|
|||
|
|
|||
|
public RequestSecurityToken(RequestSecurityTokenParameters rstParams)
|
|||
|
: base(false)
|
|||
|
{
|
|||
|
this.m_rstParams = rstParams;
|
|||
|
}
|
|||
|
|
|||
|
protected virtual void WriteRSTOpeningElement()
|
|||
|
{
|
|||
|
this.Writer.WriteStartElement(this.WstPrefix, this.ProtocolVersionProfile.WSTrust.RequestSecurityToken, this.ProtocolVersionProfile.WSTrust.Namespace);
|
|||
|
this.Writer.WriteAttributeString(this.ProtocolVersionProfile.WSTrust.Context, (string) null, this.m_rstParams.Context);
|
|||
|
}
|
|||
|
|
|||
|
protected virtual void WriteInfoCardReferenceElement()
|
|||
|
{
|
|||
|
if (this.m_rstParams.Card == null)
|
|||
|
return;
|
|||
|
this.Serializer.WriteInfoCardReferenceElement(this.m_rstParams.Card);
|
|||
|
}
|
|||
|
|
|||
|
protected virtual void WriteKeyTypeElement() => this.Serializer.WriteKeyTypeElement(this.Policy.GetKeyTypeString());
|
|||
|
|
|||
|
protected virtual void WriteKeySupportingElements()
|
|||
|
{
|
|||
|
if (this.Policy.KeyType == SecurityKeyTypeInternal.SymmetricKey)
|
|||
|
{
|
|||
|
this.Serializer.WriteKeySizeElement(this.Policy.GetIntelligentKeySize(false).ToString((IFormatProvider) CultureInfo.InvariantCulture));
|
|||
|
InfoCardTrace.Assert(null != this.m_rstParams.ClientEntropyForSymmetric, "Should not be null");
|
|||
|
this.Serializer.WriteBinarySecretElement(new BinarySecretSecurityToken(this.m_rstParams.ClientEntropyForSymmetric));
|
|||
|
if (!string.IsNullOrEmpty(this.Policy.OptionalRstParams.EncryptWith))
|
|||
|
this.Serializer.WriteEncryptWithElement(this.Policy.OptionalRstParams.EncryptWith);
|
|||
|
if (string.IsNullOrEmpty(this.Policy.OptionalRstParams.SignWith))
|
|||
|
return;
|
|||
|
this.Serializer.WriteSignWithElement(this.Policy.OptionalRstParams.SignWith);
|
|||
|
}
|
|||
|
else if (SecurityKeyTypeInternal.AsymmetricKey == this.Policy.KeyType)
|
|||
|
{
|
|||
|
if (XmlNames.WSSpecificationVersion.WSTrustOasis2007 == this.ProtocolVersionProfile.WSTrust.Version && !string.IsNullOrEmpty(this.Policy.OptionalRstParams.KeyWrapAlgorithm))
|
|||
|
this.Serializer.WriteKeyWrapAlgorithmElement(this.Policy.OptionalRstParams.KeyWrapAlgorithm);
|
|||
|
this.Serializer.WriteKeySizeElement(this.Policy.GetIntelligentKeySize(false).ToString((IFormatProvider) CultureInfo.InvariantCulture));
|
|||
|
InfoCardTrace.Assert(null != this.m_rstParams.RSAKey, "Should have been populated in asymmetric case");
|
|||
|
this.Serializer.WriteUseKeyElement(this.m_rstParams.RSAKey.GetXml());
|
|||
|
if (!string.IsNullOrEmpty(this.Policy.OptionalRstParams.EncryptWith))
|
|||
|
this.Serializer.WriteEncryptWithElement(this.Policy.OptionalRstParams.EncryptWith);
|
|||
|
if (string.IsNullOrEmpty(this.Policy.OptionalRstParams.SignWith))
|
|||
|
return;
|
|||
|
this.Serializer.WriteSignWithElement(this.Policy.OptionalRstParams.SignWith);
|
|||
|
}
|
|||
|
else
|
|||
|
InfoCardTrace.Assert(SecurityKeyTypeInternal.NoKey == this.Policy.KeyType, "Should be no proof key");
|
|||
|
}
|
|||
|
|
|||
|
protected virtual void WriteRequestTypeElement()
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(this.Policy.RequestType))
|
|||
|
this.Serializer.WriteRequestTypeElement(this.Policy.RequestType);
|
|||
|
else
|
|||
|
this.Serializer.WriteRequestTypeElement(this.ProtocolVersionProfile.WSTrust.IssueRequestType);
|
|||
|
}
|
|||
|
|
|||
|
protected virtual void WritePPIDElement()
|
|||
|
{
|
|||
|
if (this.m_rstParams.Card == null || !this.m_rstParams.Card.GetClaims().ContainsKey(InfoCardConstants.PPIDClaimsUri))
|
|||
|
return;
|
|||
|
this.Serializer.WritePPIDElement(Utility.CreateHash(this.m_rstParams.Card.Key, Convert.FromBase64String(this.Policy.ImmediateTokenRecipient.GetOrganizationPPIDIdentifier()), this.m_rstParams.Card.HashSalt));
|
|||
|
}
|
|||
|
|
|||
|
protected virtual void WriteEncryptionAlgorithmElement()
|
|||
|
{
|
|||
|
if (string.IsNullOrEmpty(this.Policy.OptionalRstParams.EncryptionAlgorithm))
|
|||
|
return;
|
|||
|
this.Serializer.WriteEncryptionAlgorithmElement(this.Policy.OptionalRstParams.EncryptionAlgorithm);
|
|||
|
}
|
|||
|
|
|||
|
protected virtual void WriteClaimsElement() => this.Serializer.WriteClaimsElement(this.m_rstParams.DisclosedClaims, this.Policy.RequiredClaims, this.Policy.OptionalClaims);
|
|||
|
|
|||
|
protected virtual void WriteDisplayTokenElement()
|
|||
|
{
|
|||
|
if (this.m_rstParams.Culture == null)
|
|||
|
return;
|
|||
|
this.Serializer.WriteDisplayTokenElement(this.m_rstParams.Culture);
|
|||
|
}
|
|||
|
|
|||
|
protected virtual void WriteTokenTypeElement()
|
|||
|
{
|
|||
|
if (string.IsNullOrEmpty(this.Policy.OptionalRstParams.TokenType))
|
|||
|
return;
|
|||
|
this.Serializer.WriteTokenTypeElement(this.Policy.OptionalRstParams.TokenType);
|
|||
|
}
|
|||
|
|
|||
|
protected virtual void WritePassOnElements() => this.Policy.OptionalRstParams.WritePassOnElements(this.Writer, this.ProtocolVersionProfile);
|
|||
|
|
|||
|
protected virtual void WriteUnprocessedPolicyElements()
|
|||
|
{
|
|||
|
if (this.Policy.UnprocessedPolicyElements == null || this.Policy.UnprocessedPolicyElements.Length <= 0L)
|
|||
|
return;
|
|||
|
this.Serializer.WriteUnprocessedPolicyElements(this.Policy.UnprocessedPolicyElements);
|
|||
|
}
|
|||
|
|
|||
|
protected abstract void WriteSecondaryParametersElement();
|
|||
|
|
|||
|
protected virtual void WriteEndElement() => this.Writer.WriteEndElement();
|
|||
|
|
|||
|
protected abstract void WriteAppliesToElement();
|
|||
|
|
|||
|
protected virtual void InitializeWriters(XmlDictionaryWriter writer)
|
|||
|
{
|
|||
|
this.Writer = writer;
|
|||
|
this.Serializer = new RequestSecurityTokenSerializer((XmlWriter) writer, this.ProtocolVersionProfile);
|
|||
|
}
|
|||
|
|
|||
|
protected override void OnWriteBodyContents(XmlDictionaryWriter writer) => this.CustomWriteBodyContents(writer);
|
|||
|
|
|||
|
protected abstract void CustomWriteBodyContents(XmlDictionaryWriter writer);
|
|||
|
}
|
|||
|
}
|