Пример #1
0
 public void ResponseMessage(long ID, MessageResponse Response)
 {
     if (SyncPolicy.RequestCertPolicyMessageID == ID)
     {
         if (Response == MessageResponse.Button2) //Nö
         {
             Status.UpdateMessage2();
             return;
         }
         if (Response == MessageResponse.Button3) //?!?
         {
             return;
         }
         if (Response == MessageResponse.Button1) //Yes
         {
             FilesystemData.InstallCertificate(SyncPolicy.RequestCertPolicyCERData);
             InvokeMessage(MessageInvoke.ReloadPolicies);
         }
     }
 }
Пример #2
0
        public void SetOptionalSoftware(string PackageID)
        {
            if (PackageID == null)
            {
                return;
            }
            PackageIDData FoundPackage = null;

            foreach (PackageIDData pkg in FilesystemData.AvailableUserPackages)
            {
                if (PackageID.ToLower() == pkg.PackageID.ToLower())
                {
                    FoundPackage = pkg;
                    break;
                }
            }

            if (FoundPackage == null)
            {
                return;
            }

            bool Found = false;

            foreach (PackageIDData pkg in FilesystemData.UserPackagesToInstall)
            {
                if (pkg.PackageID.ToLower() == FoundPackage.PackageID.ToLower())
                {
                    Found = true;
                    break;
                }
            }

            if (Found == true)
            {
                return;
            }

            FilesystemData.UserPackagesToInstall.Add(FoundPackage);
            FilesystemData.WriteUserPackageList();
        }
