mirror of
https://github.com/vxunderground/MalwareSourceCode.git
synced 2024-12-22 19:36:11 +00:00
f2ac1ece55
add
121 lines
3.4 KiB
C#
121 lines
3.4 KiB
C#
// Decompiled with JetBrains decompiler
|
|
// Type: Microsoft.InfoCards.GlobalId
|
|
// 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.Runtime.InteropServices;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
|
|
namespace Microsoft.InfoCards
|
|
{
|
|
[StructLayout(LayoutKind.Explicit, Size = 16)]
|
|
internal struct GlobalId
|
|
{
|
|
public const int StructSize = 16;
|
|
public static readonly GlobalId Empty = (GlobalId) Guid.Empty;
|
|
private static readonly byte[] HASHPREFIX = new byte[16]
|
|
{
|
|
(byte) 126,
|
|
(byte) 85,
|
|
(byte) 219,
|
|
(byte) 17,
|
|
(byte) 52,
|
|
(byte) 221,
|
|
(byte) 70,
|
|
(byte) 150,
|
|
(byte) 168,
|
|
(byte) 123,
|
|
(byte) 15,
|
|
(byte) 254,
|
|
(byte) 196,
|
|
(byte) 77,
|
|
(byte) 155,
|
|
(byte) 168
|
|
};
|
|
|
|
public GlobalId(byte[] guidBytes)
|
|
: this(new Guid(guidBytes))
|
|
{
|
|
}
|
|
|
|
public unsafe GlobalId(Guid guid)
|
|
{
|
|
fixed (GlobalId* globalIdPtr = &this)
|
|
*globalIdPtr = (GlobalId) guid;
|
|
}
|
|
|
|
public byte[] ToByteArray() => ((Guid) this).ToByteArray();
|
|
|
|
public override int GetHashCode() => ((Guid) this).GetHashCode();
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
switch (obj)
|
|
{
|
|
case GlobalId _:
|
|
case Guid _:
|
|
return (GlobalId) obj == this;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public override string ToString() => ((Guid) this).ToString("D");
|
|
|
|
public static bool operator !=(GlobalId a, GlobalId b) => !(a == b);
|
|
|
|
public static unsafe bool operator ==(GlobalId a, GlobalId b)
|
|
{
|
|
byte* numPtr1 = (byte*) &a;
|
|
byte* numPtr2 = (byte*) &b;
|
|
for (int index = 0; index < sizeof (GlobalId); ++index)
|
|
{
|
|
if ((int) numPtr1[index] != (int) numPtr2[index])
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public static unsafe implicit operator Guid(GlobalId id) => *(Guid*) &id;
|
|
|
|
public static unsafe implicit operator GlobalId(Guid guid) => *(GlobalId*) &guid;
|
|
|
|
public static GlobalId DeriveFrom(string value)
|
|
{
|
|
value = !string.IsNullOrEmpty(value) ? value.Trim() : throw InfoCardTrace.ThrowHelperArgumentNull(nameof (value));
|
|
value = value.ToLower(CultureInfo.InvariantCulture);
|
|
using (SHA256Managed shA256Managed = new SHA256Managed())
|
|
{
|
|
byte[] numArray = new byte[Encoding.Unicode.GetByteCount(value) + GlobalId.HASHPREFIX.Length];
|
|
Array.Copy((Array) GlobalId.HASHPREFIX, 0, (Array) numArray, 0, GlobalId.HASHPREFIX.Length);
|
|
Encoding.Unicode.GetBytes(value, 0, value.Length, numArray, GlobalId.HASHPREFIX.Length);
|
|
byte[] hash = shA256Managed.ComputeHash(numArray);
|
|
return new GlobalId(new byte[16]
|
|
{
|
|
hash[3],
|
|
hash[2],
|
|
hash[1],
|
|
hash[0],
|
|
hash[5],
|
|
hash[4],
|
|
hash[7],
|
|
(byte) ((int) hash[6] & 15 | 48),
|
|
(byte) ((int) hash[8] & 63 | 128),
|
|
hash[9],
|
|
hash[10],
|
|
hash[11],
|
|
hash[12],
|
|
hash[13],
|
|
hash[14],
|
|
hash[15]
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|