コード例 #1
0
ファイル: CoreCommands.cs プロジェクト: netxph/redspect
        public ActionResult About(object args)
        {
            ResultBuilder builder = new ResultBuilder();

            builder.WriteLine("RedSpect 1.0 Copyright (c) Navitaire 2010");
            builder.WriteLine("Marc Vitalis (c) 2011");

            return builder.CreateResult(null);
        }
コード例 #2
0
        public ActionResult ExecuteScript(string command)
        {
            var engine = Ruby.CreateEngine();

            MemoryStream stream = new MemoryStream();
            engine.Runtime.IO.SetOutput(stream, new UTF8Encoding());

            foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
            {
                if (!(assembly.ManifestModule is System.Reflection.Emit.ModuleBuilder))
                {
                    engine.Runtime.LoadAssembly(assembly);
                }
            }

            var results = engine.Execute(command);

            stream.Position = 0;
            StreamReader reader = new StreamReader(stream);

            ResultBuilder builder = new ResultBuilder();

            while (!reader.EndOfStream)
            {
                builder.WriteLine(reader.ReadLine());
            }

            reader.Close();
            stream.Close();

            return builder.CreateResult(results);
        }
コード例 #3
0
ファイル: WindowsTestCommand.cs プロジェクト: netxph/redspect
        public ActionResult WriteValueOfX(object args)
        {
            ResultBuilder builder = new ResultBuilder();

            Injection.WriteForm(string.Format("The value of X is {0}", Injection.X));
            builder.WriteLine("Sent to target client.");

            return builder.CreateResult(null);
        }
コード例 #4
0
ファイル: CommandManager.cs プロジェクト: netxph/redspect
        public static ActionResult Connect(string connectionId, params string[] args)
        {
            ResultBuilder builder = new ResultBuilder();

            if (!IsConnected)
            {
                initializeConnection(connectionId, args);

                if (InspectProvider != null)
                {
                    builder.WriteLine(string.Format("Connected -> {0}", InspectProvider.HostDetails()));
                    _isConnected = true;
                }
                else
                {
                    return new ErrorResult("Error connecting to host.");
                }
            }
            else
            {
                builder.WriteLine("Already connected.");
            }

            return builder.CreateResult(null);
        }
コード例 #5
0
ファイル: CommandManager.cs プロジェクト: netxph/redspect
 private static void displayCommand(ResultBuilder builder, CommandDetail detail)
 {
     builder.WriteLine();
     builder.WriteLine(string.Format("COMMAND: {0}", detail.Name));
     builder.WriteLine(string.Format("   {0}", detail.Help));
     builder.WriteLine();
     builder.WriteLine(string.Format("USAGE: {0}", detail.Usage));
 }
コード例 #6
0
ファイル: CommandManager.cs プロジェクト: netxph/redspect
        public static ActionResult GetCommand()
        {
            ResultBuilder builder = new ResultBuilder();

            builder.WriteLine("Local Commands");
            builder.WriteLine("====================");
            foreach (string key in _commands.Keys)
            {
                var detail = _commands[key] as CommandDetail;

                if (detail != null)
                {
                    builder.WriteLine(string.Format("{0}# {1}", detail.Name.PadRight(20), detail.Help));
                }
            }

            if (IsConnected)
            {
                builder.WriteLine();
                builder.WriteLine("Remote Commands");
                builder.WriteLine("====================");
                var commands = InspectProvider.GetCommands();
                foreach (var command in commands)
                {
                    builder.WriteLine(string.Format("{0}# {1}", command.Name.PadRight(20), command.Help));
                }
            }

            return builder.CreateResult();
        }
コード例 #7
0
ファイル: CommandManager.cs プロジェクト: netxph/redspect
        public static ActionResult Disconnect()
        {
            ResultBuilder builder = new ResultBuilder();
            _isConnected = false;
            builder.WriteLine("Disconnected.");

            return builder.CreateResult(null);
        }