Esempio n. 1
0
        static int Execute(ExecuteOptions options)
        {
            try
            {
                //Connect to target VM
                Connect(options.url, options.username, options.password, options.ip);


                //Build credential object to authenticate to guest OS
                if (options.guestusername == null && options.guestpassword == null)
                {
                    Log("[x] Authenticating to guest using pass through authentication (SSPI)");
                    string host      = GetProperty <GuestInfo>(vm, "guest").hostName;
                    string domain    = Environment.UserDomainName;
                    string principal = "host/" + host + "@" + domain;
                    creds = GuestAuth(GetSspiToken(principal));
                }
                else
                {
                    Log("[x] Authenticating to guest using provided username and password");
                    creds = new NamePasswordAuthentication()
                    {
                        username           = options.guestusername,
                        password           = options.guestpassword,
                        interactiveSession = false,
                    };
                }

                if (options.linux)
                {
                    ExecuteCommand(creds, "-c " + options.command, @"/bin/sh", options.outputDir == null ? "/tmp" : options.outputDir, options.output, options.linux);
                }
                else
                {
                    ExecuteCommand(creds, "/c " + options.command, @"C:\Windows\System32\cmd.exe", options.outputDir == null ? @"C:\Windows\Temp" : options.outputDir, options.output, options.linux);
                }
            }
            catch (Exception fault)
            {
                Error(fault);
            }
            return(0);
        }
Esempio n. 2
0
 static int Execute(ExecuteOptions options)
 {
     try
     {
         //Connect to target VM
         Connect(options.url, options.username, options.password, options.ip);
         //Build credential object to authenticate to guest OS
         creds = new NamePasswordAuthentication()
         {
             username           = options.guestusername,
             password           = options.guestpassword,
             interactiveSession = false,
         };
         ExecuteCommand(creds, "/c " + options.command, @"C:\Windows\System32\cmd.exe", @"C:\Users\Public", options.output);
     }
     catch (Exception fault)
     {
         Error(fault);
     }
     return(0);
 }