Пример #3
0
        static void DownloadThreadRunner()
        {
            try
            {
                int Direction = -1;
                lock (FileLock)
                {
                    if (FilesystemData.FileTransferStatus.ServerID == null)
                    {
                        return;
                    }
                    Direction = FilesystemData.FileTransferStatus.Direction;
                }

                #region Client to Server

                if (Direction == 1)
                {
                    string   LocalFilename = "";
                    string   MD5;
                    Int64    ServerID = 0;
                    Int64    CurrentSZ;
                    Int64    TotalSZ;
                    bool     OverrideMetered;
                    bool     ReqOnly;
                    DateTime LastModified;
                    try
                    {
                        lock (FileLock)
                        {
                            LocalFilename   = FilesystemData.FileTransferStatus.RemoteFileLocation;
                            ServerID        = FilesystemData.FileTransferStatus.ServerID.Value;
                            CurrentSZ       = FilesystemData.FileTransferStatus.ProgressSize;
                            TotalSZ         = FilesystemData.FileTransferStatus.Size;
                            MD5             = FilesystemData.FileTransferStatus.MD5CheckSum;
                            OverrideMetered = FilesystemData.FileTransferStatus.OverrideMeteredConnection;
                            ReqOnly         = FilesystemData.FileTransferStatus.RequestOnly;
                            LastModified    = FilesystemData.FileTransferStatus.LastModfied;
                        }

                        //won't start when in metered connection!
                        if (OverrideMetered == false)
                        {
                            try
                            {
                                if (MeteredConnection.IsMeteredConnection() == true)
                                {
                                    FoxEventLog.VerboseWriteEventLog("Upload paused = metered connection detected", System.Diagnostics.EventLogEntryType.Information);
                                    return;
                                }
                            }
                            catch
                            {
                            }
                        }

                        Int64 ReallyCurrentSZ = 0;

                        try
                        {
                            if (File.Exists(LocalFilename) == true)
                            {
                                FileInfo fi = new FileInfo(LocalFilename);
                                ReallyCurrentSZ = fi.Length;
                            }
                            else
                            {
                                FoxEventLog.WriteEventLog("File " + LocalFilename + " does not exist for upload.", System.Diagnostics.EventLogEntryType.Error);
                                return;
                            }
                        }
                        catch (Exception ee)
                        {
                            FoxEventLog.WriteEventLog("Checking upload file " + LocalFilename + " ID: " + ServerID.ToString() + " failed:\n" + ee.ToString(), System.Diagnostics.EventLogEntryType.Error);
                            return;
                        }

                        downloadnet = Utilities.ConnectNetwork(7);
                        if (downloadnet == null)
                        {
                            return;
                        }

                        if (ReqOnly == true)
                        {
                            Status.UpdateMessage(7, "Checking " + LocalFilename);
                            MD5 = MD5Utilities.CalcMD5File(LocalFilename);
                            FileInfo fi = new FileInfo(LocalFilename);
                            lock (FileLock)
                            {
                                FilesystemData.FileTransferStatus.MD5CheckSum = MD5;
                                FilesystemData.FileTransferStatus.LastModfied = fi.LastWriteTimeUtc;
                                FilesystemData.WriteFileTransferStatus();
                            }

                            Int64?NewID = downloadnet.File_Agent_NewUploadReq(LocalFilename, OverrideMetered, MD5);
                            if (NewID == null)
                            {
                                FoxEventLog.VerboseWriteEventLog("Cannot create a new upload req for " + LocalFilename, System.Diagnostics.EventLogEntryType.Warning);
                                return;
                            }

                            if (downloadnet.File_Agent_CancelUpload(ServerID) == false)
                            {
                                FoxEventLog.VerboseWriteEventLog("Cannot delete temp upload req for " + LocalFilename + " ID: " + ServerID.ToString(), System.Diagnostics.EventLogEntryType.Warning);
                                return;
                            }

                            lock (FileLock)
                            {
                                //wait for the new upload req
                                ClearDataFSD();
                                FilesystemData.WriteFileTransferStatus();
                                UnlockTimer = true;
                                return;
                            }
                        }
                        else
                        {
                            FileStream fs = null;
                            do
                            {
                                try
                                {
                                    if (CancelAndDeleteDL == true)
                                    {
                                        return;
                                    }

                                    FileInfo fi = new FileInfo(LocalFilename);
                                    if (roughDT(fi.LastWriteTimeUtc, LastModified) == false || fi.Length != TotalSZ)
                                    {
                                        if (downloadnet.File_Agent_CancelUpload(ServerID) == false)
                                        {
                                            FoxEventLog.VerboseWriteEventLog("Cannot cancel upload req for " + LocalFilename + " ID: " + ServerID.ToString() + ", due file changes", System.Diagnostics.EventLogEntryType.Warning);
                                            lock (FileLock)
                                            {
                                                ClearDataFSD();
                                                FilesystemData.WriteFileTransferStatus();
                                            }
                                            return;
                                        }
                                        else
                                        {
                                            FoxEventLog.VerboseWriteEventLog("Cannot upload req for " + LocalFilename + " ID: " + ServerID.ToString() + ": File has been changed!", System.Diagnostics.EventLogEntryType.Warning);
                                        }
                                        return;
                                    }

                                    try
                                    {
                                        if (fs == null)
                                        {
                                            fs = File.Open(LocalFilename, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
                                        }
                                    }
                                    catch (Exception ee)
                                    {
                                        FoxEventLog.WriteEventLog("Cannot upload file " + LocalFilename + " ID: " + ServerID.ToString() + " failed:\n" + ee.ToString(), System.Diagnostics.EventLogEntryType.Warning);
                                        return;
                                    }

                                    try
                                    {
                                        fs.Seek(CurrentSZ, SeekOrigin.Begin);
                                    }
                                    catch
                                    {
                                        FoxEventLog.WriteEventLog("Cannot properly seek in file " + LocalFilename + " ID: " + ServerID.ToString() + " Pos: 0x" + CurrentSZ.ToString("X"), System.Diagnostics.EventLogEntryType.Warning);
                                        return;
                                    }

                                    byte[] data = null;

                                    try
                                    {
                                        int read = 1024 * 1024;
                                        data = new byte[read];
                                        read = fs.Read(data, 0, read);
                                        if (data.Length != read)
                                        {
                                            byte[] ddd = new byte[read];
                                            Array.Copy(data, ddd, read);
                                            data = ddd;
                                        }
                                    }
                                    catch
                                    {
                                        FoxEventLog.WriteEventLog("Cannot read file " + LocalFilename + " ID: " + ServerID.ToString() + " Pos: 0x" + CurrentSZ.ToString("X"), System.Diagnostics.EventLogEntryType.Warning);
                                        return;
                                    }

                                    Status.UpdateMessage(7, "Uploading " + LocalFilename + "\r\n" + CommonUtilities.NiceSize(CurrentSZ) + " of " + CommonUtilities.NiceSize(TotalSZ));
                                    bool res = downloadnet.File_Agent_AppendUpload(ServerID, data);
                                    if (res == false)
                                    {
                                        FoxEventLog.VerboseWriteEventLog("Cannot upload append req for " + LocalFilename + " ID: " + ServerID.ToString(), System.Diagnostics.EventLogEntryType.Warning);
                                        return;
                                    }

                                    CurrentSZ += data.Length;
                                    lock (FileLock)
                                    {
                                        FilesystemData.FileTransferStatus.ProgressSize = CurrentSZ;
                                        FilesystemData.WriteFileTransferStatus();
                                    }

                                    if (CurrentSZ == TotalSZ)
                                    {
                                        FoxEventLog.WriteEventLog("Upload file success " + LocalFilename + " ID: " + ServerID.ToString(), System.Diagnostics.EventLogEntryType.Information);
                                        lock (FileLock)
                                        {
                                            ClearDataFSD();
                                            FilesystemData.WriteFileTransferStatus();
                                        }
                                        UnlockTimer = true;
                                        return;
                                    }
                                }
                                finally
                                {
                                    if (fs != null)
                                    {
                                        fs.Close();
                                        fs = null;
                                    }
                                }
                            } while (true);
                        }
                    }
                    catch (Exception ee)
                    {
                        FoxEventLog.WriteEventLog("Downloading file " + LocalFilename + " ID: " + ServerID.ToString() + " crashed:\n" + ee.ToString(), System.Diagnostics.EventLogEntryType.Error);
                    }
                    finally
                    {
                        Status.UpdateMessage(7);
                    }
                }

                #endregion
                #region Server to Client

                if (Direction == 0)
                {
                    string LocalFilename;
                    string MD5;
                    Int64  ServerID;
                    Int64  CurrentSZ;
                    Int64  TotalSZ;
                    bool   OverrideMetered;
                    lock (FileLock)
                    {
                        LocalFilename   = FilesystemData.FileTransferStatus.RemoteFileLocation;
                        ServerID        = FilesystemData.FileTransferStatus.ServerID.Value;
                        CurrentSZ       = FilesystemData.FileTransferStatus.ProgressSize;
                        TotalSZ         = FilesystemData.FileTransferStatus.Size;
                        MD5             = FilesystemData.FileTransferStatus.MD5CheckSum;
                        OverrideMetered = FilesystemData.FileTransferStatus.OverrideMeteredConnection;
                    }

                    //won't start when in metered connection!
                    if (OverrideMetered == false)
                    {
                        try
                        {
                            if (MeteredConnection.IsMeteredConnection() == true)
                            {
                                FoxEventLog.VerboseWriteEventLog("Download paused = metered connection detected", System.Diagnostics.EventLogEntryType.Information);
                                return;
                            }
                        }
                        catch
                        {
                        }
                    }

                    Int64 ReallyCurrentSZ = 0;

                    try
                    {
                        string Dir = Path.GetDirectoryName(LocalFilename);
                        if (Directory.Exists(Dir) == false)
                        {
                            Directory.CreateDirectory(Dir);
                        }
                        if (File.Exists(LocalFilename) == true)
                        {
                            FileInfo fi = new FileInfo(LocalFilename);
                            ReallyCurrentSZ = fi.Length;
                        }
                        else
                        {
                            ReallyCurrentSZ = 0;
                        }
                    }
                    catch (Exception ee)
                    {
                        FoxEventLog.WriteEventLog("Checking download file " + LocalFilename + " ID: " + ServerID.ToString() + " failed:\n" + ee.ToString(), System.Diagnostics.EventLogEntryType.Error);
                    }

                    if (ReallyCurrentSZ != CurrentSZ)
                    {
                        FoxEventLog.WriteEventLog("File Size does not match: deleting the file " + LocalFilename, System.Diagnostics.EventLogEntryType.Warning);
                        try
                        {
                            File.Delete(LocalFilename);
                        }
                        catch (Exception ee)
                        {
                            FoxEventLog.WriteEventLog("Cannot delete " + LocalFilename + "\n" + ee.ToString(), System.Diagnostics.EventLogEntryType.Error);
                        }
                        lock (FileLock)
                        {
                            ClearDataFSD();
                            FilesystemData.WriteFileTransferStatus();
                            return;
                        }
                    }

                    downloadnet = Utilities.ConnectNetwork(7);
                    if (downloadnet == null)
                    {
                        return;
                    }
                    try
                    {
                        downloadnet.DownloadNotify += Downloadnet_DownloadNotify;
                        if (downloadnet.DownloadFile("api/agent/filefiledownload/" + ServerID.ToString(), LocalFilename, TotalSZ) == false)
                        {
                            FileInfo fi = new FileInfo(LocalFilename);
                            lock (FileLock)
                            {
                                FilesystemData.FileTransferStatus.ProgressSize = fi.Length;
                                FilesystemData.WriteFileTransferStatus();
                            }
                        }
                        else
                        {
                            if (downloadnet.StopDownload == false)
                            {
                                Status.UpdateMessage(7, "Checking " + FilesystemData.FileTransferStatus.RemoteFileLocation + "...");
                                string CalcMD5 = MD5Utilities.CalcMD5File(LocalFilename);
                                if (MD5.ToLower() != CalcMD5.ToLower())
                                {
                                    FoxEventLog.WriteEventLog("File MD5 does not match: deleting the file " + LocalFilename, System.Diagnostics.EventLogEntryType.Warning);
                                    try
                                    {
                                        File.Delete(LocalFilename);
                                    }
                                    catch (Exception ee)
                                    {
                                        FoxEventLog.WriteEventLog("Cannot delete " + LocalFilename + "\n" + ee.ToString(), System.Diagnostics.EventLogEntryType.Error);
                                    }
                                    lock (FileLock)
                                    {
                                        ClearDataFSD();
                                        FilesystemData.WriteFileTransferStatus();
                                        return;
                                    }
                                }
                                else
                                {
                                    //success!
                                    FoxEventLog.WriteEventLog("File download success: " + LocalFilename, System.Diagnostics.EventLogEntryType.Information);
                                    downloadnet.File_Agent_CancelUpload(ServerID);
                                    lock (FileLock)
                                    {
                                        ClearDataFSD();
                                        FilesystemData.WriteFileTransferStatus();
                                    }
                                    UnlockTimer = true;
                                    return;
                                }
                            }
                            else
                            {
                                if (CancelAndDeleteDL == true)
                                {
                                    FoxEventLog.VerboseWriteEventLog("File " + LocalFilename + " canceled by server req.", System.Diagnostics.EventLogEntryType.Information);
                                    try
                                    {
                                        File.Delete(LocalFilename);
                                    }
                                    catch (Exception ee)
                                    {
                                        FoxEventLog.WriteEventLog("Cannot delete " + LocalFilename + "\n" + ee.ToString(), System.Diagnostics.EventLogEntryType.Error);
                                    }
                                    lock (FileLock)
                                    {
                                        ClearDataFSD();
                                        FilesystemData.WriteFileTransferStatus();
                                        return;
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ee)
                    {
                        FoxEventLog.WriteEventLog("Downloading file " + LocalFilename + " ID: " + ServerID.ToString() + " crashed:\n" + ee.ToString(), System.Diagnostics.EventLogEntryType.Error);
                    }
                    finally
                    {
                        downloadnet.DownloadNotify -= Downloadnet_DownloadNotify;
                        Status.UpdateMessage(7);
                    }
                }

                #endregion
            }
            finally
            {
                try
                {
                    if (downloadnet != null)
                    {
                        downloadnet.CloseConnection();
                    }
                }
                catch
                {
                }
                downloadnet = null;
            }
        }
Пример #4
0
        static void ThreadRunner()
        {
            lock (FileLock)
            {
                FilesystemData.LoadFileTransferStatus();
            }

            while (StopService == false)
            {
                try
                {
                    Network net = Utilities.ConnectNetwork(7);
                    if (net == null)
                    {
                        Wait(60);
                        continue;
                    }

                    NetInt64ListSigned lst = net.File_Agent_GetFileList();
                    if (lst == null)
                    {
                        net.CloseConnection();
                        Wait(2 * 60);
                        continue;
                    }

                    if (ApplicationCertificate.Verify(lst) == false)
                    {
                        FoxEventLog.WriteEventLog("One or more DownloadFS Lists are tampered - no download / uploads will be processed.", System.Diagnostics.EventLogEntryType.Error);
                        net.CloseConnection();
                        Wait(2 * 60);
                        continue;
                    }

                    if (lst.data.data.Count == 0)
                    {
                        net.CloseConnection();
                        Wait(2 * 60);
                        continue;
                    }

                    Int64 RunningID = 0;
                    lock (FileLock)
                    {
                        if (FilesystemData.FileTransferStatus.ServerID != null)
                        {
                            bool Found = false;
                            foreach (Int64 l in lst.data.data)
                            {
                                if (l == FilesystemData.FileTransferStatus.ServerID.Value)
                                {
                                    Found     = true;
                                    RunningID = l;
                                    break;
                                }
                            }

                            if (Found == false)
                            {
                                RunningID = lst.data.data[0];
                            }
                        }
                        else
                        {
                            RunningID = lst.data.data[0];
                        }
                    }

                    Debug.Assert(RunningID != 0);
                    FileUploadDataSigned fud = net.File_Agent_GetFileAnyData(RunningID);
                    if (ApplicationCertificate.Verify(fud) == false)
                    {
                        FoxEventLog.WriteEventLog("One or more DownloadFS Elements are tampered - no download / uploads will be processed.", System.Diagnostics.EventLogEntryType.Error);
                        net.CloseConnection();
                        Wait(2 * 60);
                        continue;
                    }

                    net.CloseConnection();

                    string LocalFilename   = "";
                    bool   WaitandContinue = false;

                    lock (FileLock)
                    {
                        //may be needed for deleting the file (if canceled by the server)
                        LocalFilename = FilesystemData.FileTransferStatus.RemoteFileLocation;

                        if (FilesystemData.FileTransferStatus.ServerID != null)
                        {
                            if (RunningID != FilesystemData.FileTransferStatus.ServerID)
                            {
                                CancelAndDeleteDL = true;
                            }
                            else
                            {
                                if (FilesystemData.FileTransferStatus.Size != fud.Data.Size ||
                                    FilesystemData.FileTransferStatus.RemoteFileLocation != fud.Data.RemoteFileLocation ||
                                    FilesystemData.FileTransferStatus.MD5CheckSum.ToLower() != fud.Data.MD5CheckSum.ToLower() ||
                                    FilesystemData.FileTransferStatus.RequestOnly != fud.Data.RequestOnly)
                                {
                                    CancelAndDeleteDL = true;
                                }
                                else
                                {
                                    if (RunningDLThread == null)
                                    {
                                        RunningDLThread = new Thread(new ThreadStart(DownloadThreadRunner));
                                        RunningDLThread.Start();
                                    }
                                    else
                                    {
                                        if (RunningDLThread.IsAlive == false)
                                        {
                                            RunningDLThread = new Thread(new ThreadStart(DownloadThreadRunner));
                                            RunningDLThread.Start();
                                        }
                                    }
                                }

                                WaitandContinue = true;
                            }
                        }
                    }

                    if (WaitandContinue == true)
                    {
                        Wait(2 * 60);
                        continue;
                    }

                    if (CancelAndDeleteDL == true)
                    {
                        if (RunningDLThread != null)
                        {
                            RunningDLThread.Join();
                        }

                        if (string.IsNullOrWhiteSpace(LocalFilename) == false)
                        {
                            try
                            {
                                if (FilesystemData.FileTransferStatus.Direction == 0)
                                {
                                    if (File.Exists(LocalFilename) == true)
                                    {
                                        File.Delete(LocalFilename);
                                    }
                                }
                            }
                            catch (Exception ee)
                            {
                                FoxEventLog.WriteEventLog("Cannot check / delete " + LocalFilename + "\n" + ee.ToString(), System.Diagnostics.EventLogEntryType.Error);
                            }
                        }
                    }

                    CancelAndDeleteDL = false;

                    lock (FileLock)
                    {
                        FilesystemData.FileTransferStatus.Size = fud.Data.Size;
                        FilesystemData.FileTransferStatus.RemoteFileLocation        = fud.Data.RemoteFileLocation;
                        FilesystemData.FileTransferStatus.MD5CheckSum               = fud.Data.MD5CheckSum.ToLower();
                        FilesystemData.FileTransferStatus.OverrideMeteredConnection = fud.Data.OverrideMeteredConnection;
                        FilesystemData.FileTransferStatus.Direction    = fud.Data.Direction;
                        FilesystemData.FileTransferStatus.ProgressSize = 0;
                        FilesystemData.FileTransferStatus.ServerID     = RunningID;
                        FilesystemData.FileTransferStatus.RequestOnly  = fud.Data.RequestOnly;
                        FilesystemData.FileTransferStatus.LastModfied  = fud.Data.FileLastModified;
                        FilesystemData.WriteFileTransferStatus();
                    }

                    RunningDLThread = new Thread(new ThreadStart(DownloadThreadRunner));
                    RunningDLThread.Start();

                    Wait(2 * 60);
                    continue;
                }
                catch (Exception ee)
                {
                    FoxEventLog.WriteEventLog("Internal crash in DownloadFS System: " + ee.Message, System.Diagnostics.EventLogEntryType.Error);
                    Wait(10);
                }
                Wait(2 * 60);
            }
            ;
        }
Пример #5
0
        public static void SMain()
        {
#if !DEBUG
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
#endif
            FoxEventLog.RegisterEventLog();

            if (UsePipeAction == false && UseScreenAction == false && UseDNSAutoConfig == false && UseLoginRecovery == false) //Pipe Actions can also be run in user-space ...
            {
                if (IsSystemUser() != true)
                {
#if !DEBUG || DEBUGSERVICE
                    service.Stop();
#endif
                    return;
                }
            }

            if (LoadDLL() == false)
            {
#if !DEBUG || DEBUGSERVICE
                service.Stop();
#endif
                return;
            }

#if !DEBUG
            if (TestIntegrity(null) == false)
            {
                FoxEventLog.WriteEventLog("Integrity check failed!", EventLogEntryType.Error);
                service.Stop();
                return;
            }
#endif
            if (UseDNSAutoConfig == true)
            {
                try
                {
                    List <List <string> > Query = CPP.DNSQueryTXT("sdc-contract.my-vulpes-config.lu");

                    if (Query == null)
                    {
                        return;
                    }

                    string ContractID       = null;
                    string ContractPassword = null;
                    string UseOnPrem        = null;
                    string OnPremURL        = null;

                    foreach (List <string> Q in Query)
                    {
                        if (Q == null)
                        {
                            continue;
                        }

                        foreach (string QR in Q)
                        {
                            if (string.IsNullOrWhiteSpace(QR) == true)
                            {
                                continue;
                            }
                            if (QR.ToLower().StartsWith("contractid=") == true)
                            {
                                ContractID = QR.Substring(11).Trim();
                            }
                            if (QR.ToLower().StartsWith("contractpassword="******"useonprem=") == true)
                            {
                                UseOnPrem = QR.Substring(10).Trim();
                            }
                            if (QR.ToLower().StartsWith("onpremurl=") == true)
                            {
                                OnPremURL = QR.Substring(10).Trim();
                            }
                        }
                    }

                    using (RegistryKey k = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Fox\\SDC"))
                    {
                        if (string.IsNullOrWhiteSpace(ContractID) == false && string.IsNullOrWhiteSpace(ContractPassword) == false)
                        {
                            k.SetValue("ContractID", ContractID, RegistryValueKind.String);
                            k.SetValue("ContractPassword", ContractPassword, RegistryValueKind.String);
                        }

                        int UseOnPremInt;
                        if (int.TryParse(UseOnPrem, out UseOnPremInt) == true)
                        {
                            if (UseOnPremInt == 1 && string.IsNullOrWhiteSpace(OnPremURL) == false)
                            {
                                k.SetValue("UseOnPremServer", 1, RegistryValueKind.DWord);
                                k.SetValue("Server", OnPremURL, RegistryValueKind.String);
                            }
                            else
                            {
                                k.SetValue("UseOnPremServer", 0, RegistryValueKind.DWord);
                            }
                        }
                        else
                        {
                            k.SetValue("UseOnPremServer", 0, RegistryValueKind.DWord);
                        }
                    }
                }
                catch (Exception ee)
                {
                    Debug.WriteLine(ee.ToString());
                }
                return;
            }

            if (UseLoginRecovery == true)
            {
                if (SystemInfos.CollectSystemInfo() != 0)
                {
                    return;
                }

#if !DEBUG
                if (SystemInfos.SysInfo.RunningInWindowsPE == false || SystemInfos.SysInfo.RunningInWindowsPE == null)
                {
                    return;
                }
#endif

                RecoveryLogon reclogon = new RecoveryLogon();
                reclogon.UCID             = SystemInfos.SysInfo.UCID;
                reclogon.ContractID       = SystemInfos.ContractID;
                reclogon.ContractPassword = SystemInfos.ContractPassword;

                string Check = SystemInfos.SysInfo.CPUName.Trim();
                Check += SystemInfos.SysInfo.ComputerModel == "" ? "N/A" : SystemInfos.SysInfo.ComputerModel.Trim();
                Check += SystemInfos.SysInfo.BIOS == "" ? "N/A" : SystemInfos.SysInfo.BIOS.Trim();

                reclogon.MoreMachineHash = MD5Utilities.CalcMD5(Check);
                Network net = Utilities.NoConnectNetwork();

                RecoveryData rd = net.GetRecoveryLogon(reclogon);
                if (rd == null)
                {
                    return;
                }
                if (rd.Worked == false)
                {
                    return;
                }

                string Registry = "Windows Registry Editor Version 5.00\r\n\r\n[HKEY_LOCAL_MACHINE\\SOFTWARE\\Fox\\SDC]\r\n\"ID\"=\"" + rd.MachineID + "\"\r\n\"PassID\"=\"" + rd.MachinePassword + "\"";
                try
                {
                    File.WriteAllText(Environment.ExpandEnvironmentVariables("%SYSTEMROOT%\\Fox SDC MachinePW.reg"), Registry, Encoding.Unicode);
                }
                catch
                {
                }
                return;
            }

            if (UsePipeAction == false && UseScreenAction == false)
            {
                using (RegistryKey installer = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + VulpesBranding.MSIGUID, false))
                {
                    if (installer == null)
                    {
                        FoxEventLog.WriteEventLog("Missing installer key in HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + VulpesBranding.MSIGUID + ". This can lead to erratic behavoir of the program!", EventLogEntryType.Warning);
                    }
                }

                if (CPP.SetToken() == false)
                {
                    FoxEventLog.WriteEventLog("Cannot setup token - 0x" + Marshal.GetLastWin32Error().ToString("X") + " - " + new Win32Exception(Marshal.GetLastWin32Error()).Message, System.Diagnostics.EventLogEntryType.Error);
                    return;
                }
            }

            if (UsePipeAction == true)
            {
                try
                {
                    Process2ProcessCommClient.RunPipeClient();
                }
                catch (Exception ee)
                {
                    FoxEventLog.WriteEventLog("Pipe SEH " + ee.ToString(), System.Diagnostics.EventLogEntryType.Error);
                }
                return;
            }

            if (UseScreenAction == true)
            {
                try
                {
                    if (SystemInfos.CollectSystemInfo() != 0)
                    {
                        return;
                    }
                    MainScreenSystemClient.RunPipeClient();
                }
                catch (Exception ee)
                {
                    FoxEventLog.WriteEventLog("Screen Pipe SEH " + ee.ToString(), System.Diagnostics.EventLogEntryType.Error);
                }
                return;
            }

            if (SystemInfos.CollectSystemInfo() != 0)
            {
#if !DEBUG || DEBUGSERVICE
                service.Stop();
#endif
                return;
            }

            RegistryData.InstallPath = AppPath;

            if (ApplicationCertificate.LoadCertificate() == false)
            {
                FoxEventLog.WriteEventLog("Cannot load certificate", System.Diagnostics.EventLogEntryType.Error);
#if !DEBUG || DEBUGSERVICE
                service.Stop();
#endif
                return;
            }

            if (FilesystemData.LoadCertificates() == false)
            {
#if !DEBUG || DEBUGSERVICE
                service.Stop();
#endif
                return;
            }
            if (FilesystemData.LoadPolicies() == false)
            {
#if !DEBUG || DEBUGSERVICE
                service.Stop();
#endif
                return;
            }
            FilesystemData.LoadLocalPackageData();
            FilesystemData.LoadLocalPackages();
            FilesystemData.LoadUserPackageData();
            FilesystemData.LoadEventLogList();

            SyncPolicy.ApplyPolicy(SyncPolicy.ApplyPolicyFunction.ApplySystem);

            PipeCommunicationSRV.StartPipeSrv();

            try
            {
                string p = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                if (p.EndsWith("\\") == false)
                {
                    p += "\\";
                }

                using (RegistryKey reg = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true))
                {
                    reg.SetValue("FoxSDCAgent", p + "FoxSDC_Agent_UI.exe", RegistryValueKind.String);
                    reg.SetValue("FoxSDCAgentApply", p + "FoxSDC_ApplyUserSettings.exe", RegistryValueKind.String);
                    reg.Close();
                }
            }
            catch
            {
            }

            try
            {
                using (RegistryKey reg = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", true))
                {
                    object o      = reg.GetValue("SoftwareSASGeneration", null);
                    int    rvalue = 0;
                    if (o != null)
                    {
                        rvalue = Convert.ToInt32(o);
                    }

                    if (rvalue != 1 && rvalue != 3)
                    {
                        reg.SetValue("SoftwareSASGeneration", 1);
                    }
                    reg.Close();
                }
            }
            catch
            {
            }

            Threads.StartAllThreads();
        }
Пример #6
0
        public static bool ApplyPolicy(ApplyPolicyFunction applymethod)
        {
            if (ActivePolicy == null)
            {
                ActivePolicy = new List <LoadedPolicyObject>();
            }

            FilesystemData.ReOrderPolicies();

            foreach (Type type in GetTypesWithHelpAttribute(Assembly.GetExecutingAssembly()))
            {
                PolicyObjectAttr po       = type.GetCustomAttribute <PolicyObjectAttr>();
                IPolicyClass     instance = (IPolicyClass)Activator.CreateInstance(type);
                try
                {
                    instance.PreApplyPolicy();
                }
                catch (Exception ee)
                {
                    Debug.WriteLine(ee.ToString());
                    FoxEventLog.WriteEventLog("SEH Error while finalising policy - Type 0x" + po.PolicyType.ToString("X"), System.Diagnostics.EventLogEntryType.Error);
                }
            }

            if (FilesystemData.UpdatePolicies != null)
            {
                foreach (KeyValuePair <LoadedPolicyObject, LoadedPolicyObject> kvp in FilesystemData.UpdatePolicies)
                {
                    foreach (Type type in GetTypesWithHelpAttribute(Assembly.GetExecutingAssembly()))
                    {
                        PolicyObjectAttr po = type.GetCustomAttribute <PolicyObjectAttr>();
                        if (po.PolicyType == kvp.Key.PolicyObject.Type)
                        {
                            IPolicyClass instance = (IPolicyClass)Activator.CreateInstance(type);
                            try
                            {
                                instance.UpdatePolicy(kvp.Key, kvp.Value);
                            }
                            catch (Exception ee)
                            {
                                Debug.WriteLine(ee.ToString());
                                FoxEventLog.WriteEventLog("SEH Error while updating policy - (Policy ID=" + kvp.Value.PolicyObject.ID.ToString() + " Name=" + kvp.Value.PolicyObject.Name + ")", System.Diagnostics.EventLogEntryType.Error);
                            }
                            break;
                        }
                    }
                }
            }

            List <LoadedPolicyObject> RemovePol = new List <LoadedPolicyObject>();

            foreach (LoadedPolicyObject a in ActivePolicy)
            {
                bool PolicyFound = false;
                foreach (LoadedPolicyObject b in FilesystemData.LoadedPolicyObjects)
                {
                    if (a.PolicyObject.ID == b.PolicyObject.ID &&
                        a.PolicyObject.Type == b.PolicyObject.Type)
                    {
                        PolicyFound = true;
                        break;
                    }
                }
                if (PolicyFound == false)
                {
                    RemovePol.Add(a);
                }
            }

            foreach (LoadedPolicyObject a in RemovePol)
            {
                foreach (Type type in GetTypesWithHelpAttribute(Assembly.GetExecutingAssembly()))
                {
                    PolicyObjectAttr po = type.GetCustomAttribute <PolicyObjectAttr>();
                    if (po.PolicyType == a.PolicyObject.Type)
                    {
                        IPolicyClass instance = (IPolicyClass)Activator.CreateInstance(type);
                        try
                        {
                            instance.RemovePolicy(a);
                        }
                        catch (Exception ee)
                        {
                            Debug.WriteLine(ee.ToString());
                            FoxEventLog.WriteEventLog("SEH Error while removing policy - (Policy ID=" + a.PolicyObject.ID.ToString() + " Name=" + a.PolicyObject.Name + ")", System.Diagnostics.EventLogEntryType.Error);
                        }
                        ActivePolicy.Remove(a);
                        break;
                    }
                }
            }

            RemovePol = new List <LoadedPolicyObject>(); //empty out

            foreach (LoadedPolicyObject a in FilesystemData.LoadedPolicyObjects)
            {
                bool PolicyFound = false;
                foreach (LoadedPolicyObject b in ActivePolicy)
                {
                    if (a.PolicyObject.ID == b.PolicyObject.ID &&
                        a.PolicyObject.Version == b.PolicyObject.Version &&
                        a.PolicyObject.Type == b.PolicyObject.Type)
                    {
                        PolicyFound = true;
                        break;
                    }
                }
                if (PolicyFound == false)
                {
                    bool CanProcessPolicy     = false;
                    bool FoundPolicyProcessor = false;

                    foreach (Type type in GetTypesWithHelpAttribute(Assembly.GetExecutingAssembly()))
                    {
                        PolicyObjectAttr po = type.GetCustomAttribute <PolicyObjectAttr>();
                        if (po.PolicyType == a.PolicyObject.Type)
                        {
                            IPolicyClass instance = (IPolicyClass)Activator.CreateInstance(type);
                            try
                            {
                                instance.ApplyPolicy(a);
                            }
                            catch (Exception ee)
                            {
                                Debug.WriteLine(ee.ToString());
                                FoxEventLog.WriteEventLog("SEH Error while applying policy - (Policy ID=" + a.PolicyObject.ID.ToString() + " Name=" + a.PolicyObject.Name + ")", System.Diagnostics.EventLogEntryType.Error);
                            }
                            CanProcessPolicy     = true;
                            FoundPolicyProcessor = true;
                            break;
                        }
                    }

                    if (CanProcessPolicy == true || FoundPolicyProcessor == true)
                    {
                        ActivePolicy.Add(a);
                    }

                    if (FoundPolicyProcessor == false)
                    {
                        FoxEventLog.WriteEventLog("Don't know how to process policy type 0x" + a.PolicyObject.Type.ToString("X") + " - (Policy ID=" + a.PolicyObject.ID.ToString() + " Name=" + a.PolicyObject.Name + ")", System.Diagnostics.EventLogEntryType.Warning);
                    }
                }
            }

            foreach (LoadedPolicyObject a in ActivePolicy)
            {
                foreach (Type type in GetTypesWithHelpAttribute(Assembly.GetExecutingAssembly()))
                {
                    PolicyObjectAttr po = type.GetCustomAttribute <PolicyObjectAttr>();
                    if (po.PolicyType == a.PolicyObject.Type)
                    {
                        IPolicyClass instance = (IPolicyClass)Activator.CreateInstance(type);
                        try
                        {
                            instance.ApplyOrdering(a, a.PolicyObject.Order);
                        }
                        catch (Exception ee)
                        {
                            Debug.WriteLine(ee.ToString());
                            FoxEventLog.WriteEventLog("SEH Error while reordering polcy - Type 0x" + po.PolicyType.ToString("X"), System.Diagnostics.EventLogEntryType.Error);
                        }
                    }
                }
            }

            foreach (Type type in GetTypesWithHelpAttribute(Assembly.GetExecutingAssembly()))
            {
                PolicyObjectAttr po       = type.GetCustomAttribute <PolicyObjectAttr>();
                IPolicyClass     instance = (IPolicyClass)Activator.CreateInstance(type);
                try
                {
                    switch (applymethod)
                    {
                    case ApplyPolicyFunction.ApplySystem:
                        instance.FinaliseApplyPolicy();
                        break;

                    case ApplyPolicyFunction.ApplyUser:
                        instance.FinaliseApplyPolicyUserPart();
                        break;

                    case ApplyPolicyFunction.Uninstall:
                        instance.FinaliseUninstallProgramm();
                        break;
                    }
                }
                catch (Exception ee)
                {
                    Debug.WriteLine(ee.ToString());
                    FoxEventLog.WriteEventLog("SEH Error while finalising policy (applymethod=" + applymethod.ToString() + ") - Type 0x" + po.PolicyType.ToString("X"), System.Diagnostics.EventLogEntryType.Error);
                }
            }

            FilesystemData.UpdatePolicies = null;

            if (applymethod == ApplyPolicyFunction.ApplySystem)
            {
                string ApplyUserSettingsApp = ProgramAgent.AppPath + "FoxSDC_ApplyUserSettings.exe";

                if (File.Exists(ApplyUserSettingsApp) == false)
                {
                    FoxEventLog.WriteEventLog("The file " + ApplyUserSettingsApp + " does not exist. User settings are not applied properly.", EventLogEntryType.Error);
                }
                else
                {
#if !DEBUG
                    if (ProgramAgent.CPP.VerifyEXESignature(ApplyUserSettingsApp) == false)
                    {
                        FoxEventLog.WriteEventLog("The file " + ApplyUserSettingsApp + " cannot be verified. User settings are not applied properly.", EventLogEntryType.Error);
                    }
                    else
#endif
                    {
                        try
                        {
                            Process.Start(ApplyUserSettingsApp, ""); //NT_AUTHORITY\SYSTEM
                        }
                        catch
                        {
                        }

                        try
                        {
                            ProgramAgent.CPP.StartAppAsUser(ApplyUserSettingsApp, ""); //all other logged in users
                        }
                        catch
                        {
                        }
                    }
                }
            }
            return(true);
        }
Пример #7
0
        public static bool DoSyncPolicy()
        {
            RequestCertPolicyID        = 0;
            RequestCertPolicyMessageID = 0;
            RequestCertPolicyCERData   = null;

            List <Int64> ProcessedPolicies = new List <long>();

            Network net;

            net = Utilities.ConnectNetwork(9);
            if (net == null)
            {
                return(false);
            }

            Status.UpdateMessage(9, "Downloading client settings");
            FoxEventLog.VerboseWriteEventLog("Downloading client settings", System.Diagnostics.EventLogEntryType.Information);
            ClientSettings settings = net.GetClientSettings();

            if (settings != null)
            {
                RegistryData.AdministratorName = settings.AdministratorName;
                RegistryData.MessageDisclaimer = settings.MessageDisclaimer;
            }

            Status.UpdateMessage(9, "Downloading policies");
            FoxEventLog.VerboseWriteEventLog("Downloading policies", System.Diagnostics.EventLogEntryType.Information);
            PolicyObjectListSigned    policieslistsigned = net.GetPoliciesForComputer();
            List <PolicyObjectSigned> policies           = policieslistsigned == null ? null : policieslistsigned.Items;

            if (policies == null)
            {
                FoxEventLog.VerboseWriteEventLog("Downloading policies - nix", System.Diagnostics.EventLogEntryType.Information);
                Status.UpdateMessage(9);
                net.CloseConnection();
                return(true);
            }

            if (FilesystemData.LoadedCertificates.Count > 0)
            {
                bool SignatureOK = false;
                foreach (FilesystemCertificateData cer in FilesystemData.LoadedCertificates)
                {
                    if (Certificates.Verify(policieslistsigned, cer.Certificate) == true)
                    {
                        SignatureOK = true;
                        break;
                    }
                }
                if (SignatureOK == false)
                {
                    FoxEventLog.WriteEventLog("Invalid signature for PolicyList - no policies will be processed.", System.Diagnostics.EventLogEntryType.Error);
                    net.CloseConnection();
                    return(true);
                }
            }
            if (RegistryData.Verbose == 1)
            {
                string data = "Got policy:\r\n";
                foreach (PolicyObjectSigned obj in policies)
                {
                    data += obj.Policy.Name + " [ID: " + obj.Policy.ID + " VER: " + obj.Policy.Version + "]\r\n";
                }
                FoxEventLog.VerboseWriteEventLog("Downloading policies " + data, System.Diagnostics.EventLogEntryType.Information);
            }

            if (FilesystemData.LoadedCertificates.Count > 0)
            {
                foreach (PolicyObjectSigned obj in policies)
                {
                    if (ApplicationCertificate.Verify(obj) == false)
                    {
                        FoxEventLog.WriteEventLog("One or more policies were tampered - no policies will be processed.", System.Diagnostics.EventLogEntryType.Error);
                        net.CloseConnection();
                        return(true);
                    }
                }
            }

            #region Certificate Checks

            foreach (PolicyObjectSigned obj in policies)
            {
                if (obj.Policy.Type == PolicyIDs.SignCertificate)
                {
                    if (FilesystemData.ContainsPolicy(obj.Policy, false, false) == true)
                    {
                        continue;
                    }
                    PolicyObjectSigned objj = net.GetPolicyObjectSigned(obj.Policy.ID);
                    //do not verify signing here - that won't work! - Fox
                    PolicySigningCertificates Cert = JsonConvert.DeserializeObject <PolicySigningCertificates>(objj.Policy.Data);
                    if (FilesystemData.ContainsLoadedCert(Convert.FromBase64String(Cert.UUCerFile)) == true)
                    {
                        continue;
                    }
                    bool sig = Certificates.Verify(Convert.FromBase64String(Cert.UUCerFile), Convert.FromBase64String(Cert.UUSignFile), InternalCertificate.Main);
                    if (sig == false)
                    {
                        RequestCertPolicyID      = objj.Policy.ID;
                        RequestCertPolicyCERData = Convert.FromBase64String(Cert.UUCerFile);
                        string CN = Certificates.GetCN(Convert.FromBase64String(Cert.UUCerFile));
                        if (CN == null)
                        {
                            FoxEventLog.WriteEventLog("Invalid certificate from server (Policy ID=" + objj.Policy.ID.ToString() + " Name=" + objj.Policy.Name + ")", System.Diagnostics.EventLogEntryType.Error);
                            continue;
                        }
                        Status.RequestCertificateConfirm("The certificate with " + CN + " is not signed by Vulpes. This may that someone tampered the connection, or a false certificate is installed on the server.\nDo you want to continue, and trust this certificate?", RequestCertPolicyID);
                        RequestCertPolicyMessageID = Status.MessageID;
                        FoxEventLog.WriteEventLog("Got unsinged certificate (Policy ID=" + objj.Policy.ID.ToString() + " Name=" + objj.Policy.Name + " " + CN + ")", System.Diagnostics.EventLogEntryType.Warning);
                    }
                    else
                    {
                        string CN = Certificates.GetCN(Convert.FromBase64String(Cert.UUCerFile));
                        if (CN == null)
                        {
                            FoxEventLog.WriteEventLog("Invalid (Vulpes signed) certificate from server (Policy ID=" + objj.Policy.ID.ToString() + " Name=" + objj.Policy.Name + ")", System.Diagnostics.EventLogEntryType.Error);
                            continue;
                        }
                        FilesystemData.InstallCertificate(Convert.FromBase64String(Cert.UUCerFile));
                    }
                }
            }

            #endregion

            if (FilesystemData.LoadedCertificates.Count > 0)
            {
                foreach (PolicyObjectSigned obj in policies)
                {
                    if (FilesystemData.ContainsPolicy(obj.Policy, false, false) == true)
                    {
                        if (ProcessedPolicies.Contains(obj.Policy.ID) == false)
                        {
                            ProcessedPolicies.Add(obj.Policy.ID);
                        }
                        FilesystemData.UpdatePolicyOrder(obj.Policy, obj.Policy.Order);
                        continue;
                    }

                    PolicyObjectSigned objj = net.GetPolicyObjectSigned(obj.Policy.ID);
                    if (objj == null)
                    {
                        FoxEventLog.WriteEventLog("No data for policy - not applying (Policy ID=" + obj.Policy.ID.ToString() + " Name=" + obj.Policy.Name + ")", System.Diagnostics.EventLogEntryType.Error);
                        continue;
                    }
                    if (ApplicationCertificate.Verify(objj) == false)
                    {
                        FoxEventLog.WriteEventLog("Policy was tampered - not applying (Policy ID=" + objj.Policy.ID.ToString() + " Name=" + objj.Policy.Name + ")", System.Diagnostics.EventLogEntryType.Error);
                        continue;
                    }

                    if (FilesystemData.InstallPolicy(objj.Policy, obj.Policy.Order) == false)
                    {
                        continue;
                    }
                    if (ProcessedPolicies.Contains(obj.Policy.ID) == false)
                    {
                        ProcessedPolicies.Add(obj.Policy.ID);
                    }
                }

                List <LoadedPolicyObject> RemovePol = new List <LoadedPolicyObject>();

                foreach (LoadedPolicyObject lobj in FilesystemData.LoadedPolicyObjects)
                {
                    if (ProcessedPolicies.Contains(lobj.PolicyObject.ID) == false)
                    {
                        RemovePol.Add(lobj);
                    }
                }

                foreach (LoadedPolicyObject lobj in RemovePol)
                {
                    FilesystemData.DeletePolicy(lobj);
                }
            }

            net.CloseConnection();

            if (RequestCertPolicyID == 0)
            {
                Status.UpdateMessage(9);
            }

            FoxEventLog.VerboseWriteEventLog("Downloading policies - DONE", System.Diagnostics.EventLogEntryType.Information);
            return(true);
        }
Пример #8
0
        public static bool DoSyncEventLog()
        {
            try
            {
                Network net;
                net = Utilities.ConnectNetwork(0);
                if (net == null)
                {
                    return(false);
                }
                net.CloseConnection();

                Status.UpdateMessage(0, "Collecting EventLog data");
                lst        = new List <EventLogReport>();
                HasEVTLogs = new HashSet <string>();

                Status.UpdateMessage(0, "Collecting EventLog data (Application)");

                if (CollectEVT("Application") == false)
                {
                    return(false);
                }

                Status.UpdateMessage(0, "Collecting EventLog data (Security)");

                if (CollectEVT("Security") == false)
                {
                    return(false);
                }

                Status.UpdateMessage(0, "Collecting EventLog data (System)");

                if (CollectEVT("System") == false)
                {
                    return(false);
                }

                if (RegistryData.EnableAdditionalEventLogs == true)
                {
                    string AdditionalBooks = RegistryData.AdditionalEventLogs;
                    if (string.IsNullOrWhiteSpace(AdditionalBooks) == false)
                    {
                        foreach (string AdditionalBook in AdditionalBooks.Split('|'))
                        {
                            if (string.IsNullOrWhiteSpace(AdditionalBook) == true)
                            {
                                continue;
                            }
                            Status.UpdateMessage(0, "Collecting EventLog data (" + AdditionalBook + ")");
                            if (CollectEVT2(AdditionalBook) == false)
                            {
                                return(false);
                            }
                        }
                    }
                }

                Status.UpdateMessage(0, "Collecting EventLog data (Processing ...)");

                HashSet <string> RM = new HashSet <string>();

                foreach (string evt in FilesystemData.SyncedEventLog)
                {
                    if (HasEVTLogs.Contains(evt) == false)
                    {
                        RM.Add(evt);
                    }
                }

                foreach (string evt in RM)
                {
                    FilesystemData.SyncedEventLog.Remove(evt);
                }

                RM.Clear();

                List <EventLogReport> REP = new List <EventLogReport>();

                net = Utilities.ConnectNetwork(0);
                if (net == null)
                {
                    return(false);
                }

                Status.UpdateMessage(0, "Collecting EventLog data (Sending data ...)");

                Int64 UploadCounter = 0;
                foreach (EventLogReport evt in lst)
                {
                    UploadCounter++;
                    if (FilesystemData.SyncedEventLog.Contains(evt.LogID) == true)
                    {
                        continue;
                    }
                    REP.Add(evt);
                    if (REP.Count > 99)
                    {
                        Status.UpdateMessage(0, "Collecting EventLog data (Sending data ... " + UploadCounter.ToString() + " of " + lst.Count.ToString() + ")");

                        if (net.ReportEventLogs(REP) == false)
                        {
                            net.CloseConnection();
                            Status.UpdateMessage(0);
                            return(false);
                        }
                        foreach (EventLogReport rep in REP)
                        {
                            FilesystemData.SyncedEventLog.Add(rep.LogID);
                        }
                        FilesystemData.WriteEventLogList();
                        REP.Clear();
                    }
                }

                if (REP.Count > 0)
                {
                    Status.UpdateMessage(0, "Collecting EventLog data (Sending data ...)");

                    if (net.ReportEventLogs(REP) == false)
                    {
                        net.CloseConnection();
                        Status.UpdateMessage(0);
                        return(false);
                    }
                    foreach (EventLogReport rep in REP)
                    {
                        FilesystemData.SyncedEventLog.Add(rep.LogID);
                    }
                    FilesystemData.WriteEventLogList();
                    REP.Clear();
                }
                lst.Clear();
                HasEVTLogs.Clear();
                net.CloseConnection();
            }
            catch (Exception ee)
            {
                Debug.WriteLine(ee.ToString());
                FoxEventLog.WriteEventLog("Servere error while syncing Event Log Data: " + ee.ToString(), EventLogEntryType.Error);
            }
            Status.UpdateMessage(0);
            return(true);
        }