Exemplo n.º 1
0
        private async Task UploadToS3(AWSCredentials credentials, RemoteCredentials config, string jobName, byte[] jobFile)
        {
            var s3Client = new AmazonS3Client(credentials);
            var s3       = new TransferUtility(s3Client);

            await s3.UploadAsync(new MemoryStream(jobFile), config.S3InputId, jobName + ".zip");
        }
Exemplo n.º 2
0
        /// <summary>
        /// Determine whether or not the remote registry service is active on the specified computer and if
        /// it is not start it, returning both the success or failoure of this action and the initial state of the
        /// service so that this can be restored at a later date if necessary
        /// </summary>
        /// <param name="remoteCredentials"></param>
        /// <param name="serviceWasRunning"></param>
        /// <returns></returns>
        protected int ValidateRemoteRegistryService(RemoteCredentials remoteCredentials, out bool serviceWasRunning)
        {
            try
            {
                ServiceController       sc             = new ServiceController(REMOTE_REGISTRY_SERVICE, remoteCredentials.RemoteHost);
                ServiceControllerStatus existingStatus = sc.Status;
                serviceWasRunning = (existingStatus == ServiceControllerStatus.Running);
                if (!serviceWasRunning)
                {
                    // The service is not running - try and start it
                    WriteAuditTrailMessage(AuditTrailMessage.SEVERITY.INFORMATION, "The remote registry service was not active on " + remoteCredentials.RemoteHost + ", attemptinmg to start it...");
                    sc.Start();
                    sc.WaitForStatus(ServiceControllerStatus.Running);
                }
            }
            catch (Exception ex)
            {
                WriteAuditTrailMessage(AuditTrailMessage.SEVERITY.INFORMATION, "An exception occured while checking the remote registry service on " + remoteCredentials.RemoteHost + ". The error was " + ex.Message);
                serviceWasRunning = true;                                       // Assume it was running as we don't want to touch it now!
                return(-1);
            }

            // At this point the remote registry service should be running
            return(0);
        }
Exemplo n.º 3
0
        public static HttpWebRequest CreateWebRequest(this Uri location, DavVerb verb, RemoteCredentials credentials)
        {
            var request = (HttpWebRequest)WebRequest.Create(location.For(credentials));

            request.Credentials = credentials.For(location);
            request.Method = verb.ToString().ToUpperInvariant();

            return request;
        }
Exemplo n.º 4
0
        public UploadFileController(IHostingEnvironment env, IOptions <ConnectionString> connString,
                                    MusicAlbumRepository musicRepository, IOptions <RemoteCredentials> remoteCredentials)
        {
            this.enviroment        = env;
            this.connectionString  = connString.Value;
            this.remoteCredentials = remoteCredentials.Value;


            Debug.WriteLine(connectionString.ServerInfo.IP);
        }
