Ejemplo n.º 1
0
        /// <summary>
        /// Evaluates an expression using the specified language, with an optional array of named items.
        /// </summary>
        /// <param name="language">The language.</param>
        /// <param name="expression">The expression. May not be null.</param>
        /// <param name="namedItems">The named items array.</param>
        /// <returns>The result of the evaluation.</returns>
        public static object Eval(string language, string expression, params KeyValuePair <string, object>[] namedItems)
        {
            if (language == null)
            {
                throw new ArgumentNullException("language");
            }

            if (expression == null)
            {
                throw new ArgumentNullException("expression");
            }

            using (ScriptEngine engine = new ScriptEngine(language))
            {
                if (namedItems != null)
                {
                    foreach (KeyValuePair <string, object> kvp in namedItems)
                    {
                        engine.SetNamedItem(kvp.Key, kvp.Value);
                    }
                }
                return(engine.Eval(expression));
            }
        }
Ejemplo n.º 2
0
        public bool ProcessResponse(ref WebClient client, string response)
        {
            int where = response.IndexOf("{\"");
            if (where == -1)
            {
                return(false);
            }
            where = response.IndexOf(':', where) + 1;
            int    finish = response.IndexOf('}', where);
            string Key1   = response.Substring(where, finish - where);

            where = response.IndexOf("action=", where);
            if (where == -1)
            {
                return(false);
            }
            where += 8;
            finish = response.IndexOf('"', where);
            string PostUrl = response.Substring(where, finish - where);

            where = response.IndexOf("name=", where);
            if (where == -1)
            {
                return(false);
            }
            where += 16;
            finish = response.IndexOf('"', where);
            string rKey = response.Substring(where, finish - where);

            where = response.IndexOf("name=", where);
            if (where == -1)
            {
                return(false);
            }
            where += 23;
            finish = response.IndexOf('"', where);
            string jschl_vcKey = response.Substring(where, finish - where);

            where = response.IndexOf("name=", where);
            if (where == -1)
            {
                return(false);
            }
            where += 19;
            finish = response.IndexOf('"', where);
            string passKey = response.Substring(where, finish - where);

            where = response.IndexOf("visibility", where);
            if (where == -1)
            {
                return(false);
            }

            where = response.IndexOf('>', where);
            where++;
            finish = response.IndexOf('<', where);
            string StrangeKey = response.Substring(where, finish - where);


            where = response.IndexOf("-form');");
            if (where == -1)
            {
                return(false);
            }
            where += 8;
            where  = response.IndexOf(';', where);
            where++;
            finish = response.IndexOf("a.value", where);
            finish++;
            string Calculations = response.Substring(where, finish - where), TrueCalculations = "";

            where = Calculations.IndexOf('=');
            while (where != -1)
            {
                char operation = Calculations[where - 1];
                where++;
                finish = Calculations.IndexOf(';', where);
                while (Calculations[finish + 1] == ' ')
                {
                    finish = Calculations.IndexOf(';', finish + 1);
                }

                string Calculation = Calculations.Substring(where, finish - where);
                if (Calculation.StartsWith("function"))
                {
                    Calculation = "Key2";
                }
                else if (Calculation.Contains("function"))
                {
                    int twhere = Calculation.IndexOf("eval"), tfinish = Calculation.IndexOf("}", twhere);
                    Calculation = Calculation.Remove(twhere, tfinish - twhere);
                    Calculation = Calculation.Insert(twhere, "98"); // replace with the first charcode of the target website, for instance "b" is 98
                }
                TrueCalculations += "Handler.HanderKey" + operation + "=" + Calculation + "; " + Environment.NewLine;

                where = Calculations.IndexOf('=', finish);
            }

            ScriptEngine engine       = new ScriptEngine("jscript");
            string       ParseContent = File.ReadAllText("execute.js");

            ParseContent = ParseContent.Replace("DefaltValue", Key1);
            ParseContent = ParseContent.Replace("StrangeKey", StrangeKey);
            ParseContent = ParseContent.Replace("CalCulations", TrueCalculations);
            engine.Parse(ParseContent);

            string jschl_answer = engine.Eval("GetResult()").ToString();

            MessageBox.Show(jschl_answer);
            return(true);
        }