Exemplo n.º 1
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                PrintUsage();
                return;
            }
            var hostname = args[0];

#if DEBUG
            Console.WriteLine("[*] hostname: {0}", hostname);
#endif
            var version = GetDotNetVersion(hostname);
            CopyServiceExe(version, hostname);
            InstallService(hostname, version);
            try
            {
                CSExecClient.Connect(hostname);
            }
            catch (TimeoutException te)
            {
                Console.WriteLine(te.Message);
            }
            UninstallService(hostname);
            DeleteServiceExe(hostname);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                PrintUsage();
                return;
            }
            var hostname = args[0];

#if DEBUG
            Console.WriteLine("[*] hostname: {0}", hostname);
#endif

            var version = GetDotNetVersion(hostname);

            byte[] svcexe = new byte[0];
            if (version == DotNetVersion.net35)
            {
                svcexe = Properties.Resources.csexecsvc_net35;
            }
            if (version == DotNetVersion.net40)
            {
                svcexe = Properties.Resources.csexecsvc_net40;
            }
            if (version == DotNetVersion.net45)
            {
                svcexe = Properties.Resources.csexecsvc_net45;
            }
            var path = hostname + @"\admin$\system32\csexecsvc.exe";
            try
            {
                File.WriteAllBytes(path, svcexe);
            } catch (UnauthorizedAccessException uae)
            {
                Console.WriteLine(uae.Message);
                return;
            }

            InstallService(hostname, version);
            try
            {
                CSExecClient.Connect(hostname);
            }
            catch (TimeoutException te)
            {
                Console.WriteLine(te.Message);
            }
            UninstallService(hostname);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                PrintUsage();
                return;
            }
            var hostname = args[0];

            var initialCommand          = string.Empty;
            var stopAfterInitialCommand = false;

            if (args.Length > 1)
            {
                if (args[1] == "cmd")
                {
                    int initialCommandArgsSkip = 2;

                    if (args.Length > 2)
                    {
                        var cParameter = "/c";
                        if (args[2] == cParameter)
                        {
                            stopAfterInitialCommand = true;
                            ++initialCommandArgsSkip;
                        }
                    }

                    initialCommand = string.Join(" ",
                                                 args.Skip(initialCommandArgsSkip)
                                                 .Select(arg =>
                    {
                        if (arg.Contains(" "))
                        {
                            if (arg.EndsWith(@"\"))
                            {
                                arg += @"\";         // add backslash to ensure existing backslash is not evaluated as escape char for trailing quote char
                            }

                            arg = $"\"{arg}\"";
                        }

                        return(arg);
                    })
                                                 .ToArray());
                }
            }

#if DEBUG
            Console.WriteLine("[*] hostname: {0}", hostname);
#endif
            var version = GetDotNetVersion(hostname);
            CopyServiceExe(version, hostname);
            InstallService(hostname, version);
            try
            {
                CSExecClient.Connect(hostname, initialCommand, stopAfterInitialCommand);
            }
            catch (TimeoutException te)
            {
                Console.WriteLine(te.Message);
            }
            UninstallService(hostname);
            DeleteServiceExe(hostname);
        }