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