Esempio n. 1
0
        void Remoting()
        {
            try
            {
                DataSerializer ds = new DataSerializer();
                string         a  = ds.Serialize(Data);
                if (a == "WAIT_NEXT_DATA")
                {
                    jsonComm.CommandType   = "WAIT_NEXT_DATA";
                    jsonComm.Client_Socket = Client;
                    LastCommand            = jsonComm.CommandType.ToString();
                }
                else
                {
                    jsonComm = JsonConvert.DeserializeObject <JsonCommand>(a);
                    jsonComm.Client_Socket = Client;
                    LastCommand            = jsonComm.CommandType.ToString();
                }
                if (!SystemCommandIsActive)
                {
                    goto UserCommands;
                }
                switch (jsonComm.CommandType)
                {
                case "print_message":
                {
                    PrintMessage_Command PrintMessageComm = new PrintMessage_Command(jsonComm);
                    Command Comm = PrintMessageComm;
                    INV = new Invoker(Comm);
                    INV.Execute();
                    break;
                }

                case "open_program":
                {
                    ProgramOpen_Command ProgramOpenCommand = new ProgramOpen_Command(jsonComm);
                    Command             Comm = ProgramOpenCommand;
                    INV = new Invoker(Comm);
                    INV.Execute();
                    break;
                }

                case "get_programs":
                {
                    GetPrograms_Command GetProgramsCommand = new GetPrograms_Command(jsonComm);
                    Command             Comm = GetProgramsCommand;
                    INV = new Invoker(Comm);
                    INV.Execute();
                    break;
                }

                case "get_processes":
                {
                    GetProcesses_Command GetProcessesCommand = new GetProcesses_Command(jsonComm);
                    Command Comm = GetProcessesCommand;
                    INV = new Invoker(Comm);
                    INV.Execute();
                    break;
                }

                case "process_kill":
                {
                    ProcessKill_Command ProcessKillCommand = new ProcessKill_Command(jsonComm);
                    Command             Comm = ProcessKillCommand;
                    INV = new Invoker(Comm);
                    INV.Execute();
                    break;
                }

                case "get_logs":
                {
                    GetLogs_Command getlog = new GetLogs_Command(jsonComm);
                    Command         comm   = getlog;
                    INV = new Invoker(comm);
                    INV.Execute();
                    break;
                }

                default:
                {
                    if (OutParserPermission)
                    {
                        OutParser(jsonComm);
                    }
                    break;
                }
                }
UserCommands:
                if (OutParserPermission)
                {
                    OutParser(jsonComm);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + ex.Source.ToString());
            }
        }
Esempio n. 2
0
        public DataParser(String Data, Socket Client)
        {
            try
            {
                DataSerializer ds = new DataSerializer();
                string         a  = ds.Serialize(Data);
                if (a == "WAIT_NEXT_DATA")
                {
                    jsonComm.CommandType   = "WAIT_NEXT_DATA";
                    jsonComm.Client_Socket = Client;
                    LastCommand            = jsonComm.CommandType.ToString();
                }
                else
                {
                    jsonComm = JsonConvert.DeserializeObject <JsonCommand>(a);
                    jsonComm.Client_Socket = Client;
                    LastCommand            = jsonComm.CommandType.ToString();
                }
                switch (jsonComm.CommandType)
                {
                case "print_message":
                {
                    PrintMessage_Command PrintMessageComm = new PrintMessage_Command(jsonComm);
                    Command Comm = PrintMessageComm;
                    Invoker Inv  = new Invoker(Comm);
                    Inv.Execute();
                    break;
                }

                case "open_program":
                {
                    ProgramOpen_Command ProgramOpenCommand = new ProgramOpen_Command(jsonComm);
                    Command             Comm = ProgramOpenCommand;
                    Invoker             Inv  = new Invoker(Comm);
                    Inv.Execute();
                    break;
                }

                case "get_folder_list":
                {
                    GetFolderList_Command GetFolderListCommand = new GetFolderList_Command(jsonComm);
                    Command Comm = GetFolderListCommand;
                    Invoker Inv  = new Invoker(Comm);
                    Inv.Execute();
                    break;
                }

                case "get_file":
                {
                    GetFile_Command GetFileCommand = new GetFile_Command(jsonComm);
                    Command         Comm           = GetFileCommand;
                    Invoker         Inv            = new Invoker(Comm);
                    Inv.Execute();
                    break;
                }

                case "get_programs":
                {
                    GetPrograms_Command GetProgramsCommand = new GetPrograms_Command(jsonComm);
                    Command             Comm = GetProgramsCommand;
                    Invoker             Inv  = new Invoker(Comm);
                    Inv.Execute();
                    break;
                }

                case "get_processes":
                {
                    GetProcesses_Command GetProcessesCommand = new GetProcesses_Command(jsonComm);
                    Command Comm = GetProcessesCommand;
                    Invoker Inv  = new Invoker(Comm);
                    Inv.Execute();
                    break;
                }

                case "process_kill":
                {
                    ProcessKill_Command ProcessKillCommand = new ProcessKill_Command(jsonComm);
                    Command             Comm = ProcessKillCommand;
                    Invoker             Inv  = new Invoker(Comm);
                    Inv.Execute();
                    break;
                }

                default:
                {
                    if (OutParserPermission)
                    {
                        OutParser(jsonComm);
                    }
                    break;
                }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + ex.Source.ToString());
            }
        }