private void InvokeFunctionCallMethods(FunctionCallType functionCallType)
 {
     foreach (var item in _functionCalls.Where(x => x.FunctionCallConfig.GetFunctionCallType() == functionCallType))
     {
         InvokeFunctionCall(item);
     }
 }
示例#2
0
 public FunctionCallAttribute(FunctionCallType fct)
 {
     if (fct == FunctionCallType.CallOnInterval || fct == FunctionCallType.CallOnTime)
     {
         throw new Exception("you have to specify a value (timeMs or dateTime)");
     }
     _fct = fct;
 }
示例#3
0
        public void RegisterFunction(string name, FunctionCallType type, int address, int argumentsCount)
        {
            var registrationData = new object[] {
                name,
                address,
                type,
                argumentsCount
            };

            this[c_register, false, Encoding.UTF8](new object[] {
                registrationData
            }, 1);
        }
示例#4
0
 public FunctionCall(FunctionCallType type, CallSiteParameter[] arguments)
 {
     Type = type;
     Arguments = arguments;
 }
示例#5
0
        private static int GetTokenForMethodDecode(ProxyType PT, int iIndex, AntiProxyParams Params, out FunctionCallType CT)
        {
            FieldInfo fieldFromHandle   = PT.arFieldReflection[iIndex];
            Assembly  executingAssembly = Params.asmReflection;

            char[] array = new char[fieldFromHandle.Name.Length];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = (char)((int)((byte)fieldFromHandle.Name[i]) ^ i);
            }
            byte[] array2 = Convert.FromBase64String(new string(array));
            CT = (array2[0] == 13) ? FunctionCallType.Callvirt : FunctionCallType.Call;

            return(BitConverter.ToInt32(array2, 1) ^ Params.XORTokenMethod);
        }
示例#6
0
        private static bool DoAntiProxy(ProxyType PT, AntiProxyParams Params)
        {
            FunctionCallType CT = FunctionCallType.Call;

            for (int iIndex = 0; iIndex < PT.arMethods.Length; iIndex++)
            {
                if (PT.arProxyTypeDelegate[iIndex] == ProxyTypeDelegate.NewObjectCall)
                {
                    Int32 TokenOfOriginalCall = GetTokenForFieldDecode(PT, iIndex, Params);

                    MethodReference MR    = AsmDef.MainModule.Import(Params.asmReflection.GetModules()[0].ResolveMethod(TokenOfOriginalCall));
                    Instruction[]   arIns = GetInstructionsWithMethodCall(PT.arMethods[iIndex]).ToArray();

                    for (int i = 0; i < arIns.Length; i++)
                    {
                        arIns[i].OpCode  = OpCodes.Newobj;
                        arIns[i].Operand = MR;
                    }
                }

                if (PT.arProxyTypeDelegate[iIndex] == ProxyTypeDelegate.DirectMethodCall)
                {
                    Int32 TokenOfOriginalCall = GetTokenForMethodDecode(PT, iIndex, Params, out CT);

                    ProxyType       PT2 = null;
                    MethodReference MR  = AsmDef.MainModule.Import(Params.asmReflection.GetModules()[0].ResolveMethod(TokenOfOriginalCall));

                    ProxyType[] NestedPT = Params.lstProxyTypes.Where(m => m.Type.Name == MR.DeclaringType.Name).ToArray();

                    if (NestedPT.Length != 0)
                    {
                        PT2 = NestedPT[0];
                    }

                    /*foreach (var PTNew in AP17.lstProxyTypes)
                     * {
                     *  if (MR.DeclaringType.Name == PTNew.Type.Name)
                     *  {
                     *      PT2 = new ProxyType(PTNew.Type, AP17);
                     *  }
                     * }*/

                    // PT2 = Second stage proxy -> proxy followed by a proxy by a method/newobj
                    if (PT2 != null)
                    {
                        Instruction[] arIns = GetInstructionsWithMethodCall(PT.arMethods[iIndex]);

                        if (PT2.arProxyTypeDelegate[0] == ProxyTypeDelegate.NewObjectCall)
                        {
                            Int32 TokenOfOriginalCall2 = GetTokenForFieldDecode(PT2, 0, Params);

                            MethodReference MR2 = AsmDef.MainModule.Import(Params.asmReflection.GetModules()[0].ResolveMethod(TokenOfOriginalCall2));

                            for (int i = 0; i < arIns.Length; i++)
                            {
                                arIns[i].OpCode  = OpCodes.Newobj;
                                arIns[i].Operand = MR2;
                            }
                        }
                    }
                    else
                    {
                        Instruction[] arIns = GetInstructionsWithMethodCall(PT.arMethods[iIndex]);
                        for (int i = 0; i < arIns.Length; i++)
                        {
                            if (CT == FunctionCallType.Call)
                            {
                                arIns[i].OpCode  = OpCodes.Call;
                                arIns[i].Operand = MR;
                            }
                            if (CT == FunctionCallType.Callvirt)
                            {
                                arIns[i].OpCode  = OpCodes.Callvirt;
                                arIns[i].Operand = MR;
                            }
                        }
                    }
                }
            }
            return(true);
        }
示例#7
0
 protected FunctionCall(FunctionCallType type, CallSiteParameter[] arguments)
 {
     Type      = type;
     Arguments = arguments;
 }
示例#8
0
        private static int GetTokenForMethodDecode(ProxyType PT, int iIndex, AntiProxyParams Params, out FunctionCallType CT)
        {
            FieldInfo fieldFromHandle = PT.arFieldReflection[iIndex];
            Assembly executingAssembly = Params.asmReflection;

            char[] array = new char[fieldFromHandle.Name.Length];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = (char)((int)((byte)fieldFromHandle.Name[i]) ^ i);
            }
            byte[] array2 = Convert.FromBase64String(new string(array));
            CT = (array2[0] == 13) ? FunctionCallType.Callvirt : FunctionCallType.Call;

            return BitConverter.ToInt32(array2, 1) ^ Params.XORTokenMethod;
        }
示例#9
0
 public FunctionCallAttribute(FunctionCallType fct, DateTime dateTime)
 {
     _fct     = fct;
     DateTime = dateTime;
 }
示例#10
0
 public FunctionCallAttribute(FunctionCallType fct, double timeMs)
 {
     _fct   = fct;
     TimeMs = timeMs;
 }