Exemplo n.º 5
0
        public async Task Save(RemoteCredentials remoteCredentials)
        {
            var configPath     = Path.Combine(Environment.GetFolderPath(SpecialFolder.LocalApplicationData, SpecialFolderOption.DoNotVerify), "BlenderAWS");
            var configFilePath = Path.Combine(configPath, "config.json");

            if (!Directory.Exists(configPath))
            {
                Directory.CreateDirectory(configPath);
            }

            var configString = JsonConvert.SerializeObject(remoteCredentials, Formatting.Indented);

            await File.WriteAllTextAsync(configFilePath, configString);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Restore the initial state of the remote registry service - by this we mean stop it if it was not
        /// running initially when we began the audit
        /// </summary>
        /// <param name="remoteCredentials"></param>
        /// <param name="serviceWasRunning"></param>
        protected void RestoreRemoteRegistyStatus(RemoteCredentials remoteCredentials, bool serviceWasRunning)
        {
            // Sanity check - if the service was initially running then leave it that way
            if (serviceWasRunning)
            {
                return;
            }

            try
            {
                ServiceController sc = new ServiceController(REMOTE_REGISTRY_SERVICE, remoteCredentials.RemoteHost);
                sc.Stop();
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 7
0
 public DavClient(RemoteCredentials credentials)
 {
     _credentials = credentials;
 }
Exemplo n.º 8
0
        public void Setup()
        {
            _credentials = new DavCredentials("username", "password");

            _uri = new Uri("http://masstransit.googlecode.com/svn/");
        }
Exemplo n.º 9
0
 public DavRemoteDirectory(Uri location, RemoteCredentials credentials)
     : base(location, credentials)
 {
 }
Exemplo n.º 10
0
 public static Uri For(this Uri location, RemoteCredentials credentials)
 {
     return location;
 }
Exemplo n.º 11
0
 protected DavRemoteResource(Uri location, RemoteCredentials credentials)
 {
     Location = location;
     Credentials = credentials;
 }
Exemplo n.º 12
0
        /// <summary>
        /// This is the main detection function called to recover the OS
        /// </summary>
        /// <param name="remoteCredentials"></param>
        /// <returns></returns>
        public int Detect(RemoteCredentials remoteCredentials)
        {
            Layton.Common.Controls.Impersonator impersonator = null;
            String remoteHost = remoteCredentials.RemoteHost;

            try
            {
                // We may want to impersonate a different user so that we can audit remote computers - if so
                // start the impersonation here
                if (remoteCredentials.Username != null && remoteCredentials.Username != "")
                {
                    impersonator = new Impersonator(remoteCredentials.Username, remoteCredentials.Domain, remoteCredentials.Password);
                }

                // Pickup and format the remote host name for WMI
                if (remoteCredentials.IsLocalComputer())
                {
                    remoteHost = @"\\localhost";
                }
                else
                {
                    remoteHost = @"\\" + remoteCredentials.RemoteHost;
                }

                //Connection credentials to the remote computer - not needed if the logged in account has access
                ConnectionOptions oConn = null;

                // Construct the path to the WMI node we are interested in
                String          path = remoteHost + @"\root\cimv2";
                ManagementScope scope;
                if (oConn == null)
                {
                    scope = new ManagementScope(path);
                }
                else
                {
                    scope = new ManagementScope(path, oConn);
                }

                // ...and connect
                scope.Connect();

                // Query the Operating System
                ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_OperatingSystem");
                ManagementObjectSearcher   searcher        = new ManagementObjectSearcher(scope, query);
                ManagementObjectCollection queryCollection = searcher.Get();
                foreach (ManagementObject managementObject in queryCollection)
                {
                    _name             = managementObject["Caption"].ToString();
                    _name             = RationalizeOS(_name);
                    _serial           = new ApplicationSerial();
                    _serial.ProductId = managementObject["SerialNumber"].ToString();
                    managementObject.Dispose();
                    break;
                }

                // The above WMI call works as far as it goes however it cannot recover the CD Key
                // for this we will need to use registry access - we may as well use WMI for this as
                // well as if the above fails we stuck anyway
                DetectOSCdKey(remoteHost);
            }
            catch (Exception)
            {
                return(-1);
            }

            finally
            {
                if (impersonator != null)
                {
                    impersonator.Dispose();
                }
            }

            return(0);
        }
Exemplo n.º 13
0
        private async Task <SubmitJobResponse> SubmitBakeJob(AWSCredentials credentials, RemoteCredentials config, string jobName)
        {
            var batchClient = new AmazonBatchClient(credentials);

            var response = await batchClient.SubmitJobAsync(new SubmitJobRequest
            {
                JobDefinition = config.BakeJobDefinitionId,
                JobName       = jobName,
                JobQueue      = config.BakeJobQueueId,

                Parameters = new Dictionary <string, string>
                {
                    { "job", jobName }
                },

                ContainerOverrides = new ContainerOverrides()
                {/*
                  * ResourceRequirements = new List<ResourceRequirement> {
                  *     new ResourceRequirement()
                  *     {
                  *         Type = ResourceType.VCPU,
                  *         Value = "36"
                  *     },
                  *     new ResourceRequirement()
                  *     {
                  *         Type = ResourceType.MEMORY,
                  *         Value = "70000"
                  *     }
                  * },*/
                    Vcpus  = 36,
                    Memory = 70000
                }
            });



            return(response);
        }
Exemplo n.º 14
0
        private async Task <SubmitJobResponse> SubmitRenderingJob(AWSCredentials credentials, RemoteCredentials config, string jobName, string bakeJobId)
        {
            var batchClient = new AmazonBatchClient(credentials);
            var request     = new SubmitJobRequest
            {
                JobDefinition = config.RenderJobDefinitionId,
                JobName       = jobName,
                JobQueue      = config.RenderJobQueueId,
                Parameters    = new Dictionary <string, string>
                {
                    { "job", jobName }
                },
                DependsOn = new List <JobDependency>()
            };

            if (!string.IsNullOrEmpty(bakeJobId))
            {
                request.DependsOn.Add(new JobDependency {
                    JobId = bakeJobId,
                    Type  = ArrayJobDependency.N_TO_N
                });
            }

            var response = await batchClient.SubmitJobAsync(request);

            return(response);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Main Detection function.  The main cause of an error here is the inability to connect to the remote
        /// systems registry.  This will most often be down to either the remote registry service not running
        /// or the user having insufficient privilege to access the remote registry
        /// </summary>
        /// <param name="remoteCredentials"></param>
        /// <param name="onlyMicrosoft"></param>
        /// <returns></returns>
        public int Detect(RemoteCredentials remoteCredentials, ref String errorText)
        {
            Layton.Common.Controls.Impersonator impersonator = null;
            String remoteHost            = remoteCredentials.RemoteHost;
            int    status                = 0;
            bool   existingServiceStatus = false;

            try
            {
                // We may want to impersonate a different user so that we can audit remote computers - if so
                // start the impersonation here
                if (remoteCredentials.Username != null && remoteCredentials.Username != "")
                {
                    impersonator = new Impersonator(remoteCredentials.Username, remoteCredentials.Domain, remoteCredentials.Password);
                }

                // Ensure that the remote registry service is running on the remote Asset and that we can
                // connect.  If the service is not active we may start it
                status = ValidateRemoteRegistryService(remoteCredentials, out existingServiceStatus);
                if (status != 0)
                {
                    errorText = "The Remote Registry Service was not active and could not be started";
                    return(status);
                }

                // Now begin the audit
                this.ReadPublisherMappings();
                this._applicationSerials.Detect(remoteHost);
                RegistryKey    rootCUKey;
                RegistryAccess registryAccess = new RegistryAccess();
                RegistryKey    rootLMKey      = null;

                // Attempt to connect to the remote registry and open the HKEY_LOCAL_MACHINE key
                status = registryAccess.OpenRegistry(Registry.LocalMachine, remoteHost, out rootLMKey);
                if (status != 0)
                {
                    errorText = registryAccess.LastErrorText;
                    return(status);
                }

                // Attempt to connect to the remote registry and open the HKEY_CURRENT_USER key
                status = registryAccess.OpenRegistry(Registry.CurrentUser, remoteHost, out rootCUKey);
                if (status != 0)
                {
                    errorText = registryAccess.LastErrorText;
                    return(status);
                }

                // Open the Softare uninstall key under HKLM and scan it
                RegistryKey uninstallKey = rootLMKey.OpenSubKey(UNINSTALLKEY);
                if (uninstallKey != null)
                {
                    this.ScanUninstallKey(uninstallKey);
                    uninstallKey.Close();
                }

                // Open the software uninstall key under HKCU and scan it
                uninstallKey = rootCUKey.OpenSubKey(UNINSTALLKEY);
                if (uninstallKey != null)
                {
                    this.ScanUninstallKey(uninstallKey);
                    uninstallKey.Close();
                }

                // Scan the Windows installer key
                this.ScanWindowsInstaller(rootLMKey);

                // close all open keys
                rootLMKey.Close();
                rootCUKey.Close();
            }
            catch (Exception ex)
            {
                errorText = "An exception occurred while trying to connect to the system registry on Asset [" + remoteHost + "] - The error was [" + ex.Message + "]";
                return(-1);
            }

            finally
            {
                // Ensure that we restore the initial status of the remote registry service on the target computer
                RestoreRemoteRegistyStatus(remoteCredentials, existingServiceStatus);

                // Displose of any impersonator object if created
                if (impersonator != null)
                {
                    impersonator.Dispose();
                }
            }

            // Iterate through the applications detected by the above and attempt to recover any serial number
            foreach (ApplicationInstance thisApplication in this)
            {
                ApplicationSerial thisSerial = null;
                if (thisApplication.Guid != "")
                {
                    thisSerial = this._applicationSerials.ContainsApplication(thisApplication.Guid);
                }

                if ((thisSerial == null) && (thisApplication.Name != ""))
                {
                    thisSerial = this._applicationSerials.ContainsApplication(thisApplication.Name);
                }

                if (thisSerial != null)
                {
                    thisApplication.Serial = thisSerial;
                    thisSerial.Matched     = true;
                }
            }

            errorText = "";
            return(0);
        }