Example #1
0
        private void KickOffCimAsync(Computer computer, Credential credential, string commandline, CimSessionOptions options)
        {
            var optionsBuilder = new DbContextOptionsBuilder <ACEWebServiceDbContext>();

            optionsBuilder.UseSqlServer("Server=(localdb)\\MSSQLLocalDB;Database=ACEWebService;Trusted_Connection=True;MultipleActiveResultSets=true");
            using (ACEWebServiceDbContext context = new ACEWebServiceDbContext(optionsBuilder.Options))
            {
                // Convert stored password to a secure string
                SecureString securePwd = new SecureString();
                foreach (char c in _cryptoService.Decrypt(credential.Password))
                {
                    securePwd.AppendChar(c);
                }

                CimCredential cimCreds = null;

                if (credential.UserName.Contains('\\'))
                {
                    // Create a CimCredential object
                    cimCreds = new CimCredential(PasswordAuthenticationMechanism.Kerberos, credential.UserName.Split('\\')[0], credential.UserName.Split('\\')[1], securePwd);
                }
                else
                {
                    // Create a CimCredential object
                    cimCreds = new CimCredential(PasswordAuthenticationMechanism.Default, null, credential.UserName, securePwd);
                }

                // Create a CimSession with the remote system
                options.AddDestinationCredentials(cimCreds);
                CimSession session = CimSession.Create(computer.ComputerName, options);

                // Create a CimMethodParametersCollection to pass to method invocation
                CimMethodParametersCollection collection = new CimMethodParametersCollection();
                collection.Add(CimMethodParameter.Create("CommandLine", commandline, CimFlags.None));

                CimMethodResult result = session.InvokeMethod("root/cimv2", "Win32_Process", "Create", collection);
                if (result.ReturnValue.ToString() == "0")
                {
                }
                else
                {
                }

                session.Dispose();
            }
        }
Example #2
0
 public SweepController(ISweepExecutionService sweepExecutionService, ACEWebServiceDbContext context)
 {
     _sweepExecutionService = sweepExecutionService;
     _context = context;
 }
Example #3
0
 public DownloadService(ACEWebServiceDbContext context, ICryptographyService cryptoService, IOptions <AppSettings> settings)
 {
     _context       = context;
     _cryptoService = cryptoService;
     _settings      = settings.Value;
 }
Example #4
0
 public UserController(ACEWebServiceDbContext context)
 {
     _context = context;
 }
Example #5
0
 public DownloadController(ACEWebServiceDbContext context, IHostingEnvironment hostingEnv, IDownloadService downloadService)
 {
     _context         = context;
     _hostingEnv      = hostingEnv;
     _downloadService = downloadService;
 }
Example #6
0
 public ApiKeyHandler(ACEWebServiceDbContext context)
 {
     _context = context;
 }
Example #7
0
 public DiscoveryActiveDirectoryService(ACEWebServiceDbContext context, ICryptographyService cryptoService)
 {
     _context       = context;
     _cryptoService = cryptoService;
 }
Example #8
0
 public ScriptController(ACEWebServiceDbContext context, IHostingEnvironment hostingEnv)
 {
     _context = context;
     _hostingEnv = hostingEnv;
 }
Example #9
0
 public CredentialController(ACEWebServiceDbContext context, ICryptographyService cryptoService)
 {
     _context       = context;
     _cryptoService = cryptoService;
 }
Example #10
0
 public ScheduleController(ACEWebServiceDbContext context, ISchedulingService schedulingService)
 {
     _context           = context;
     _schedulingService = schedulingService;
 }
Example #11
0
 public IsAdminHandler(ACEWebServiceDbContext context)
 {
     _context = context;
 }
Example #12
0
 public SweepExecutionService(ACEWebServiceDbContext context, ICryptographyService cryptoService)
 {
     _context       = context;
     _cryptoService = cryptoService;
 }
Example #13
0
 public ScanController(ACEWebServiceDbContext context)
 {
     _context = context;
 }