public override string Decrypt(MethodDef caller, int magic) { var reader = stringDecrypter.reader; reader.Position = (caller.MDToken.ToInt32() ^ magic) - stringDecrypter.magic1; int len = reader.ReadInt32() ^ (int)~stringDecrypter.magic2; var rand = new Random(caller.MDToken.ToInt32()); var instrs = stringDecrypter.decryptMethod.Body.Instructions; constReader = new PolyConstantsReader(instrs, false); int polyIndex = ConfuserUtils.FindCallMethod(instrs, 0, Code.Callvirt, "System.Int64 System.IO.BinaryReader::ReadInt64()"); if (polyIndex < 0) { throw new ApplicationException("Could not find start of decrypt code"); } var decrypted = new byte[len]; for (int i = 0; i < len; i += 8) { constReader.Arg = reader.ReadInt64(); int index = polyIndex; long val; if (!constReader.GetInt64(ref index, out val) || instrs[index].OpCode.Code != Code.Conv_I8) { throw new ApplicationException("Could not get string int64 value"); } Array.Copy(BitConverter.GetBytes(val ^ rand.Next()), 0, decrypted, i, Math.Min(8, len - i)); } return(Encoding.Unicode.GetString(decrypted)); }
public override string Decrypt(MethodDef caller, int magic) { var reader = stringDecrypter.reader; reader.Position = (caller.MDToken.ToInt32() ^ magic) - stringDecrypter.magic1; int len = reader.ReadInt32() ^ (int)~stringDecrypter.magic2; var rand = new Random(caller.MDToken.ToInt32()); var instrs = stringDecrypter.decryptMethod.Body.Instructions; constReader = new PolyConstantsReader(instrs, false); int polyIndex = ConfuserUtils.FindCallMethod(instrs, 0, Code.Callvirt, "System.Int64 System.IO.BinaryReader::ReadInt64()"); if (polyIndex < 0) throw new ApplicationException("Could not find start of decrypt code"); var decrypted = new byte[len]; for (int i = 0; i < len; i += 8) { constReader.Arg = reader.ReadInt64(); int index = polyIndex; long val; if (!constReader.GetInt64(ref index, out val) || instrs[index].OpCode.Code != Code.Conv_I8) throw new ApplicationException("Could not get string int64 value"); Array.Copy(BitConverter.GetBytes(val ^ rand.Next()), 0, decrypted, i, Math.Min(8, len - i)); } return Encoding.Unicode.GetString(decrypted); }