Exemple #1
0
        private static void Boot_UserOperations()
        {
            string Host = "192.168.178.26";

            //Host = GetHost();
            ClientCommands.INIT();
            if (CommandSender.INIT(Host))
            {
                while (true)
                {
                    Console.Write($"BlackOS@{Host}>");
                    string input = Console.ReadLine();
                    if (input.StartsWith("/"))
                    {
                        ClientCommands.ExecuteCommand(input.Substring(1));
                    }
                    else
                    {
                        CommandSender.ExecCommand(input);
                    }
                }
            }
            else
            {
                Console.WriteLine("Failed to INIT CommandSender");
            }
            Console.ReadKey();
        }
Exemple #2
0
 private static void QSEND(string[] Args)
 {
     if (Args.Length > 0)
     {
         UInt16 CID;
         if (UInt16.TryParse(Args[0], out CID))
         {
             if (CommandSender.VerifyKey(CID))
             {
                 string args = "";
                 for (int x = 1; x < Args.Length; x++)
                 {
                     args += " " + Args[x];
                 }
                 CommandSender.SendCommand(CID, args);
             }
             else
             {
                 Console.WriteLine("Invalid CID");
             }
         }
         else
         {
             Console.WriteLine("A CID is Required");
         }
     }
     else
     {
         Console.WriteLine("A CID is Required");
     }
 }
Exemple #3
0
        private static void Boot_CmdOperations(string[] args)
        {
            if (args[0] == "-h" || args[0] == "--help")
            {
                DisplayHelpTextForCommandExecution();
            }
            else
            {
                string Host = args[0];
                CommandSender.INIT(Host, false);
                ClientCommands.INIT(false);
                Queue <CommandObjectiv> Objectivs = new Queue <CommandObjectiv>();


                string Args = args[1];
                for (int x = 2; x < args.Length; x++)
                {
                    Args += " " + args[x];
                }
                //hint string is char array
                //you can use a string just like you would a char array
                for (int x = 0; x < Args.Length; x++)
                {
                    if (Args[x] == '-')
                    {
                        x++;
                        if (Args[x] == 'c')
                        {
                            x += 2;
                            if (Args[x] == '(')
                            {
                                x++;
                                int      EndOfCommand = Args.Substring(x).IndexOf(")");
                                string[] commandArgs  = Args.Substring(x, EndOfCommand).Split(new char[1] {
                                    ','
                                }, StringSplitOptions.RemoveEmptyEntries);
                                x += EndOfCommand + 1;
                                CommandObjectiv cmd = new CommandObjectiv()
                                {
                                    isLocalCommand        = true,
                                    Args                  = "",
                                    isRemoteCommandByName = false,
                                    RemoteCommandCID      = 0,
                                    RemoteCommandName     = null,
                                };

                                if (ClientCommands.VerifyCommandExists(commandArgs[0]))
                                {
                                    cmd.LocalCommandName = commandArgs[0];
                                }
                                else
                                {
                                    Console.WriteLine("Command Doesnt Exist:" + commandArgs[0]);
                                    Environment.Exit(1);
                                }
                                if (commandArgs.Length > 1)
                                {
                                    cmd.Args += commandArgs[1];
                                    for (int y = 2; y < commandArgs.Length; y++)
                                    {
                                        cmd.Args += " " + commandArgs[y];
                                    }
                                }
                                Objectivs.Enqueue(cmd);
                            }
                            else
                            {
                                Console.WriteLine("Invalid Char at " + x);
                                Environment.Exit(1);
                            }
                        }
                        else if (Args[x] == 's')
                        {
                            x += 2;
                            if (Args[x] == '(')
                            {
                                x++;
                                int      EndOfCommand = Args.Substring(x).IndexOf(")");
                                string[] commandArgs  = Args.Substring(x, EndOfCommand).Split(new char[1] {
                                    ','
                                }, StringSplitOptions.RemoveEmptyEntries);
                                x += EndOfCommand + 1;
                                CommandObjectiv cmd = new CommandObjectiv()
                                {
                                    isLocalCommand   = false,
                                    LocalCommandName = null,
                                    Args             = "",
                                };
                                if (UInt16.TryParse(commandArgs[0], out cmd.RemoteCommandCID))
                                {
                                    cmd.isRemoteCommandByName = false;
                                    cmd.RemoteCommandName     = null;
                                }
                                else
                                {
                                    cmd.isRemoteCommandByName = true;
                                    cmd.RemoteCommandName     = commandArgs[0];
                                }
                                if (commandArgs.Length > 1)
                                {
                                    cmd.Args += commandArgs[1];
                                    for (int y = 2; y < commandArgs.Length; y++)
                                    {
                                        cmd.Args += " " + commandArgs[y];
                                    }
                                }
                                Objectivs.Enqueue(cmd);
                            }
                            else
                            {
                                Console.WriteLine("Invalid Char at " + x);
                                Environment.Exit(1);
                            }
                        }
                        else if (Args[x] == 'h')
                        {
                            DisplayHelpTextForCommandExecution();
                            Environment.Exit(0);
                        }
                        else
                        {
                            Console.WriteLine("Invalid Char at " + x);
                            Environment.Exit(1);
                        }
                    }
                }


                while (Objectivs.Count > 0)
                {
                    CommandObjectiv objectiv = Objectivs.Dequeue();

                    if (objectiv.isLocalCommand)
                    {
                        ClientCommands.ExecuteCommand(objectiv.LocalCommandName + " " + objectiv.Args);
                    }
                    else
                    {
                        if (objectiv.isRemoteCommandByName)
                        {
                            CommandSender.SendCommand(objectiv.RemoteCommandName, objectiv.Args);
                        }
                        else
                        {
                            CommandSender.SendCommand(objectiv.RemoteCommandCID, objectiv.Args);
                        }
                    }
                }
            }
        }