static bool OpenCert() { Int64 HResult; if (OpenCert(SystemInfos.SysInfo.UCID.ToUpper(), out HResult) == false) { if (HResult == 0x80070056) //Wrong Password { if (string.IsNullOrWhiteSpace(RegistryData.UCIDOverride) == true) { if (OpenCert(UCID.GetUCIDLegacy().ToUpper(), out HResult) == false) { return(false); } else { FoxEventLog.WriteEventLog("Using LEGACY UCID to load agent certificate.", System.Diagnostics.EventLogEntryType.Warning); } } else { return(false); } } else { return(false); } } return(true); }
public static void LoadLic() { //Modified for GitHub NumComputers = 1000; AllowContract = true; Data = new LicensingData(); Data.Features = ""; Data.LicenseID = Guid.NewGuid().ToString(); Data.LicenseType = "GitHub Version"; Data.Owner = "Fox"; Data.OwnerCustomID = ""; Data.SupportValidTo = null; Data.UCID = UCID.GetUCID(); Data.ValidTo = null; Data.ValidFrom = DateTime.UtcNow.Date; Data.Vacant1 = "1000"; ValidLicense = true; }
public bool GetCertificate() { Cert = null; string ProgramData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); if (ProgramData.EndsWith("\\") == false) { ProgramData += "\\"; } ProgramData += "Fox\\SDC Agent\\"; string myUCID = UCID.GetUCID(); string CertFile = ProgramData + "cert.pfx"; if (File.Exists(CertFile) == false) { return(false); } Cert = new X509Certificate2(CertFile, myUCID.ToUpper()); if (Cert == null) { return(false); } string TestCN = "CN=Fox SDC Certificate for " + SystemInformation.ComputerName; if (Cert.Subject != TestCN) { Cert = null; return(false); } return(true); }
public static void SMain() { string ErrorReason; Console.WriteLine("Server version: " + Assembly.GetExecutingAssembly().GetName().Version.ToString() + (InstanceID == "" ? "" : " (" + InstanceID + ")")); FoxEventLog.WriteEventLog("Server version: " + Assembly.GetExecutingAssembly().GetName().Version.ToString() + " starting" + (InstanceID == "" ? "" : " (" + InstanceID + ")"), EventLogEntryType.Information); if (SQLTest.TestSettings(out ErrorReason) == false) { FoxEventLog.WriteEventLog("Settings are faulty: " + ErrorReason, EventLogEntryType.Error); Console.WriteLine("Settings are faulty: " + ErrorReason); #if !DEBUG Process.GetCurrentProcess().Kill(); #endif return; } if (SQLTest.TestServer(out ErrorReason) == false) { FoxEventLog.WriteEventLog("Cannot connect to the server: " + ErrorReason, EventLogEntryType.Error); Console.WriteLine("Cannot connect to the server: " + ErrorReason); #if !DEBUG Process.GetCurrentProcess().Kill(); #endif return; } RESTful.RegisterRESTfulClasses(); FS_Watcher.InstallFSW(); if (Utilities.TestSign(out ErrorReason) == false) { FoxEventLog.WriteEventLog("Cannot test-sign with the certificate " + SettingsManager.Settings.UseCertificate + ": " + ErrorReason, EventLogEntryType.Warning); } #if DEBUG if (Fox_LicenseGenerator.SDCLicensing.ValidLicense == false) { FoxEventLog.WriteEventLog("Writing a crap-license into memory.", EventLogEntryType.Information); Fox_LicenseGenerator.SDCLicensing.NumComputers = 1000; Fox_LicenseGenerator.SDCLicensing.AllowContract = true; Fox_LicenseGenerator.SDCLicensing.Data = new Fox_LicenseGenerator.LicensingData(); Fox_LicenseGenerator.SDCLicensing.Data.Features = ""; Fox_LicenseGenerator.SDCLicensing.Data.LicenseID = Guid.NewGuid().ToString(); Fox_LicenseGenerator.SDCLicensing.Data.LicenseType = "Memory"; Fox_LicenseGenerator.SDCLicensing.Data.Owner = "Fox"; Fox_LicenseGenerator.SDCLicensing.Data.OwnerCustomID = ""; Fox_LicenseGenerator.SDCLicensing.Data.SupportValidTo = null; Fox_LicenseGenerator.SDCLicensing.Data.UCID = UCID.GetUCID(); Fox_LicenseGenerator.SDCLicensing.Data.ValidTo = null; Fox_LicenseGenerator.SDCLicensing.Data.ValidFrom = DateTime.UtcNow.Date; Fox_LicenseGenerator.SDCLicensing.Data.Vacant1 = "1000"; Fox_LicenseGenerator.SDCLicensing.ValidLicense = true; } #endif try { Console.CancelKeyPress += Console_CancelKeyPress; WebServerHandler.RunWebServer(); MaintenanceTasks.StartMaintenanceTreads(); ReportingThread.StartReportingThreads(); RemoteNetworkConnectionWSCrosser.InitialInitWS(); Console.WriteLine("=============== Server started ==============="); Debug.WriteLine("=============== Server started ==============="); Console.WriteLine(Settings.Default.ListenOn); Debug.WriteLine(Settings.Default.ListenOn); Console.WriteLine(Settings.Default.WSListenOn); Debug.WriteLine(Settings.Default.WSListenOn); FoxEventLog.WriteEventLog("Server started", EventLogEntryType.Information); ServiceRunning = true; Thread tmm = new Thread(new ThreadStart(TimeoutManager)); tmm.Start(); do { Thread.Sleep(1000); } while (ServiceRunning == true); } catch (Exception ee) { FoxEventLog.WriteEventLog("Cannot start server " + ee.Message, EventLogEntryType.Error); Console.WriteLine("Cannot start server " + ee.Message); #if !DEBUG Process.GetCurrentProcess().Kill(); #endif return; } }
public static int CollectSystemInfo() { if (IsRunningOnMono() == true) { FoxEventLog.WriteEventLog("Running on Mono is not supported!", EventLogEntryType.Error); Console.WriteLine("Running on Mono is not supported!"); return(1); } if (GetWineVersion() != "") { FoxEventLog.WriteEventLog("Running on Wine/CrossOver is not supported!", EventLogEntryType.Error); Console.WriteLine("Running on Wine/CrossOver is not supported!"); return(1); } SysInfo = new BaseSystemInfo(); SysInfo.RunningInWindowsPE = WindowsPE.IsRunningInWindowsPE; SysInfo.ComputerModel = GetComputerModel(); SysInfo.ComputerName = SystemInformation.ComputerName; SysInfo.CPU = GetCPU().ToString(); SysInfo.MachineID = RegistryData.MachineID; SysInfo.IsTSE = IsSystemTSE(); SysInfo.OSName = SysInfo.RunningInWindowsPE == true ? "Windows PE / MiniNT" : GetWindowsProduct(); SysInfo.OSSuite = GetOSSuite().ToString(); SysInfo.OSVerBuild = Environment.OSVersion.Version.Build; SysInfo.OSVerMaj = Environment.OSVersion.Version.Major; SysInfo.OSVerMin = Environment.OSVersion.Version.Minor; SysInfo.Language = CultureInfo.InstalledUICulture.Name; SysInfo.DisplayLanguage = CultureInfo.InstalledUICulture.EnglishName; SysInfo.RunningInHypervisor = ProgramAgent.CPP.IsInHypervisor(); SysInfo.BIOS = GetBIOSData(); SysInfo.BIOSType = ProgramAgent.CPP.FoxGetFirmwareType(); GetProcessorInfos(out SysInfo.NumberOfProcessors, out SysInfo.NumberOfLogicalProcessors, out SysInfo.TotalPhysicalMemory); SysInfo.CPUName = GetProcessorName(); SysInfo.SecureBootState = GetSecureBootState(); SysInfo.SystemRoot = Environment.GetFolderPath(Environment.SpecialFolder.Windows); SysInfo.SUSID = GetSUSID(); try { SysInfo.IsMeteredConnection = MeteredConnection.IsMeteredConnection(); } catch (Exception ee) { Debug.WriteLine(ee.ToString()); SysInfo.IsMeteredConnection = null; } OSVERSIONINFOEX os = new OSVERSIONINFOEX(); os.dwOSVersionInfoSize = Marshal.SizeOf(os); GetVersionEx(ref os); SysInfo.OSVerType = os.wSuiteMask; #if DEBUG SysInfo.AgentVersion = VulpesBranding.AgentIdentifier + " [DEBUG] " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); #else SysInfo.AgentVersion = VulpesBranding.AgentIdentifier + " " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); #endif SysInfo.AgentVersionID = FoxVersion.Version; CPUType CPU = GetCPU(); if (CPU != CPUType.Intel32 && CPU != CPUType.EM64T && CPU != CPUType.ARM64) { FoxEventLog.WriteEventLog("Only i386, AMD64 (EM64T) or ARM64 CPU are supported!", EventLogEntryType.Error); return(1); } if (CPU == CPUType.EM64T) { if (Is64Bit() == null) { FoxEventLog.WriteEventLog("Cannot determine WOW state.", EventLogEntryType.Error); return(1); } if (Is64Bit() == false && CPU == CPUType.EM64T) { FoxEventLog.WriteEventLog("If you've a 64 bit CPU, then run this process as 64 bit!!!!", EventLogEntryType.Error); return(1); } SysInfo.Is64Bit = Is64Bit().Value; } else { SysInfo.Is64Bit = false; } if (SysInfo.MachineID == "") { FoxEventLog.WriteEventLog("Cannot get machine ID.", EventLogEntryType.Error); return(1); } if (SysInfo.ComputerModel == null) { FoxEventLog.WriteEventLog("Cannot get Computer Model.", EventLogEntryType.Error); return(1); } PasswordID = RegistryData.MachinePassword; if (PasswordID == "") { FoxEventLog.WriteEventLog("Cannot get PassID.", EventLogEntryType.Error); return(1); } if (SysInfo.OSSuite == "Unknown") { FoxEventLog.WriteEventLog("Unknown OS Suite.", EventLogEntryType.Error); return(1); } if (RegistryData.UseOnPrem == true) { ServerURL = RegistryData.ServerURL; } else { ServerURL = ProgramAgent.VulpesURL; } if (ServerURL == "") { FoxEventLog.WriteEventLog("Cannot get Server URL.", EventLogEntryType.Error); return(1); } ProgramData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); if (ProgramData.EndsWith("\\") == false) { ProgramData += "\\"; } ProgramData += "Fox\\SDC Agent\\"; try { if (Directory.Exists(ProgramData) == false) { Directory.CreateDirectory(ProgramData); } } catch { FoxEventLog.WriteEventLog("Error accessing " + ProgramData, EventLogEntryType.Error); return(1); } SysInfo.UCID = UCID.GetUCID(); SysInfo.LegacyUCID = UCID.GetUCIDLegacy(); if (RegistryData.UCIDOverride != "") { string UUU = RegistryData.UCIDOverride.Trim().ToUpper(); if (UUU.Length == 32) { FoxEventLog.WriteEventLog("UCID Overriden from " + SysInfo.UCID + " to " + UUU, EventLogEntryType.Warning); SysInfo.UCID = UUU; } } string SysInfoResumee = ""; ContractID = RegistryData.ContractID.Trim(); ContractPassword = RegistryData.ContractPassword; SysInfoResumee += "System Info:\r\n"; SysInfoResumee += "Agent: " + SysInfo.AgentVersion + "\r\n"; SysInfoResumee += SysInfo.OSName + "\r\n"; SysInfoResumee += "aka Windows NT " + SysInfo.OSVerMaj.ToString() + "." + SysInfo.OSVerMin.ToString() + "." + SysInfo.OSVerBuild.ToString() + "\r\n"; SysInfoResumee += "Suite: " + SysInfo.OSSuite + "\r\n"; SysInfoResumee += "Language: " + SysInfo.Language + " (" + SysInfo.DisplayLanguage + ")\r\n"; SysInfoResumee += "Bits: " + (SysInfo.Is64Bit == true ? "64 bit" : "32 bit") + "\r\n"; SysInfoResumee += "TSE: " + (SysInfo.IsTSE == false ? "no" : "yes") + "\r\n"; SysInfoResumee += "OS Suite: " + SysInfo.OSVerType + "\r\n"; SysInfoResumee += "CPU: " + CPU.ToString() + "\r\n"; SysInfoResumee += "Model: " + SysInfo.ComputerModel + "\r\n"; SysInfoResumee += "BIOS: " + SysInfo.BIOS + "\r\n"; SysInfoResumee += "Computername: " + SysInfo.ComputerName + "\r\n"; SysInfoResumee += "Machine ID: " + SysInfo.MachineID + "\r\n"; SysInfoResumee += "Server URL: " + ServerURL + "\r\n"; SysInfoResumee += "UCID: " + SysInfo.UCID + "\r\n"; SysInfoResumee += "Program Data: " + ProgramData + "\r\n"; SysInfoResumee += "Running in Hypervisor: " + (SysInfo.RunningInHypervisor == false ? "no" : "yes") + "\r\n"; FoxEventLog.WriteEventLog("Fox SDC Agent starting: " + SysInfoResumee, EventLogEntryType.Information); return(0); }
private void MainDLG_Load(object sender, EventArgs e) { txtUCID.Text = UCID.GetUCID(); }