Merge branch 'il'

This commit is contained in:
de4dot 2014-03-11 22:07:24 +01:00
commit 5a1888452e
6 changed files with 234 additions and 83 deletions

View File

@ -38,6 +38,7 @@ namespace de4dot.code.deobfuscators.ILProtector {
FieldInfo invokerFieldInfo;
ModuleDefMD moduleProtect;
IDecrypter decrypter;
bool methodReaderHasDelegateTypeFlag;
interface IDecrypter {
byte[] Decrypt(int methodId, uint rid);
@ -82,6 +83,7 @@ namespace de4dot.code.deobfuscators.ILProtector {
{ new Version(2, 0, 9, 0), new PatchInfo(0x00023360, new PatchData(0x000056F2, nops6)) },
{ new Version(2, 0, 10, 0), new PatchInfo(0x00023B30, new PatchData(0x00005B12, nops6)) },
{ new Version(2, 0, 11, 0), new PatchInfo(0x000207C0, new PatchData(0x00018432, nops6)) },
{ new Version(2, 0, 11, 1), new PatchInfo(0x000207C0, new PatchData(0x00018432, nops6)) },
};
static readonly Dictionary<Version, PatchInfo> patchInfos64 = new Dictionary<Version, PatchInfo> {
{ new Version(2, 0, 8, 0), new PatchInfo(0x00026090, new PatchData(0x00005E0C, nops6)) },
@ -89,6 +91,7 @@ namespace de4dot.code.deobfuscators.ILProtector {
{ new Version(2, 0, 9, 0), new PatchInfo(0x00028B00, new PatchData(0x00005F70, nops6)) },
{ new Version(2, 0, 10, 0), new PatchInfo(0x00029630, new PatchData(0x00006510, nops6)) },
{ new Version(2, 0, 11, 0), new PatchInfo(0x000257C0, new PatchData(0x0001C9A0, nops6)) },
{ new Version(2, 0, 11, 1), new PatchInfo(0x000257C0, new PatchData(0x0001C9A0, nops6)) },
};
[DllImport("kernel32")]
@ -267,7 +270,7 @@ namespace de4dot.code.deobfuscators.ILProtector {
}
}
// 2.0.9.0 - 2.0.11.0
// 2.0.9.0 - 2.0.11.1
class DecrypterV2_0_9_0 : DecrypterBase {
DecryptMethod decryptMethod;
byte[] decryptedData;
@ -297,6 +300,112 @@ namespace de4dot.code.deobfuscators.ILProtector {
}
}
abstract class DecrypterBaseV2_0_12_x : IDecrypter {
protected readonly DynamicMethodsDecrypter dmd;
protected byte[] currentILBytes;
byte[] decryptedData;
readonly Delegate invoker;
protected readonly IntPtr pGetILBytes;
protected readonly IntPtr pDecryptCallback;
protected unsafe DecrypterBaseV2_0_12_x(DynamicMethodsDecrypter dmd) {
this.dmd = dmd;
this.invoker = (Delegate)dmd.invokerFieldInfo.GetValue(null);
byte* p = (byte*)GetStateAddr(invoker.Target);
p += IntPtr.Size * 3;
p = *(byte**)p;
p += 8 + IntPtr.Size * 8;
p = *(byte**)p;
p += IntPtr.Size * 3;
p = *(byte**)p;
pGetILBytes = new IntPtr(p + IntPtr.Size * 39);
pDecryptCallback = new IntPtr(p + IntPtr.Size * 40);
}
IntPtr GetStateAddr(object obj) {
var flags = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
foreach (var fi in obj.GetType().GetFields(flags)) {
if (fi.FieldType == typeof(IntPtr))
return (IntPtr)fi.GetValue(obj);
}
throw new ApplicationException("Could not find an IntPtr field");
}
public byte[] Decrypt(int methodId, uint rid) {
decryptedData = null;
currentILBytes = dmd.reflectionModule.ResolveMethod(0x06000000 + (int)rid).GetMethodBody().GetILAsByteArray();
invoker.DynamicInvoke(new object[1] { methodId });
return decryptedData;
}
protected unsafe void SaveDecryptedData(byte* pMethodCode, int methodSize) {
decryptedData = new byte[methodSize];
Marshal.Copy(new IntPtr(pMethodCode), decryptedData, 0, decryptedData.Length);
}
}
// 2.0.12.0 - 2.0.12.2
class DecrypterV2_0_12_0 : DecrypterBaseV2_0_12_x {
readonly GetCallerMethodAsILByteArrayDelegate getCallerMethodAsILByteArrayDelegate;
readonly DecryptCallbackDelegate decryptCallbackDelegate;
[return: MarshalAs(UnmanagedType.SafeArray)]
delegate byte[] GetCallerMethodAsILByteArrayDelegate(IntPtr a, int skipFrames);
unsafe delegate bool DecryptCallbackDelegate(IntPtr a, byte* pMethodCode, int methodSize, int methodId);
public unsafe DecrypterV2_0_12_0(DynamicMethodsDecrypter dmd)
: base(dmd) {
getCallerMethodAsILByteArrayDelegate = GetCallerMethodAsILByteArray;
decryptCallbackDelegate = MyDecryptCallback;
*(IntPtr*)pGetILBytes = Marshal.GetFunctionPointerForDelegate(getCallerMethodAsILByteArrayDelegate);
*(IntPtr*)pDecryptCallback = Marshal.GetFunctionPointerForDelegate(decryptCallbackDelegate);
}
byte[] GetCallerMethodAsILByteArray(IntPtr a, int skipFrames) {
return currentILBytes;
}
unsafe bool MyDecryptCallback(IntPtr a, byte* pMethodCode, int methodSize, int methodId) {
SaveDecryptedData(pMethodCode, methodSize);
return true;
}
}
// 2.0.12.3
class DecrypterV2_0_12_3 : DecrypterBaseV2_0_12_x {
readonly GetCallerMethodAsILByteArrayDelegate getCallerMethodAsILByteArrayDelegate;
readonly DecryptCallbackDelegate decryptCallbackDelegate;
[return: MarshalAs(UnmanagedType.SafeArray)]
delegate byte[] GetCallerMethodAsILByteArrayDelegate(IntPtr a, int skipFrames, IntPtr c, IntPtr d);
unsafe delegate bool DecryptCallbackDelegate(IntPtr a, byte* pMethodCode, int methodSize, int methodId, IntPtr e);
public unsafe DecrypterV2_0_12_3(DynamicMethodsDecrypter dmd)
: base(dmd) {
getCallerMethodAsILByteArrayDelegate = GetCallerMethodAsILByteArray;
decryptCallbackDelegate = MyDecryptCallback;
*(IntPtr*)pGetILBytes = Marshal.GetFunctionPointerForDelegate(getCallerMethodAsILByteArrayDelegate);
*(IntPtr*)pDecryptCallback = Marshal.GetFunctionPointerForDelegate(decryptCallbackDelegate);
}
byte[] GetCallerMethodAsILByteArray(IntPtr a, int skipFrames, IntPtr c, IntPtr d) {
return currentILBytes;
}
unsafe bool MyDecryptCallback(IntPtr a, byte* pMethodCode, int methodSize, int methodId, IntPtr e) {
SaveDecryptedData(pMethodCode, methodSize);
return true;
}
}
public bool MethodReaderHasDelegateTypeFlag {
get { return methodReaderHasDelegateTypeFlag; }
}
public DynamicMethodsDecrypter(ModuleDefMD module, Module reflectionModule) {
this.module = module;
this.reflectionModule = reflectionModule;
@ -336,11 +445,22 @@ namespace de4dot.code.deobfuscators.ILProtector {
}
IDecrypter CreateDecrypter() {
return CreateDecrypterV1_0_7_0() ??
CreateDecrypterV2_0_0_0() ??
CreateDecrypterV2_0_8_0() ??
CreateDecrypterV2_0_8_5() ??
CreateDecrypterV2_0_9_0();
var version = reflectionProtectModule.Assembly.GetName().Version;
if (reflectionProtectModule.Assembly.GetName().Version < new Version(2, 0, 12, 0)) {
return CreateDecrypterV1_0_7_0() ??
CreateDecrypterV2_0_0_0() ??
CreateDecrypterV2_0_8_0() ??
CreateDecrypterV2_0_8_5() ??
CreateDecrypterV2_0_9_0();
}
methodReaderHasDelegateTypeFlag = true;
if (version < new Version(2, 0, 12, 3))
return CreateDecrypterV2_0_12_0();
if (version < new Version(2, 0, 12, 4))
return CreateDecrypterV2_0_12_3();
return null;
}
IDecrypter CreateDecrypterV1_0_7_0() {
@ -383,6 +503,14 @@ namespace de4dot.code.deobfuscators.ILProtector {
return new DecrypterV2_0_9_0(this, delegateField);
}
IDecrypter CreateDecrypterV2_0_12_0() {
return new DecrypterV2_0_12_0(this);
}
IDecrypter CreateDecrypterV2_0_12_3() {
return new DecrypterV2_0_12_3(this);
}
static readonly byte[] ilpPublicKeyToken = new byte[8] { 0x20, 0x12, 0xD3, 0xC0, 0x55, 0x1F, 0xE0, 0x3D };
static Assembly GetProtectAssembly() {
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) {

View File

@ -26,9 +26,11 @@ using AssemblyData;
namespace de4dot.code.deobfuscators.ILProtector {
sealed class DynamicMethodsDecrypterService : IUserGenericService {
public const int MSG_DECRYPT_METHODS = 0;
public const int MSG_HAS_DELEGATE_TYPE_FLAG = 1;
Module reflObfModule;
ModuleDefMD obfModule;
bool hasDelegateTypeFlag;
[CreateUserGenericService]
public static IUserGenericService Create() {
@ -51,6 +53,9 @@ namespace de4dot.code.deobfuscators.ILProtector {
case MSG_DECRYPT_METHODS:
return DecryptMethods(args[0] as IList<int>);
case MSG_HAS_DELEGATE_TYPE_FLAG:
return hasDelegateTypeFlag;
default:
throw new ApplicationException(string.Format("Invalid msg: {0:X8}", msg));
}
@ -65,6 +70,8 @@ namespace de4dot.code.deobfuscators.ILProtector {
for (int i = 0; i < methodIds.Count; i += 2)
infos.Add(decrypter.Decrypt(methodIds[i], (uint)methodIds[i + 1]));
hasDelegateTypeFlag = decrypter.MethodReaderHasDelegateTypeFlag;
return infos;
}
}

View File

@ -42,6 +42,7 @@ namespace de4dot.code.deobfuscators.ILProtector {
client.GenericService.LoadUserService(typeof(DynamicMethodsDecrypterService), null);
client.GenericService.LoadAssembly(module.Location);
decryptedData = client.GenericService.SendMessage(DynamicMethodsDecrypterService.MSG_DECRYPT_METHODS, new object[] { GetMethodIds() }) as IList<DecryptedMethodInfo>;
MethodReaderHasDelegateTypeFlag = (bool)client.GenericService.SendMessage(DynamicMethodsDecrypterService.MSG_HAS_DELEGATE_TYPE_FLAG, new object[0]);
}
if (decryptedData == null)

View File

@ -31,6 +31,7 @@ namespace de4dot.code.deobfuscators.ILProtector {
ModuleDefMD module;
MethodFlags flags;
TypeDef delegateType;
bool hasDelegateTypeFlag;
[Flags]
enum MethodFlags {
@ -38,6 +39,7 @@ namespace de4dot.code.deobfuscators.ILProtector {
HasLocals = 2,
HasInstructions = 4,
HasExceptionHandlers = 8,
HasDelegateType = 0x10,
}
public TypeDef DelegateType {
@ -60,6 +62,15 @@ namespace de4dot.code.deobfuscators.ILProtector {
get { return (flags & MethodFlags.HasExceptionHandlers) != 0; }
}
bool HasDelegateType {
get { return !hasDelegateTypeFlag || (flags & MethodFlags.HasDelegateType) != 0; }
}
public bool HasDelegateTypeFlag {
get { return hasDelegateTypeFlag; }
set { hasDelegateTypeFlag = value; }
}
public MethodReader(ModuleDefMD module, byte[] data, IList<Parameter> parameters)
: base(MemoryImageStream.Create(data), parameters) {
this.module = module;
@ -67,9 +78,11 @@ namespace de4dot.code.deobfuscators.ILProtector {
public void Read() {
flags = (MethodFlags)reader.ReadByte();
delegateType = Resolve<TypeDef>(ReadTypeToken());
if (!DotNetUtils.DerivesFromDelegate(delegateType))
throw new ApplicationException("Invalid delegate type");
if (HasDelegateType) {
delegateType = Resolve<TypeDef>(ReadTypeToken());
if (!DotNetUtils.DerivesFromDelegate(delegateType))
throw new ApplicationException("Invalid delegate type");
}
if (HasLocals)
ReadLocals((int)reader.Read7BitEncodedUInt32());
if (HasInstructions)
@ -104,29 +117,29 @@ namespace de4dot.code.deobfuscators.ILProtector {
TypeSig ReadType() {
switch ((ElementType)reader.ReadByte()) {
case ElementType.Void: return module.CorLibTypes.Void;
case ElementType.Boolean: return module.CorLibTypes.Boolean;
case ElementType.Char: return module.CorLibTypes.Char;
case ElementType.I1: return module.CorLibTypes.SByte;
case ElementType.U1: return module.CorLibTypes.Byte;
case ElementType.I2: return module.CorLibTypes.Int16;
case ElementType.U2: return module.CorLibTypes.UInt16;
case ElementType.I4: return module.CorLibTypes.Int32;
case ElementType.U4: return module.CorLibTypes.UInt32;
case ElementType.I8: return module.CorLibTypes.Int64;
case ElementType.U8: return module.CorLibTypes.UInt64;
case ElementType.R4: return module.CorLibTypes.Single;
case ElementType.R8: return module.CorLibTypes.Double;
case ElementType.String: return module.CorLibTypes.String;
case ElementType.Ptr: return new PtrSig(ReadType());
case ElementType.ByRef: return new ByRefSig(ReadType());
case ElementType.TypedByRef: return module.CorLibTypes.TypedReference;
case ElementType.I: return module.CorLibTypes.IntPtr;
case ElementType.U: return module.CorLibTypes.UIntPtr;
case ElementType.Object: return module.CorLibTypes.Object;
case ElementType.SZArray: return new SZArraySig(ReadType());
case ElementType.Sentinel: ReadType(); return new SentinelSig();
case ElementType.Pinned: return new PinnedSig(ReadType());
case ElementType.Void: return module.CorLibTypes.Void;
case ElementType.Boolean: return module.CorLibTypes.Boolean;
case ElementType.Char: return module.CorLibTypes.Char;
case ElementType.I1: return module.CorLibTypes.SByte;
case ElementType.U1: return module.CorLibTypes.Byte;
case ElementType.I2: return module.CorLibTypes.Int16;
case ElementType.U2: return module.CorLibTypes.UInt16;
case ElementType.I4: return module.CorLibTypes.Int32;
case ElementType.U4: return module.CorLibTypes.UInt32;
case ElementType.I8: return module.CorLibTypes.Int64;
case ElementType.U8: return module.CorLibTypes.UInt64;
case ElementType.R4: return module.CorLibTypes.Single;
case ElementType.R8: return module.CorLibTypes.Double;
case ElementType.String: return module.CorLibTypes.String;
case ElementType.Ptr: return new PtrSig(ReadType());
case ElementType.ByRef: return new ByRefSig(ReadType());
case ElementType.TypedByRef:return module.CorLibTypes.TypedReference;
case ElementType.I: return module.CorLibTypes.IntPtr;
case ElementType.U: return module.CorLibTypes.UIntPtr;
case ElementType.Object: return module.CorLibTypes.Object;
case ElementType.SZArray: return new SZArraySig(ReadType());
case ElementType.Sentinel: ReadType(); return new SentinelSig();
case ElementType.Pinned: return new PinnedSig(ReadType());
case ElementType.ValueType:
case ElementType.Class:

View File

@ -37,6 +37,8 @@ namespace de4dot.code.deobfuscators.ILProtector {
get { return delegateTypes; }
}
public bool MethodReaderHasDelegateTypeFlag { get; set; }
public MethodsDecrypterBase(ModuleDefMD module, MainType mainType) {
this.module = module;
this.mainType = mainType;
@ -84,10 +86,12 @@ namespace de4dot.code.deobfuscators.ILProtector {
var methodInfo = methodInfos[methodId.Value];
methodInfos.Remove(methodId.Value);
var methodReader = new MethodReader(module, methodInfo.data, parameters);
methodReader.HasDelegateTypeFlag = MethodReaderHasDelegateTypeFlag;
methodReader.Read();
RestoreMethod(method, methodReader);
delegateTypes.Add(methodReader.DelegateType);
if (methodReader.DelegateType != null)
delegateTypes.Add(methodReader.DelegateType);
return true;
}

View File

@ -24,9 +24,6 @@ using dnlib.DotNet;
namespace de4dot.code.deobfuscators.ILProtector {
class RuntimeFileInfo {
const uint HASH_FILE_OFFSET = 0x00040000;
const int HASH_SIZE = 0x1000;
public MethodDef ProtectMethod { get; private set; }
public string PathName { get; private set; }
public string Name { get; private set; }
@ -45,45 +42,53 @@ namespace de4dot.code.deobfuscators.ILProtector {
}
static readonly VersionInfo[] versionInfo32 = new VersionInfo[] {
new VersionInfo(new Version(1, 0, 7, 0), new byte[] { 0x94, 0x79, 0x6E, 0xC1, 0x1F, 0x6D, 0xE9, 0xE3, 0x2F, 0x5E, 0xA3, 0x57, 0x71, 0x02, 0x22, 0x6A }),
new VersionInfo(new Version(1, 0, 7, 1), new byte[] { 0x8D, 0xCE, 0xAB, 0x0C, 0xA6, 0xA9, 0x4A, 0xA2, 0xCE, 0x43, 0xDE, 0x38, 0xEA, 0xDE, 0x0D, 0x3A }),
new VersionInfo(new Version(1, 0, 8, 0), new byte[] { 0x44, 0x09, 0x33, 0xCE, 0x90, 0x43, 0xF9, 0xC2, 0x2F, 0x11, 0x40, 0x1D, 0x18, 0xDA, 0x63, 0x3B }),
new VersionInfo(new Version(2, 0, 0, 0), new byte[] { 0xFD, 0x1D, 0x2B, 0x73, 0x2F, 0xD8, 0x27, 0x5F, 0xA3, 0x83, 0x76, 0x36, 0x29, 0x8E, 0x51, 0xA9 }),
new VersionInfo(new Version(2, 0, 1, 0), new byte[] { 0x0D, 0x5E, 0xC2, 0xA5, 0x0D, 0x7C, 0xE1, 0x8B, 0x57, 0x9F, 0xC8, 0x16, 0x25, 0x95, 0x70, 0xEB }),
new VersionInfo(new Version(2, 0, 2, 0), new byte[] { 0x9C, 0xED, 0x53, 0x3A, 0x97, 0x4B, 0x9E, 0xC7, 0xF4, 0x82, 0xE9, 0x84, 0xB4, 0x9A, 0xEB, 0xA6 }),
new VersionInfo(new Version(2, 0, 3, 0), new byte[] { 0x0C, 0xDD, 0xCF, 0x04, 0x20, 0x6E, 0x7A, 0x48, 0x26, 0x8B, 0x97, 0x8E, 0x58, 0x17, 0x9B, 0x51 }),
new VersionInfo(new Version(2, 0, 4, 0), new byte[] { 0x1D, 0x41, 0xE7, 0x6D, 0x17, 0xED, 0x51, 0x37, 0xA0, 0xFC, 0x98, 0x5F, 0x19, 0x97, 0xEF, 0x9D }),
new VersionInfo(new Version(2, 0, 5, 0), new byte[] { 0x60, 0xD8, 0x1D, 0x1C, 0x0C, 0xBF, 0x46, 0x82, 0x9C, 0xE3, 0x73, 0x8D, 0x88, 0x2E, 0x0E, 0xBA }),
new VersionInfo(new Version(2, 0, 6, 0), new byte[] { 0x85, 0x89, 0x66, 0x39, 0xC3, 0x04, 0x3D, 0x3F, 0xFD, 0xBC, 0xFA, 0x70, 0x1D, 0x04, 0x59, 0x89 }),
new VersionInfo(new Version(2, 0, 7, 0), new byte[] { 0x16, 0x5C, 0xE1, 0xA4, 0x30, 0xF7, 0x55, 0x26, 0x45, 0xB8, 0x43, 0x99, 0x2A, 0xC9, 0x6F, 0xD9 }),
new VersionInfo(new Version(2, 0, 7, 5), new byte[] { 0x11, 0x50, 0x25, 0x2C, 0x26, 0x03, 0x8B, 0xDA, 0xBC, 0x98, 0x7E, 0x81, 0x97, 0x3E, 0xCE, 0x31 }),
new VersionInfo(new Version(2, 0, 7, 6), new byte[] { 0x6F, 0x9C, 0xF2, 0xDB, 0x83, 0x76, 0x92, 0x6A, 0xC4, 0xAA, 0xAE, 0xFA, 0x3D, 0xB3, 0x69, 0x59 }),
new VersionInfo(new Version(2, 0, 8, 0), new byte[] { 0x96, 0x84, 0xA0, 0x32, 0x3A, 0xB5, 0xAD, 0x89, 0xD7, 0xCD, 0x69, 0x34, 0xF1, 0x5D, 0xF3, 0x3A }),
new VersionInfo(new Version(2, 0, 8, 5), new byte[] { 0xB8, 0xCF, 0xEA, 0xBA, 0xB6, 0xAD, 0xE5, 0xCC, 0xFB, 0xA4, 0xE4, 0xFE, 0x1A, 0x83, 0xE5, 0x85 }),
new VersionInfo(new Version(2, 0, 9, 0), new byte[] { 0xA4, 0x68, 0x70, 0xA2, 0x1E, 0xBB, 0x99, 0xAB, 0xDD, 0x8C, 0xCA, 0x55, 0x32, 0x12, 0x95, 0xB5 }),
new VersionInfo(new Version(2, 0, 10, 0), new byte[] { 0xC5, 0xDC, 0x27, 0x22, 0x8F, 0x09, 0xFB, 0x56, 0x84, 0x6E, 0x07, 0x62, 0x4E, 0xBF, 0x71, 0xA6 }),
new VersionInfo(new Version(2, 0, 11, 0), new byte[] { 0x57, 0xAD, 0xBC, 0xB0, 0x7F, 0x80, 0xEF, 0xEA, 0xC3, 0xB7, 0x9F, 0x27, 0x87, 0x0A, 0x4B, 0xFF }),
new VersionInfo(new Version(1, 0, 7, 0), new byte[] { 0x1B, 0x7A, 0x48, 0x9E, 0x70, 0x69, 0x3C, 0x51, 0xDB, 0x3E, 0xD8, 0x09, 0x71, 0x1F, 0x16, 0x33 }),
new VersionInfo(new Version(1, 0, 7, 1), new byte[] { 0xD2, 0x76, 0x37, 0xA2, 0xE4, 0xCC, 0x66, 0xAB, 0x6A, 0x72, 0x45, 0x25, 0x06, 0x64, 0x05, 0xD7 }),
new VersionInfo(new Version(1, 0, 8, 0), new byte[] { 0x0B, 0x3D, 0xFD, 0xB3, 0x8B, 0xCF, 0x59, 0x42, 0x9C, 0x4C, 0x2B, 0x43, 0xA4, 0x22, 0x91, 0xB0 }),
new VersionInfo(new Version(2, 0, 0, 0), new byte[] { 0xC5, 0x8A, 0x92, 0x92, 0xBD, 0xA4, 0x6D, 0xF2, 0xEA, 0xF8, 0x4F, 0x79, 0x89, 0xF2, 0x44, 0x38 }),
new VersionInfo(new Version(2, 0, 1, 0), new byte[] { 0xFD, 0x79, 0x53, 0x6C, 0xDA, 0x10, 0x3F, 0x29, 0xBF, 0x52, 0x4B, 0x70, 0xB2, 0xFF, 0x55, 0x25 }),
new VersionInfo(new Version(2, 0, 2, 0), new byte[] { 0xED, 0xC2, 0xB2, 0x07, 0x1F, 0x1A, 0xF0, 0x4D, 0x9B, 0x37, 0x6F, 0x10, 0x7A, 0xDA, 0xA2, 0xED }),
new VersionInfo(new Version(2, 0, 3, 0), new byte[] { 0xF3, 0xD8, 0x48, 0x69, 0x2B, 0x39, 0x99, 0x48, 0xB7, 0x8D, 0x0D, 0x72, 0xC5, 0xE4, 0xF5, 0x6D }),
new VersionInfo(new Version(2, 0, 4, 0), new byte[] { 0xBC, 0x39, 0x58, 0x38, 0x5C, 0x2F, 0x5A, 0x50, 0xCF, 0xF7, 0x47, 0xC7, 0xEC, 0x52, 0xC6, 0xD0 }),
new VersionInfo(new Version(2, 0, 5, 0), new byte[] { 0x90, 0x42, 0x0F, 0xB5, 0x84, 0x09, 0x90, 0xE5, 0xD8, 0x10, 0xF1, 0xAF, 0xF5, 0xBC, 0xA5, 0xF8 }),
new VersionInfo(new Version(2, 0, 6, 0), new byte[] { 0xD1, 0x8D, 0x0C, 0x3C, 0x51, 0xBD, 0x36, 0x37, 0x17, 0xAB, 0xEC, 0x92, 0x19, 0x1B, 0xB0, 0xD6 }),
new VersionInfo(new Version(2, 0, 7, 0), new byte[] { 0x02, 0xD1, 0x75, 0x77, 0x12, 0x6D, 0x4E, 0x86, 0x90, 0x34, 0x6A, 0xBB, 0x56, 0x0E, 0x6A, 0xEA }),
new VersionInfo(new Version(2, 0, 7, 5), new byte[] { 0x7D, 0x5C, 0xBE, 0x21, 0x0B, 0xA9, 0x15, 0xFF, 0xE6, 0xC9, 0xD5, 0xFD, 0x7C, 0xA0, 0xAA, 0xC1 }),
new VersionInfo(new Version(2, 0, 7, 6), new byte[] { 0x0D, 0x03, 0xB7, 0x1A, 0x74, 0x8E, 0x6B, 0x94, 0x2B, 0xD4, 0x33, 0x24, 0x49, 0xF8, 0x38, 0xD2 }),
new VersionInfo(new Version(2, 0, 8, 0), new byte[] { 0xE6, 0xD6, 0x07, 0x89, 0x03, 0xA8, 0xE3, 0xD7, 0x86, 0x5A, 0x3D, 0xC2, 0x86, 0xF5, 0x0F, 0x67 }),
new VersionInfo(new Version(2, 0, 8, 5), new byte[] { 0xFC, 0x79, 0x83, 0x61, 0xD2, 0x99, 0x8E, 0xE8, 0x2C, 0x5F, 0x14, 0xBA, 0xCB, 0xB9, 0x28, 0xF2 }),
new VersionInfo(new Version(2, 0, 9, 0), new byte[] { 0x7A, 0x88, 0xD8, 0xC3, 0xB8, 0x77, 0xAA, 0x13, 0xC0, 0x6C, 0x43, 0x88, 0x0D, 0x66, 0xFE, 0x7A }),
new VersionInfo(new Version(2, 0, 10, 0), new byte[] { 0xE5, 0x8E, 0xEB, 0x26, 0x1A, 0x1C, 0x44, 0xA8, 0xFF, 0x88, 0x14, 0xE7, 0x38, 0x13, 0xE5, 0x6D }),
new VersionInfo(new Version(2, 0, 11, 0), new byte[] { 0x67, 0xB8, 0xF7, 0x15, 0x70, 0x1D, 0xF2, 0x57, 0x00, 0x42, 0xF3, 0xA4, 0x83, 0x07, 0x62, 0xA3 }),
new VersionInfo(new Version(2, 0, 11, 1), new byte[] { 0x2E, 0xC9, 0x53, 0xA0, 0x3C, 0x9B, 0x08, 0xDA, 0x88, 0x84, 0x37, 0xFC, 0x07, 0xAE, 0x8B, 0xEC }),
new VersionInfo(new Version(2, 0, 12, 0), new byte[] { 0x63, 0x8B, 0x5C, 0xE9, 0x89, 0x83, 0x57, 0x9D, 0xDC, 0xC3, 0xBD, 0xD9, 0xDB, 0x54, 0xBE, 0x66 }),
new VersionInfo(new Version(2, 0, 12, 2), new byte[] { 0xD5, 0x46, 0x38, 0xC7, 0x48, 0xF6, 0x3C, 0x1C, 0x1E, 0x7F, 0x3B, 0x7B, 0x5B, 0xE0, 0x49, 0x46 }),
new VersionInfo(new Version(2, 0, 12, 3), new byte[] { 0x35, 0xA3, 0x53, 0xE9, 0x9E, 0x30, 0x6E, 0x9C, 0x0F, 0x46, 0x20, 0x9A, 0x91, 0xD2, 0x95, 0x18 }),
};
static readonly VersionInfo[] versionInfo64 = new VersionInfo[] {
// No sig for 1.0.7.0 x64 since I don't have it yet.
new VersionInfo(new Version(1, 0, 7, 1), new byte[] { 0x68, 0x4C, 0xC0, 0xC2, 0x55, 0x75, 0x72, 0x09, 0x12, 0x10, 0xA4, 0xF3, 0xFE, 0x95, 0x4D, 0x7A }),
new VersionInfo(new Version(1, 0, 8, 0), new byte[] { 0x99, 0xAF, 0x3D, 0x39, 0x16, 0xC2, 0xD6, 0x10, 0x6E, 0x09, 0x64, 0xDE, 0xA4, 0xB3, 0x30, 0xE5 }),
new VersionInfo(new Version(2, 0, 0, 0), new byte[] { 0x02, 0x90, 0xDA, 0xBD, 0x37, 0xEE, 0x20, 0x86, 0xA7, 0x30, 0x31, 0x6D, 0x92, 0xEF, 0xB3, 0x01 }),
new VersionInfo(new Version(2, 0, 1, 0), new byte[] { 0xE8, 0xE7, 0x11, 0x6B, 0x52, 0x60, 0x5A, 0x4D, 0x5A, 0xC6, 0x76, 0xF5, 0xD3, 0x64, 0xB1, 0x03 }),
new VersionInfo(new Version(2, 0, 2, 0), new byte[] { 0xD3, 0x37, 0xA1, 0x69, 0xF4, 0x25, 0x86, 0x19, 0xC6, 0x89, 0x70, 0x82, 0x9A, 0x3E, 0xCC, 0x04 }),
new VersionInfo(new Version(2, 0, 3, 0), new byte[] { 0xB1, 0xF8, 0xCB, 0xFD, 0x2D, 0x47, 0x36, 0xF1, 0x8A, 0x1D, 0xEF, 0xA7, 0x07, 0x0C, 0xD9, 0x74 }),
new VersionInfo(new Version(2, 0, 4, 0), new byte[] { 0x53, 0xC7, 0xA8, 0x3F, 0xD8, 0x9D, 0xA1, 0x85, 0x04, 0x50, 0x1D, 0x19, 0xF4, 0x1F, 0xF4, 0x44 }),
new VersionInfo(new Version(2, 0, 5, 0), new byte[] { 0x32, 0x82, 0x4B, 0xC7, 0xBB, 0x32, 0xBF, 0x9F, 0xB7, 0x9B, 0x06, 0x90, 0x7B, 0xB0, 0x7B, 0x7C }),
new VersionInfo(new Version(2, 0, 6, 0), new byte[] { 0x4F, 0x02, 0x86, 0xA6, 0xCA, 0xFD, 0xC1, 0x47, 0xA1, 0xDB, 0x2F, 0x73, 0x94, 0x38, 0x2B, 0xA7 }),
new VersionInfo(new Version(2, 0, 7, 0), new byte[] { 0x43, 0xA4, 0xC1, 0xA8, 0xC7, 0x36, 0x55, 0xEB, 0x3F, 0xFF, 0xA0, 0xB3, 0x85, 0x00, 0x21, 0x99 }),
new VersionInfo(new Version(2, 0, 7, 5), new byte[] { 0x6A, 0xA8, 0x2B, 0x28, 0x0B, 0xEE, 0x4C, 0xF0, 0x57, 0x3F, 0x43, 0xD4, 0xFB, 0xBC, 0x5E, 0x8C }),
new VersionInfo(new Version(2, 0, 7, 6), new byte[] { 0xE5, 0xD7, 0x81, 0xBD, 0x85, 0x02, 0x10, 0xAC, 0x92, 0x4A, 0xF0, 0x35, 0xD2, 0x4C, 0x50, 0xA5 }),
new VersionInfo(new Version(2, 0, 8, 0), new byte[] { 0x14, 0x44, 0xD1, 0x34, 0x69, 0x4D, 0xC7, 0xB7, 0x4D, 0x91, 0x0E, 0x6C, 0x4C, 0x9B, 0x46, 0x8E }),
new VersionInfo(new Version(2, 0, 8, 5), new byte[] { 0x5C, 0xEE, 0x47, 0x36, 0x2B, 0x10, 0xAD, 0x5F, 0x66, 0x6D, 0x3F, 0xD4, 0xF4, 0x4A, 0xFF, 0xA1 }),
new VersionInfo(new Version(2, 0, 9, 0), new byte[] { 0x2B, 0x80, 0x93, 0x78, 0x22, 0x29, 0x8C, 0xA1, 0xED, 0xE4, 0x59, 0x1A, 0xEC, 0x5B, 0xAF, 0xA7 }),
new VersionInfo(new Version(2, 0, 10, 0), new byte[] { 0xE3, 0x56, 0xB4, 0x98, 0x38, 0x27, 0x29, 0x27, 0x56, 0x87, 0x88, 0xAD, 0xA3, 0x50, 0x61, 0x24 }),
new VersionInfo(new Version(2, 0, 11, 0), new byte[] { 0x08, 0xDD, 0x40, 0x28, 0x08, 0x61, 0xDA, 0xD3, 0xD1, 0x38, 0x2F, 0x8A, 0xE0, 0x21, 0x0E, 0xE9 }),
new VersionInfo(new Version(1, 0, 7, 1), new byte[] { 0x8E, 0xB4, 0x61, 0x12, 0xDF, 0x76, 0x6F, 0xAB, 0xF0, 0x2C, 0x7A, 0x3A, 0x0D, 0x71, 0xE8, 0xB0 }),
new VersionInfo(new Version(1, 0, 8, 0), new byte[] { 0x04, 0xB1, 0xDA, 0x92, 0xE7, 0x59, 0x54, 0x82, 0x0F, 0x46, 0xD6, 0x08, 0xA2, 0x69, 0xB7, 0x75 }),
new VersionInfo(new Version(2, 0, 0, 0), new byte[] { 0xC7, 0xD9, 0x62, 0x7E, 0xEC, 0x6D, 0x10, 0x8A, 0xBF, 0x71, 0x7A, 0x4C, 0xC0, 0x3E, 0xAE, 0x9E }),
new VersionInfo(new Version(2, 0, 1, 0), new byte[] { 0xD3, 0xCF, 0x89, 0x80, 0xFD, 0xB7, 0x38, 0xC2, 0x3C, 0xDF, 0x4E, 0x9D, 0xCE, 0xDD, 0x95, 0xDE }),
new VersionInfo(new Version(2, 0, 2, 0), new byte[] { 0x44, 0xB7, 0xBA, 0xF9, 0x0A, 0x5B, 0xD6, 0xE7, 0xBE, 0x7A, 0x47, 0x82, 0x3B, 0x24, 0xB3, 0x73 }),
new VersionInfo(new Version(2, 0, 3, 0), new byte[] { 0x8D, 0x25, 0x16, 0x40, 0xB6, 0xCF, 0x54, 0xF8, 0x78, 0xBE, 0x3A, 0xE5, 0x3D, 0x5E, 0xF9, 0x60 }),
new VersionInfo(new Version(2, 0, 4, 0), new byte[] { 0x7F, 0x49, 0xEA, 0x93, 0x8E, 0x81, 0xFC, 0xF5, 0x56, 0x94, 0x73, 0xA8, 0x52, 0x61, 0x79, 0x60 }),
new VersionInfo(new Version(2, 0, 5, 0), new byte[] { 0x08, 0xDB, 0xA2, 0x8E, 0xD7, 0x27, 0xBB, 0xD0, 0x69, 0xF5, 0x63, 0x28, 0x46, 0xBF, 0xBB, 0xB3 }),
new VersionInfo(new Version(2, 0, 6, 0), new byte[] { 0x09, 0xFC, 0x92, 0x18, 0xC8, 0x34, 0xD6, 0x55, 0xE3, 0x7C, 0xA5, 0xCB, 0x15, 0x28, 0x59, 0x94 }),
new VersionInfo(new Version(2, 0, 7, 0), new byte[] { 0x7B, 0x36, 0x68, 0xA0, 0x9E, 0xCB, 0xB9, 0x73, 0x5B, 0x1A, 0xAC, 0x50, 0x7E, 0x59, 0x1C, 0xB7 }),
new VersionInfo(new Version(2, 0, 7, 5), new byte[] { 0x14, 0x13, 0x30, 0x60, 0x1A, 0xB0, 0x6F, 0x37, 0x82, 0xE3, 0x67, 0x16, 0x6C, 0x62, 0x30, 0x16 }),
new VersionInfo(new Version(2, 0, 7, 6), new byte[] { 0x98, 0xDE, 0x41, 0x4B, 0x15, 0x2C, 0xF7, 0x34, 0x2A, 0xEF, 0xE3, 0x91, 0x07, 0x7F, 0x0F, 0xE7 }),
new VersionInfo(new Version(2, 0, 8, 0), new byte[] { 0x21, 0x40, 0xED, 0xC6, 0xA2, 0x13, 0x3D, 0xCA, 0x22, 0x11, 0x02, 0x75, 0xFC, 0xE6, 0x3A, 0x51 }),
new VersionInfo(new Version(2, 0, 8, 5), new byte[] { 0xF5, 0x67, 0xC1, 0x44, 0xF6, 0x2F, 0xBA, 0x01, 0xA3, 0x01, 0x91, 0x60, 0xDF, 0x99, 0xAB, 0x0C }),
new VersionInfo(new Version(2, 0, 9, 0), new byte[] { 0x04, 0x17, 0xF3, 0xEA, 0x97, 0x24, 0x48, 0xC0, 0x01, 0x2E, 0x45, 0x80, 0x9D, 0x5B, 0x7C, 0xDF }),
new VersionInfo(new Version(2, 0, 10, 0), new byte[] { 0xD8, 0x79, 0x05, 0xC9, 0x2D, 0xA6, 0x5B, 0x7D, 0xEE, 0xA6, 0x13, 0x25, 0x7D, 0x29, 0x73, 0xB4 }),
new VersionInfo(new Version(2, 0, 11, 0), new byte[] { 0x49, 0xAD, 0x40, 0x10, 0xD4, 0x03, 0x04, 0xB4, 0x3C, 0xD2, 0x36, 0x67, 0x38, 0x62, 0x9C, 0xE8 }),
new VersionInfo(new Version(2, 0, 11, 1), new byte[] { 0x1D, 0x6C, 0xB6, 0xC8, 0xB3, 0x07, 0x53, 0x24, 0x6F, 0xC0, 0xF3, 0x4F, 0x5E, 0x8B, 0x9F, 0xD1 }),
new VersionInfo(new Version(2, 0, 12, 0), new byte[] { 0x5F, 0x42, 0xA5, 0x6C, 0x19, 0xC6, 0x73, 0x9E, 0xE6, 0x74, 0x62, 0x3B, 0x8A, 0x51, 0xBB, 0x93 }),
new VersionInfo(new Version(2, 0, 12, 2), new byte[] { 0x10, 0x91, 0xED, 0x05, 0x9C, 0x31, 0x0B, 0x63, 0x76, 0xD7, 0x4A, 0xEC, 0xDE, 0x99, 0x6D, 0xD0 }),
new VersionInfo(new Version(2, 0, 12, 3), new byte[] { 0x38, 0x86, 0xE0, 0xBF, 0xC6, 0x64, 0xB9, 0xA0, 0x07, 0xED, 0xDB, 0x02, 0x40, 0xD0, 0x57, 0xE8 }),
};
public RuntimeFileInfo(MethodDef protectMethod) {
@ -125,19 +130,12 @@ namespace de4dot.code.deobfuscators.ILProtector {
static byte[] GetHash(string fullPath) {
try {
using (var reader = new BinaryReader(new FileStream(fullPath, FileMode.Open, FileAccess.Read, FileShare.Read))) {
reader.BaseStream.Position = HASH_FILE_OFFSET;
var bytes = reader.ReadBytes(HASH_SIZE);
if (bytes.Length != HASH_SIZE)
return null;
using (var hasher = MD5.Create()) {
using (var outStream = new NullStream()) {
using (var csStream = new CryptoStream(outStream, hasher, CryptoStreamMode.Write))
new BinaryWriter(csStream).Write(bytes);
}
return hasher.Hash;
using (var hasher = MD5.Create()) {
using (var outStream = new NullStream()) {
using (var csStream = new CryptoStream(outStream, hasher, CryptoStreamMode.Write))
new BinaryWriter(csStream).Write(File.ReadAllBytes(fullPath));
}
return hasher.Hash;
}
}
catch {