Beispiel #1
0
        public void cmdSet(string args, bool global)
        {
            if (!CheckModule(false, EModuleType.None))
            {
                return;
            }
            args = args.Trim();

            string[] prop = ArgumentHelper.ArrayFromCommandLine(args);
            if (prop == null || (prop.Length != 2 && prop.Length != 1))
            {
                _IO.WriteError(Lang.Get("Incorrect_Command_Usage"));
                return;
            }

            object val = prop.Length == 2 ? prop[1] : null;

            if (!_Current.SetProperty(prop[0], val))
            {
                _IO.WriteError(Lang.Get("Error_Converting_Value"));
            }
            else
            {
                if (global)
                {
                    _CurrentGlobal.SetProperty(prop[0], val);
                }
            }
        }
Beispiel #2
0
        public void GetCommand(string input, out string word, out string command, out string[] args)
        {
            if (input == null)
            {
                input = "";
            }
            input = input.TrimStart();

            int ix = input == null ? -1 : input.IndexOf(' ');

            if (ix != -1)
            {
                command = input.Substring(0, ix).Trim();

                args = ArgumentHelper.ArrayFromCommandLine(input.TrimStart().Substring(command.Length));
                // Añadimos un parametro extra para diferenciar que ya ha acabado de escribir el ultimo parametro
                if (input.EndsWith(" "))
                {
                    Array.Resize(ref args, args.Length + 1);
                }

                ix   = input.LastIndexOf(' ');
                word = input.Substring(ix + 1, input.Length - ix - 1);
            }
            else
            {
                // Command
                word    = input == null ? "" : input.TrimStart();
                command = "";
                args    = null;
            }
        }
Beispiel #3
0
        public void cmdSearch(string args)
        {
            args = args.Trim().ToLowerInvariant();


            string[] pars = ArgumentHelper.ArrayFromCommandLine(args);
            if (pars != null && pars.Length > 0)
            {
                CommandTable tb = new CommandTable();

                bool primera1 = false;
                foreach (Module m in ModuleCollection.Current.Search(pars))
                {
                    if (!primera1)
                    {
                        if (tb.Count > 0)
                        {
                            tb.AddRow("", "", "");
                        }
                        CommandTableRow row = tb.AddRow(Lang.Get("Type"), Lang.Get("Path"), Lang.Get("Disclosure"));
                        tb.AddRow(row.MakeSeparator());
                        tb.AddRow("", "", "");
                        primera1 = true;
                    }

                    tb.AddRow(Lang.Get("Modules"), m.FullPath, m.DisclosureDate.ToShortDateString());
                }
                bool primera2 = false;
                foreach (IModule m in PayloadCollection.Current.Search(pars))
                {
                    if (!primera2)
                    {
                        if (tb.Count > 0)
                        {
                            tb.AddRow("", "", "");
                        }
                        CommandTableRow row = tb.AddRow(Lang.Get("Type"), Lang.Get("Path"), "");
                        tb.AddRow(row.MakeSeparator());
                        tb.AddRow("", "", "");
                        primera2 = true;
                    }

                    tb.AddRow(Lang.Get("Payload"), m.FullPath, "");
                }

                if (primera1 || primera2)
                {
                    tb.OutputColored(_IO);
                }
                else
                {
                    _IO.WriteInfo(Lang.Get("Nothing_To_Show"));
                }
            }
            else
            {
                _IO.WriteInfo(Lang.Get("Be_More_Specific"));
            }
        }