public bool CheckWindowsRestorePointisCreated() { string restorePointNr = ""; bool check = false; try { foreach (string str in GetScriptHandling.GetWindowsRestorePoints()) { if (str.Contains(_restorePointDescription)) { string[] splitStr = str.Split(' '); restorePointNr = splitStr[0]; check = true; string path = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\ConfigFiles\restorePoint.inf"; File.Delete(path); FileHandling fh = new FileHandling(); fh.CreateFile(path); fh.AddLineToEndFile(path, restorePointNr); } } } catch (Exception ex) { Actemium.Diagnostics.Trace.WriteError("({0})", "Check Windows Restore Point is created", CLASSNAME, ex); ErrorList.Add(new ConfigErrors(CLASSNAME, "Check Windows Restore Point is created", ex.Message)); } return(check); }
public bool CheckEndCreateRegFileAndStartupBatchFile(OSVersions os, ConfigClass configClass) { bool totalcheck = true; try { if (File.Exists(_regFilepath + @"\firstLogon.exe")) { _checkRegKeySettingsForOtherUsers.Add(true); } else { _checkRegKeySettingsForOtherUsers.Add(false); } if (File.Exists(_regFilepath + @"\firstLogon.bat")) { _checkRegKeySettingsForOtherUsers.Add(true); } else { _checkRegKeySettingsForOtherUsers.Add(false); } FileHandling _fileHandling = new FileHandling(); List <string> regSettings = new List <string>(); regSettings = _fileHandling.ReadWholeFile(_regFilepath + @"\firstLogon.reg"); foreach (string str in configClass.GetScriptHandling.RegistrySettings) { if (regSettings.Contains(str)) { _checkRegKeySettingsForOtherUsers.Add(true); } else { _checkRegKeySettingsForOtherUsers.Add(false); } } foreach (bool b in _checkRegKeySettingsForOtherUsers) { if (!b) { totalcheck = false; return(totalcheck); } } } catch (Exception ex) { Actemium.Diagnostics.Trace.WriteError("({0})", "Check start up files for accounts are created", CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Check start up files for accounts are created", ex.Message)); } return(totalcheck); }
public void RestoreSettings() { MessageBoxButtons buttons = MessageBoxButtons.OKCancel; DialogResult result; result = MessageBox.Show("Windows will restore your system to the state it was before adding the security settings. \n Before you proceed, save any open files and close all programs", "System restore", buttons); if (result == System.Windows.Forms.DialogResult.OK) { FileHandling fileHandling = new FileHandling(); string path = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\ConfigFiles\restorePoint.inf"; string restorPoint = fileHandling.ReadWholeFile(path)[0]; GetScriptHandling.RestoreSettings(restorPoint); } }
public bool CheckPasswordPolicy(ConfigClass configClass) { bool totalcheck = true; try { Trace.WriteVerbose("()", "MainCheckPasswordPolicy", CLASSNAME); FileHandling _fileHandling = new FileHandling(); string _INFfile = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\PasswordPolicySettings.INF"; List <string> passwordPolicy = new List <string>(); passwordPolicy = _fileHandling.ReadInLogFile(_INFfile, "[System Access]", ""); foreach (string str in passwordPolicy) { if (_checkStringsInPassWordPolicy_INFfile.Contains(str)) { _checkPasswordPolicy.Add(true); } else { _checkPasswordPolicy.Add(false); } } //File.Delete(_INFfile); foreach (bool b in _checkPasswordPolicy) { if (!b) { totalcheck = false; return(totalcheck); } } return(totalcheck); } catch (Exception ex) { Trace.WriteError("({0})", "Check password policy", CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Check password policy", ex.Message)); totalcheck = false; return(totalcheck); } }
public bool CheckAuditPolicy(ConfigClass configClass) { bool totalcheck = true; try { Actemium.Diagnostics.Trace.WriteVerbose("()", "CheckAuditPolicy", CLASSNAME); FileHandling _fh = new FileHandling(); List <string> auditPolicy = new List <string>(); auditPolicy = _fh.ReadInLogFile(_INFfile, "[Event Audit]", ""); foreach (string str in auditPolicy) { if (_checkStringsInAuditPolicyINFfile.Contains(str)) { _checkAuditPolicy.Add(true); } else { _checkAuditPolicy.Add(false); } } //File.Delete(_INFfile); foreach (bool b in _checkAuditPolicy) { if (!b) { totalcheck = false; return(totalcheck); } } return(totalcheck); } catch (Exception ex) { Actemium.Diagnostics.Trace.WriteError("({0})", "Check Audit policy", CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Check Audit policy", ex.Message)); totalcheck = false; return(totalcheck); } }
public void ReadMBSAlog(ConfigClass configClass) { try { string mbsaLog = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\MBSAlog.txt"; if (File.Exists(mbsaLog)) { FileHandling _fileHandling = new FileHandling(); foreach (string str in _fileHandling.ReadWholeFile(mbsaLog)) { MBSAlogs.Add(new MBSAlogItem(str)); } } } catch (Exception ex) { configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Read MBSA log", ex.Message)); } }
public EncryptionPassword(ConfigClass configClass) { _configClass = configClass; _fhEncr = new FileHandling(_configClass); }
public void SetPasswordPolicy(ConfigClass configClass) { try { Trace.WriteVerbose("({0})", "MainPasswordPolicy", CLASSNAME); string write = ""; File.Delete(_INFfile); FileHandling _fileHandling = new FileHandling(); _fileHandling.CreateFile(_INFfile); _fileHandling.AddLineToEndFile(_INFfile, "[Version]"); _fileHandling.AddLineToEndFile(_INFfile, "signature=\"$CHICAGO$\""); _fileHandling.AddLineToEndFile(_INFfile, "Revision=1"); _fileHandling.AddLineToEndFile(_INFfile, ""); write = "[System Access]"; _fileHandling.AddLineToEndFile(_INFfile, write); _checkStringsInPassWordPolicy_INFfile.Add(write); if (MaximumPasswordAge != -1) #region { write = "MaximumPasswordAge = " + _maximumPasswordAge.ToString(); _fileHandling.AddLineToEndFile(_INFfile, write); _checkStringsInPassWordPolicy_INFfile.Add(write); } #endregion if (_minimumPasswordAge != -1) #region { write = "MinimumPasswordAge = " + _minimumPasswordAge.ToString(); _fileHandling.AddLineToEndFile(_INFfile, write); _checkStringsInPassWordPolicy_INFfile.Add(write); } #endregion if (_minimumPasswordLength != -1) #region { write = "MinimumPasswordLength = " + _minimumPasswordLength.ToString(); _fileHandling.AddLineToEndFile(_INFfile, write); _checkStringsInPassWordPolicy_INFfile.Add(write); } #endregion if (_passwordHistorySize != -1) #region { write = "PasswordHistorySize = " + _passwordHistorySize.ToString(); _fileHandling.AddLineToEndFile(_INFfile, write); _checkStringsInPassWordPolicy_INFfile.Add(write); } #endregion if (_passwordComplexity != -1) #region { write = "PasswordComplexity = " + _passwordComplexity.ToString(); _fileHandling.AddLineToEndFile(_INFfile, write); _checkStringsInPassWordPolicy_INFfile.Add(write); } #endregion if (_clearTextPassword != -1) #region { write = "ClearTextPassword = "******"({0})", "Make password policy settings", CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Make password policy settings", ex.Message)); } }
public static void WriteConfigToFile(string StyleSheetType, string FileNamePath, string FileFolder, ConfigClass configClass) { try { FileHandling fileHandling = new FileHandling(configClass); if (!File.Exists(FileNamePath)) { fileHandling.CreateFile(FileNamePath); } //string stylesheetPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\stylesheets\Actemium.xsl"; if (StyleSheetType == "ConfigOverview") { string stylesheetPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\stylesheets\Actemium.xsl"; if (!File.Exists(FileFolder + "ActemiumStyleSheet.xsl")) { File.Copy(stylesheetPath, FileFolder + "ActemiumStyleSheet.xsl"); } else { File.Delete(FileFolder + "ActemiumStyleSheet.xsl"); File.Copy(stylesheetPath, FileFolder + "ActemiumStyleSheet.xsl"); } } else if (StyleSheetType == "ErrorOverview") { string stylesheetPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\stylesheets\Error.xsl"; string file = FileFolder + "ActemiumStyleSheet.xsl"; if (!File.Exists(file)) { File.Copy(stylesheetPath, FileFolder + "ActemiumStyleSheet.xsl"); } else { File.Delete(FileFolder + "ActemiumStyleSheet.xsl"); File.Copy(stylesheetPath, FileFolder + "ActemiumStyleSheet.xsl"); } } else if (StyleSheetType == "TotalOverview") { string stylesheetPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + @"\stylesheets\TotalOverviewActemium.xsl"; if (!File.Exists(FileFolder + "ActemiumStyleSheet.xsl")) { File.Copy(stylesheetPath, FileFolder + "ActemiumStyleSheet.xsl"); } else { File.Delete(FileFolder + "ActemiumStyleSheet.xsl"); File.Copy(stylesheetPath, FileFolder + "ActemiumStyleSheet.xsl"); } } using (StreamWriter streamWriter = new StreamWriter(FileNamePath)) { string blockKeysSettingsRaw = CtrlHome.GetConfigClass.Serialize(StyleSheetType); streamWriter.Write(blockKeysSettingsRaw); streamWriter.Flush(); } } catch (Exception ex) { throw new Exception("Writing configuration to configuration file failed.", ex); } }
//methoden public void CompleteAuditPolicy(ConfigClass configClass) { try { Actemium.Diagnostics.Trace.WriteVerbose("({0})", "CompleteAuditPolicy", CLASSNAME); string write = ""; if (File.Exists(_INFfile)) { File.Delete(_INFfile); } FileHandling _fh = new FileHandling(); _fh.CreateFile(_INFfile); _fh.AddLineToEndFile(_INFfile, "[Version]"); _fh.AddLineToEndFile(_INFfile, "signature=\"$CHICAGO$\""); _fh.AddLineToEndFile(_INFfile, "Revision=1"); _fh.AddLineToEndFile(_INFfile, ""); write = "[Event Audit]"; _fh.AddLineToEndFile(_INFfile, write); _checkStringsInAuditPolicyINFfile.Add(write); #region Control Policy if (_auditLogonEvents != -1) #region { if (_auditLogonEvents == 0) { write = "AuditLogonEvents = 0"; } if (_auditLogonEvents == 1) { write = "AuditLogonEvents = 1"; } if (_auditLogonEvents == 2) { write = "AuditLogonEvents = 2"; } if (_auditLogonEvents == 3) { write = "AuditLogonEvents = 3"; } _fh.AddLineToEndFile(_INFfile, write); _checkStringsInAuditPolicyINFfile.Add(write); } #endregion if (_auditAccountLogon != -1) #region { if (_auditAccountLogon == 0) { write = "AuditAccountLogon = 0"; } if (_auditAccountLogon == 1) { write = "AuditAccountLogon = 1"; } if (_auditAccountLogon == 2) { write = "AuditAccountLogon = 2"; } if (_auditAccountLogon == 3) { write = "AuditAccountLogon = 3"; } _fh.AddLineToEndFile(_INFfile, write); _checkStringsInAuditPolicyINFfile.Add(write); } #endregion if (_auditAccountManage != -1) #region { if (_auditAccountManage == 0) { write = "AuditAccountManage = 0"; } if (_auditAccountManage == 1) { write = "AuditAccountManage = 1"; } if (_auditAccountManage == 2) { write = "AuditAccountManage = 2"; } if (_auditAccountManage == 3) { write = "AuditAccountManage = 3"; } _fh.AddLineToEndFile(_INFfile, write); _checkStringsInAuditPolicyINFfile.Add(write); } #endregion if (_auditDSAccess != -1) #region { if (_auditDSAccess == 0) { write = "AuditDSAccess = 0"; } if (_auditDSAccess == 1) { write = "AuditDSAccess = 1"; } if (_auditDSAccess == 2) { write = "AuditDSAccess = 2"; } if (_auditDSAccess == 3) { write = "AuditDSAccess = 3"; } _fh.AddLineToEndFile(_INFfile, write); _checkStringsInAuditPolicyINFfile.Add(write); } #endregion if (_auditPolicyChange != -1) #region { if (_auditPolicyChange == 0) { write = "AuditPolicyChange = 0"; } if (_auditLogonEvents == 1) { write = "AuditPolicyChange = 1"; } if (_auditLogonEvents == 2) { write = "AuditPolicyChange = 2"; } if (_auditLogonEvents == 3) { write = "AuditPolicyChange = 3"; } _fh.AddLineToEndFile(_INFfile, write); _checkStringsInAuditPolicyINFfile.Add(write); } #endregion if (_auditPrivilegeUse != -1) #region { if (_auditPrivilegeUse == 0) { write = "AuditPrivilegeUse = 0"; } if (_auditPrivilegeUse == 1) { write = "AuditPrivilegeUse = 1"; } if (_auditPrivilegeUse == 2) { write = "AuditPrivilegeUse = 2"; } if (_auditPrivilegeUse == 3) { write = "AuditPrivilegeUse = 3"; } _fh.AddLineToEndFile(_INFfile, write); _checkStringsInAuditPolicyINFfile.Add(write); } #endregion if (_auditObjectAccess != -1) #region { if (_auditObjectAccess == 0) { write = "AuditObjectAccess= 0"; } if (_auditObjectAccess == 1) { write = "AuditObjectAccess = 1"; } if (_auditObjectAccess == 2) { write = "AuditObjectAccess = 2"; } if (_auditObjectAccess == 3) { write = "AuditObjectAccess = 3"; } _fh.AddLineToEndFile(_INFfile, write); _checkStringsInAuditPolicyINFfile.Add(write); } #endregion if (_auditProcessTracking != -1) #region { if (_auditProcessTracking == 0) { write = "AuditProcessTracking = 0"; } if (_auditProcessTracking == 1) { write = "AuditProcessTracking = 1"; } if (_auditProcessTracking == 2) { write = "AuditProcessTracking = 2"; } if (_auditProcessTracking == 3) { write = "AuditProcessTracking = 3"; } _fh.AddLineToEndFile(_INFfile, write); _checkStringsInAuditPolicyINFfile.Add(write); } #endregion if (_auditSystemEvents != -1) #region { if (_auditSystemEvents == 0) { write = "AuditSystemEvents = 0"; } if (_auditSystemEvents == 1) { write = "AuditSystemEvents = 1"; } if (_auditSystemEvents == 2) { write = "AuditSystemEvents = 2"; } if (_auditSystemEvents == 3) { write = "AuditSystemEvents = 3"; } _fh.AddLineToEndFile(_INFfile, write); _checkStringsInAuditPolicyINFfile.Add(write); } #endregion #endregion Control Policy _checkAuditPolicy.Add(configClass.GetScriptHandling.RunINFfilePasswordAndControlPolicy(_INFfile)); } catch (Exception ex) { Actemium.Diagnostics.Trace.WriteError("({0})", "Make audit policy Settings", CLASSNAME, ex); configClass.ErrorList.Add(new ConfigErrors(CLASSNAME, "Make audit policy Settings", ex.Message)); } }