一般的模块<Module>是个空类,但是遇到一个处理过的。处理方法不清楚。
这个类构有非空造函数和方法,调用了VirtualProtect,方法名是空字符串。
internal class <Module>
{
static <Module>()
{
<Module>.*********();
}
[System.Runtime.InteropServices.DllImport("kernel32.dll", EntryPoint = "VirtualProtect")]
internal static extern bool *********(System.IntPtr, uint, uint, ref uint);
internal unsafe static void *********()
{
System.Reflection.Module module = typeof(<Module>).Module;
string fullyQualifiedName = module.FullyQualifiedName;
bool flag = fullyQualifiedName.Length > 0 && fullyQualifiedName[0] == '<';
byte* ptr = (byte*)((void*)System.Runtime.InteropServices.Marshal.GetHINSTANCE(module));
byte* ptr2 = ptr + *(uint*)(ptr + 60);
ushort num = *(ushort*)(ptr2 + 6);
ushort num2 = *(ushort*)(ptr2 + 20);
uint* ptr3 = null;
uint num3 = 0u;
uint* ptr4 = (uint*)(ptr2 + 24 + num2);
uint num4 = 1944716907u;
uint num5 = 3396842843u;
uint num6 = 144243033u;
uint num7 = 1918455554u;
for (int i = 0; i < (int)num; i++)
{
uint num8 = *(ptr4++) * *(ptr4++);
if (num8 == 3512859536u)
{
ptr3 = (uint*)(ptr + (flag ? ptr4[3] : ptr4[1]) / 4u);
num3 = (flag ? ptr4[2] : (*ptr4)) >> 2;
}
else if (num8 != 0u)
{
uint* ptr5 = (uint*)(ptr + (flag ? ptr4[3] : ptr4[1]) / 4u);
uint num9 = ptr4[2] >> 2;
for (uint num10 = 0u; num10 < num9; num10 += 1u)
{
uint num11 = (num4 ^ *(ptr5++)) + num5 + num6 * num7;
num4 = num5;
num5 = num7;
num7 = num11;
}
}
ptr4 += 8;
}
uint[] array = new uint[16];
uint[] array2 = new uint[16];
for (int j = 0; j < 16; j++)
{
array[j] = num7;
array2[j] = num5;
num4 = (num5 >> 5 | num5 << 27);
num5 = (num6 >> 3 | num6 << 29);
num6 = (num7 >> 7 | num7 << 25);
num7 = (num4 >> 11 | num4 << 21);
}
array[0] = (array[0] ^ array2[0]);
array[1] = array[1] * array2[1];
array[2] = array[2] + array2[2];
array[3] = (array[3] ^ array2[3]);
array[4] = array[4] * array2[4];
array[5] = array[5] + array2[5];
array[6] = (array[6] ^ array2[6]);
array[7] = array[7] * array2[7];
array[8] = array[8] + array2[8];
array[9] = (array[9] ^ array2[9]);
array[10] = array[10] * array2[10];
array[11] = array[11] + array2[11];
array[12] = (array[12] ^ array2[12]);
array[13] = array[13] * array2[13];
array[14] = array[14] + array2[14];
array[15] = (array[15] ^ array2[15]);
uint num12 = 64u;
<Module>.*********((System.IntPtr)((void*)ptr3), num3 << 2, num12, ref num12);
uint num13 = 0u;
for (uint num14 = 0u; num14 < num3; num14 += 1u)
{
*ptr3 ^= array[(int)((System.UIntPtr)(num13 & 15u))];
array[(int)((System.UIntPtr)(num13 & 15u))] = (array[(int)((System.UIntPtr)(num13 & 15u))] ^ *(ptr3++)) + 1035675673u;
num13 += 1u;
}
}
}
还有第二个模块名为ConfusedByAttribute,继承System.Attribute
仅有一个构造函数
.method public hidebysig specialname rtspecialname
instance void .ctor(string A_1) cil managed
{
// 代码大小 0 (0x0)
} // end of method ConfusedByAttribute::.ctor
问题就是用Mono.Cecil读取一些类和方法都会报异常。
第一种是这样的:
---> System.InvalidOperationException: 对象的当前状态使该操作无效。
在 Mono.Cecil.Cil.CodeReader.ReadMethodBody()
在 Mono.Cecil.Cil.CodeReader.ReadMethodBody(MethodDefinition method)
在 Mono.Cecil.MethodDefinition.<get_Body>b__2(MethodDefinition method, MetadataReader reader)
在 Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TRet& variable, TItem item, Func`3 read)
在 Mono.Cecil.MethodDefinition.get_Body()
第二种是这样的:
---> System.IndexOutOfRangeException: 索引超出了数组界限。
在 Mono.Cecil.Cil.CodeReader.ReadOpCode()
在 Mono.Cecil.Cil.CodeReader.ReadCode()
在 Mono.Cecil.Cil.CodeReader.ReadMethodBody()
在 Mono.Cecil.Cil.CodeReader.ReadMethodBody(MethodDefinition method)
在 Mono.Cecil.MethodDefinition.<get_Body>b__2(MethodDefinition method, MetadataReader reader)
在 Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TRet& variable, TItem item, Func`3 read)
在 Mono.Cecil.MethodDefinition.get_Body()
ILDasm也试过,也是不能正确读取,提示类型多样
.method private hidebysig instance void CallHome() cil managed
{
// 代码大小 61 (0x3d)
.maxstack 8
IL_0000: stind.i1
IL_0001: conv.u
IL_0002: br.s IL_fffffff4
IL_0004: conv.ovf.i2
IL_0005: conv.ovf.i
IL_0006: conv.r8
IL_0007: ldc.i4.1
IL_0008: unused
IL_0009: bgt.un.s IL_0018
IL_000b: stloc.s V_159
IL_000d: ldc.i8 0x352bd1adfed9a6aa
IL_0016: unused
IL_0017: unused
IL_0018: conv.i2
IL_0019: brtrue.s IL_009a
IL_001b: nop
IL_001c: unused
IL_001d: unused
IL_001e: unused
IL_001f: ldc.r4 -2.3178437e-008
IL_0024: unused
IL_0025: conv.u8
// ***指令解码错误: F8 (在位置 0x26 (38)处)
} // end of method CallHomeService::CallHome
也有这样的
.method private hidebysig static class [System]System.Uri
GetHostUri() cil managed
{
// 代码大小 9 (0x9)
.maxstack 8
IL_0000: unused
IL_0001: conv.ovf.i
IL_0002: conv.i4
IL_0003: shl
IL_0004: unused
IL_0005: bge.un.s IL_001f
IL_0007: unused
IL_0008: ldflda [ERROR: INVALID TOKEN 0xA7E38F44]
} // end of method CallHomeService::GetHostUri
有没有遇到过这种情况的,求加密原理和反编译方法!
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!