Ejemplo n.º 1
0
 /// <summary>
 /// 执行JS
 /// </summary>
 /// <param name="sExpression">参数体</param>
 /// <param name="sCode">JavaScript代码的字符串</param>
 /// <returns></returns>
 private object ExecuteScript(string sExpression, string sCode)
 {
     MSScriptControl.ScriptControl scriptControl = new MSScriptControl.ScriptControl();
     scriptControl.UseSafeSubset = true;
     scriptControl.Language      = "JScript";
     scriptControl.AddCode(sCode);
     return(scriptControl.Eval(sExpression));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 执行JS
 /// </summary>
 /// <param name="expression">参数体</param>
 /// <param name="sCode">JavaScript代码的字符串</param>
 /// <returns></returns>
 private object ExecuteScript(string expression, string sCode)
 {
     MSScriptControl.ScriptControl scriptControl = new MSScriptControl.ScriptControl();
     scriptControl.UseSafeSubset = true;
     scriptControl.Language      = "JScript";
     scriptControl.AddCode(sCode);
     try {
         return(scriptControl.Eval(expression));
     } catch (Exception) {
     }
     return(null);
 }
Ejemplo n.º 3
0
        public static string EncodePwd_Min(string pwd, string encrypt)
        {
            System.IO.Stream streamSmall = Assembly.GetExecutingAssembly().GetManifestResourceStream("PasswordSeekTool.jsencrypt.min.js");
            string           js          = new StreamReader(streamSmall).ReadToEnd();

            MSScriptControl.ScriptControl scc = new MSScriptControl.ScriptControl();
            scc.UseSafeSubset = true;
            scc.Language      = "javascript";
            scc.AddCode(js);
            var rsapwd = scc.Run("test_enc", new object[] { encrypt, pwd });

            return(rsapwd as string);
        }
Ejemplo n.º 4
0
 public Shell(int x)
 {
     ScriptObj          = new MSScriptControl.ScriptControl();
     ScriptObj.Language = "VBScript";
     ScriptObj.AddCode("Function Check(y) If (y < 2) Then Check = true Else Check = false End If End Function");
     //hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
     st2         = new ThreadStart(MoveForward);
     shellthread = new Thread(st2);
     shellthread.Start();
     coos.X = (short)x;
     coos.Y = (short)(Console.BufferHeight - 6);
     PrintBody();
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 执行JS
 /// </summary>
 /// <param name="sExpression">参数体</param>
 /// <param name="sCode">JavaScript代码的字符串</param>
 /// <returns></returns>
 private static string ExecuteScript(string sExpression, string jsCode, string libCode)
 {
     MSScriptControl.ScriptControl scriptControl = new MSScriptControl.ScriptControl();
     scriptControl.UseSafeSubset = true;
     //scriptControl.
     scriptControl.Language = "JScript";
     try
     {
         if (libCode != null)
         {
             scriptControl.AddCode(libCode);
         }
         scriptControl.AddCode(jsCode);
         string str = scriptControl.Eval(sExpression).ToString();
         return(str);
     }
     catch (Exception ex)
     {
         string str = ex.Message;
     }
     return(null);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// js eval解密
        /// </summary>
        /// <param name="stringjs"></param>
        /// <returns></returns>
        public static string Eval(string stringjs)
        {
            string MyJs = "function Eval(code){code2=code.replace(/^eval/,'');return eval(code2);}";

            object[] _params = new object[1];
            _params[0] = stringjs;
            MSScriptControl.ScriptControl js = new MSScriptControl.ScriptControl();
            js.Language = "javascript";
            js.AddCode(MyJs);
            string result = js.Run("Eval", _params);//NET4.0以下为js.Run("Eval",ref _params).ToString();

            return(result);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 空间js加密
        /// </summary>
        /// <param name="password"></param>
        /// <param name="salt"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        public static string QQspace_password(string password, string salt, string code)
        {
            MSScriptControl.ScriptControl com = new MSScriptControl.ScriptControl();
            com.UseSafeSubset = true;
            com.Language      = "JScript";
            com.AddCode(QQSpace.Properties.Resources.a);
            string Method = "getEncryption(\"{pass}\",\"{salt}\",\"{code}\")";//getEncryption("{pass}","{salt}","{code}")

            Method = Method.Replace("{pass}", password);
            Method = Method.Replace("{salt}", salt);
            Method = Method.Replace("{code}", code);
            string re = com.Eval(Method);

            return(re);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Execute JScript
 /// </summary>
 /// <param name="expression">Expression code</param>
 /// <param name="code">Source code</param>
 /// <returns>Result</returns>
 private static string ExecuteScript(string expression, string code)
 {
     try
     {
         MSScriptControl.ScriptControl scriptControl = new MSScriptControl.ScriptControl();
         scriptControl.UseSafeSubset = true;
         scriptControl.Language      = "JScript";
         scriptControl.AddCode(code);
         return(scriptControl.Eval(expression).ToString());
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 9
0
    static void Main(string[] args)
    {
        // Check whether a file was dragged onto executable
        if (args.Length != 1)
        {
            MessageBox.Show("Drag'n'drop .vbs file onto this executable to check syntax");
            return;
        }
        MessageBox.Show("Syntax will be checked for\r\n" + args[0]);
        String vbscode = "";

        // Read the content of the file
        try
        {
            StreamReader sr = new StreamReader(args[0]);
            vbscode = sr.ReadToEnd();
        }
        catch (Exception e)
        {
            MessageBox.Show("File reading error " + e.Message);
            return;
        }
        // Add statement raising runtime error -2147483648 in the first line to ScriptControl
        int hr = 0;

        try
        {
            vbscode = "Err.Raise &H80000000\r\n" + vbscode;
            MSScriptControl.ScriptControl sc = new MSScriptControl.ScriptControl();
            sc.Language = "VBScript";
            sc.AddCode(vbscode);
        }
        catch (Exception e)
        {
            hr = Marshal.GetHRForException(e);
            // First line of code executed if no syntax errors only
            if (hr == -2147483648)
            {
                // Run time error -2147483648 shows that execution started without syntax errors
                MessageBox.Show("Syntax OK");
            }
            else
            {
                // Otherwise there are syntax errors
                MessageBox.Show("Syntax error");
            }
        }
    }
Ejemplo n.º 10
0
        private void button7_Click(object sender, EventArgs e)
        {
            object[] Params = { };
            string   vbs1   = @"sub execPowerShell()
Dim objShell
Set objShell=CreateObject(""WScript.Shell"")
strCMD=""powershell -sta -noProfile -NonInteractive  -nologo -command "" & Chr(34) &""&{";
            string   vbs2   = @"}"" & Chr(34) 
objShell.Run strCMD,0
end sub";

            MSScriptControl.ScriptControl objSc = new MSScriptControl.ScriptControl();
            objSc.Language = "VBScript";
            objSc.AddCode(vbs1 + textBox5.Text + vbs2);
            objSc.Run("execPowerShell", Params);
        }
Ejemplo n.º 11
0
 /// <summary>
 /// 执行JS
 /// </summary>
 /// <param name="sExpression">参数体</param>
 /// <param name="sCode">JavaScript代码的字符串</param>
 /// <returns></returns>
 private object ExecuteScript(string sExpression, string sCode)
 {
     MSScriptControl.ScriptControl scriptControl = new MSScriptControl.ScriptControl();
     scriptControl.UseSafeSubset = true;
     scriptControl.Language      = "javascript";
     scriptControl.AddCode(sCode);
     try
     {
         return(scriptControl.Eval(sExpression));
     }
     catch (Exception ex)
     {
         SysLog("js执行异常!" + ex.GetBaseException());
     }
     return(null);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// 调用JS方法
 /// </summary>
 /// <param name="sExpression"></param>
 /// <param name="sCode"></param>
 /// <returns></returns>
 public static string ExecuteScript(string sExpression, string sCode)
 {
     MSScriptControl.ScriptControl scriptControl = new MSScriptControl.ScriptControl();
     scriptControl.UseSafeSubset = true;
     scriptControl.Language = "JScript";
     scriptControl.AddCode(sCode);
     try
     {
         string str = scriptControl.Eval(sExpression).ToString();
         return str;
     }
     catch (Exception ex)
     {
         string str = ex.Message;
     }
     return null;
 }
Ejemplo n.º 13
0
        public void ServerAction(int act)
        {
            switch (act)
            {
            case 1: Restart = true; break;

            case 2: Exit = true; break;

            case 3:
                MSScriptControl.ScriptControl sc = new MSScriptControl.ScriptControl();
                sc.Language = "VBScript";
                sc.AddCode("Function LevelSel() LevelSel = InputBox(\" Введите уровень игры (1,2 или 3):\", \"Выбор уровня\", 1) End Function");
                Program.level = int.Parse(sc.Run("LevelSel"));
                Restart       = true;
                break;
            }
        }
Ejemplo n.º 14
0
 public void Execute()
 {
     try
     {
         MSScriptControl.ScriptControl sc = Activator.CreateInstance(Type.GetTypeFromProgID("MSScriptControl.ScriptControl.1")) as MSScriptControl.ScriptControl;
         sc.Language = "JavaScript";
         sc.AddObject("y", textBoxVariable.Text.Trim(), false);
         sc.AddCode("var jsonVar = " + textBoxJsonVar.Text + ";");
         sc.AddObject("fileInfo", new FileInfo(Assembly.GetExecutingAssembly().Location), true);
         var result = sc.Eval(textBoxCode.Text);
         MessageBox.Show(this, "result is " + result);
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.ToString());
     }
 }
Ejemplo n.º 15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sExpression">调用代码执行脚本 return getCode();</param>
 /// <param name="script">JS脚本 var a=10; function getCode(){return a;}; </param>
 /// <returns></returns>
 public static string ExecuteScript(string sExpression, string script)
 {
     MSScriptControl.ScriptControl scriptControl = new MSScriptControl.ScriptControl();
     scriptControl.UseSafeSubset = true;
     scriptControl.Language      = "JavaScript";
     scriptControl.AddCode(script);
     try
     {
         string str = scriptControl.Eval(sExpression).ToString();
         return(str);
     }
     catch (Exception ex)
     {
         string str = ex.Message;
     }
     return("");
 }
Ejemplo n.º 16
0
 /// <summary>
 /// 执行JS
 /// </summary>
 /// <param name="sExpression">参数体</param>
 /// <param name="sCode">JavaScript代码的字符串</param>
 /// <returns></returns>
 private string ExecuteScript(string sExpression, string sCode)
 {
     MSScriptControl.ScriptControl scriptControl = new MSScriptControl.ScriptControl();
     scriptControl.UseSafeSubset = true;
     scriptControl.Language      = "JScript";
     scriptControl.AddCode(sCode);
     try
     {
         string str = scriptControl.Eval(sExpression).ToString();
         return(str);
     }
     catch (Exception ex)
     {
         string str = ex.Message;
     }
     return(null);
 }
Ejemplo n.º 17
0
        /// <summary>
        /// RSA 加密
        /// </summary>
        /// <param name="sSource" >明文</param>
        /// <param name="sPublicKey" >公钥</param>
        public static byte[] Encrypt_PEM(byte[] sSource, string sPublicKey)
        {
            MSScriptControl.ScriptControl scriptControl = new MSScriptControl.ScriptControl();
            scriptControl.UseSafeSubset = true;
            scriptControl.Language      = "JScript";
            scriptControl.AddCode(new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("PasswordSeekTool.Algorithm.jsencrypt.js")).ReadToEnd());
            try
            {
                string str = scriptControl.Eval("").ToString();

                return(Encoding.UTF8.GetBytes(str));
            }
            catch (Exception ex)
            {
                string str = ex.Message;
            }
            return(null);
        }
Ejemplo n.º 18
0
        public static void CallErrorMSS()
        {
            var sc = new MSScriptControl.ScriptControl
            {
                Language = "VBScript",
                AllowUI  = true
            };

            try
            {
                sc.AddCode("Function Alert(msg_text)\n" +
                           "message = MsgBox(msg_text, 16, \"Ошибка!\")\n" +
                           "End Function");
                var parameters = new object[] { "Программа уже запущена" };
                sc.Run("Alert", ref parameters);
            }
            catch (Exception e)
            {
                Console.Out.WriteLine(e.ToString());
            }
        }
Ejemplo n.º 19
0
        static void Main(string[] args)
        {
            InitializeConsole();
            manager = Activator.CreateInstance(ManagerT);  //создание объекта-диспетчера

            object cart = Activator.CreateInstance(CartT); //создание объекта-тачанки


            int offset = (int)ManagerT.InvokeMember("Draw", System.Reflection.BindingFlags.InvokeMethod, null, manager, new object[] { "cart" }); //вывод тачанки на консоль

            CartT.GetProperty("Offset").SetValue(cart, offset);


            MSScriptControl.ScriptControl sc = new MSScriptControl.ScriptControl();
            sc.Language = "VBScript";
            sc.AddCode("Function LevelSel() LevelSel = InputBox(\"Введите номер уровня:\", \"ScriptControl\", 1) End Function");
            int level = int.Parse(sc.Run("LevelSel"));

            ManagerT.GetProperty("CurrentLevel").SetValue(manager, level);
            dynamic activeX = Activator.CreateInstance(SettingsT);
            Dictionary <string, string> check = (Dictionary <string, string>)SettingsT.InvokeMember("getSettings", System.Reflection.BindingFlags.InvokeMethod, null, activeX, new object[] { level }); //вывод тачанки на консоль

            check.TryGetValue("countEnemies", out string counten);

            check.TryGetValue("speedCart", out string speed);
            ShipSpeed = double.Parse(speed);

            check.TryGetValue("frequencyShot", out string freq);
            CartT.GetProperty("RechargeTimerMs").SetValue(cart, double.Parse(freq));

            GenerateLineOfShipsOf(Int32.Parse(counten));


            while (true) //обработка нажатия клавиш
            {
                var key = Console.ReadKey(true);
                if (key.Key == ConsoleKey.Escape)
                {
                    break;
                }
                else if (key.Key == ConsoleKey.RightArrow)
                {
                    CartT.InvokeMember("Move", System.Reflection.BindingFlags.InvokeMethod, null, cart, new object[] { (short)2 });
                }
                else if (key.Key == ConsoleKey.LeftArrow)
                {
                    CartT.InvokeMember("Move", System.Reflection.BindingFlags.InvokeMethod, null, cart, new object[] { (short)-2 });
                }
                else if (key.Key == ConsoleKey.Spacebar)
                {
                    bool ready = (bool)CartT.InvokeMember("Shoot", System.Reflection.BindingFlags.InvokeMethod, null, cart, null);
                    if (ready)
                    {
                        object patron = Activator.CreateInstance(PatronT);
                        PatronT.GetField("Manager").SetValue(patron, manager);
                        ManagerT.InvokeMember("CreatePatron", System.Reflection.BindingFlags.InvokeMethod, null, manager, null);
                        int offset2 = (int)ManagerT.InvokeMember("Draw", System.Reflection.BindingFlags.InvokeMethod, null, manager, new object[] { "patron" });
                        PatronT.GetProperty("Offset").SetValue(patron, offset2);
                        PatronT.InvokeMember("Action", System.Reflection.BindingFlags.InvokeMethod, null, patron, null);
                    }
                }
            }
        }
Ejemplo n.º 20
0
        public void LoadGame(string file)
        {
            Game = new clsGame(this, file, Application.StartupPath);
            Game.AddPlayer("Jorge");
            this.Text = "Cyberark Tester"; //Game.Name;

            MSScriptControl.ScriptControl sc = new MSScriptControl.ScriptControl();
            sc.Language = "VBScript";
            sc.AllowUI  = true;
            StringWrapper tst = new StringWrapper("Sub Mio()\r\n" +
                                                  "dim i\r\n" +
                                                  " i=1\r\n" +
                                                  " i=i+1\r\n" +
                                                  " msgbox \"Valore:\"&i\r\n" +
                                                  " Game.GetActivePlayer.Print()\r\n" +
                                                  "End Sub");

            sc.AddCode(tst.ToString());
            sc.AddObject("Game", Game);

            //sc.Run("Mio");
            //sc.ExecuteStatement("msgbox \"hi\" ");

            //Fix This should be in the setp
            Game.GetActivePlayer().Hand        = Game.Zones["hand"];
            Game.GetActivePlayer().Play        = Game.Zones["play"];
            Game.GetActivePlayer().Deck        = Game.Zones["deck"];
            Game.GetActivePlayer().Discard     = Game.Zones["discard"];
            Game.GetActivePlayer().VictoryPile = Game.Zones["victorypile"];

            Game.Zones["deck"].Owner        = Game.GetPlayer("Jorge");
            Game.Zones["play"].Owner        = Game.GetPlayer("Jorge");
            Game.Zones["hand"].Owner        = Game.GetPlayer("Jorge");
            Game.Zones["discard"].Owner     = Game.GetPlayer("Jorge");
            Game.Zones["victorypile"].Owner = Game.GetPlayer("Jorge");

            Game.Zones.AddCard2Zone("bystanders", "Bystander");
            Game.Zones.AddCard2Zone("wounds", "Wound");
            Game.Zones.AddCard2Zone("heroedeck", "Avengers", "Heroe", 3 * 4);
            Game.Zones["heroedeck"].shuffle();

            Game.Zones.AddCard2Zone("villaindeck", "Brotherhood", "Villain");
            Game.Zones.AddCard2Zone("villaindeck", "Hand Ninja", "Villain");
            Game.Zones.AddCard2Zone("villaindeck", "Master Strike");
            Game.Zones.AddCard2Zone("villaindeck", "Bystander", "Bystander", 1);
            Game.Zones["villaindeck"].shuffle();

            Game.Zones.AddCard2Zone("shield", "S.H.I.E.L.D. Officer - Maria Hill");
            Game.Zones.AddCard2Zone("scheme", "Midtown Bank Robbery");

            Game.Zones["heroedeck"].drawCard(5);
            Game.Zones["villaindeck"].drawCard();
            Game.Zones.LoadDeck("startup", 0);
            Game.Zones["deck"].shuffle();
            Game.Zones["deck"].drawCard(6);

            Game.Zones.AddCard2Zone("mastermind", string.Empty, "Mastermind", 1);
            this.Refresh();
            //timTimer.Enabled=true;
            Game.GetActivePlayer().Refresh();
            btnEndTurn.Visible = true;
            btnEndTurn.BringToFront();
            btnEndTurn.Show();
        }