Exemplo n.º 1
0
 internal static void WRITE_Default_SWELF_Reg_Keys()
 {
     Microsoft.Win32.RegistryKey key;
     key = Microsoft.Win32.Registry.LocalMachine.CreateSubKey("Software\\SWELF");
     BASE_SWELF_KEY.SetValue(SWELF_Keys[(int)REG_KEY.First_Run].ToString(), Crypto_Operation.Protect_Data_Value("true"));
     BASE_SWELF_KEY.SetValue(SWELF_Keys[(int)REG_KEY.LogCollecter].ToString(), Crypto_Operation.Protect_Data_Value("127.0.0.1"));
     //BASE_SWELF_KEY.SetValue(SWELF_Keys[(int)REG_KEY.LogCollecter_1].ToString(), Encryptions.Protect_Data_Value("127.0.0.1"));
     //BASE_SWELF_KEY.SetValue(SWELF_Keys[(int)REG_KEY.LogCollecter_2].ToString(), Encryptions.Protect_Data_Value("127.0.0.1"));
     //BASE_SWELF_KEY.SetValue(SWELF_Keys[(int)REG_KEY.LogCollecter_3].ToString(), Encryptions.Protect_Data_Value("127.0.0.1"));
     //BASE_SWELF_KEY.SetValue(SWELF_Keys[(int)REG_KEY.LogCollecter_4].ToString(), Encryptions.Protect_Data_Value("127.0.0.1"));
     //BASE_SWELF_KEY.SetValue(SWELF_Keys[(int)REG_KEY.LogCollecter_5].ToString(), Encryptions.Protect_Data_Value("127.0.0.1"));
     BASE_SWELF_KEY.SetValue(SWELF_Keys[(int)REG_KEY.Encryption].ToString(), Crypto_Operation.Protect_Data_Value(Crypto_Operation.Generate_Decrypt()));
     BASE_SWELF_KEY.SetValue(SWELF_Keys[(int)REG_KEY.logging_level].ToString(), Crypto_Operation.Protect_Data_Value(Settings.Logging_Level_To_Report));
     BASE_SWELF_KEY.SetValue(SWELF_Keys[(int)REG_KEY.output_format].ToString(), Crypto_Operation.Protect_Data_Value("keyvalue"));
     BASE_SWELF_KEY.SetValue(SWELF_Keys[(int)REG_KEY.SWELF_Current_Version].ToString(), Crypto_Operation.Protect_Data_Value(Settings.SWELF_Version));
     BASE_SWELF_KEY.SetValue(SWELF_Keys[(int)REG_KEY.SWELF_CWD].ToString(), Crypto_Operation.Protect_Data_Value(Settings.SWELF_CWD));
     BASE_SWELF_KEY.SetValue(SWELF_Keys[(int)REG_KEY.SWELF_FAILED_SEC_CHECK].ToString(), Crypto_Operation.Protect_Data_Value("false"));
     //BASE_SWELF_KEY.SetValue(SWELF_Keys[(int)REG_KEY.central_app_config].ToString(), Crypto_Operation.Protect_Data_Value(""));
     //BASE_SWELF_KEY.SetValue(SWELF_Keys[(int)REG_KEY.central_plugin_search_config].ToString(), Crypto_Operation.Protect_Data_Value(""));
     // BASE_SWELF_KEY.SetValue(SWELF_Keys[(int)REG_KEY.central_search_config].ToString(), Crypto_Operation.Protect_Data_Value(""));
     //BASE_SWELF_KEY.SetValue(SWELF_Keys[(int)REG_KEY.central_whitelist_search_config].ToString(),Crypto_Operation.Protect_Data_Value(""));
     BASE_SWELF_KEY.SetValue(SWELF_Keys[(int)REG_KEY.ConsoleAppConfig_CreationDate].ToString(), Crypto_Operation.Protect_Data_Value(File_Operation.GET_CreationTime(Settings.GET_AppConfigFile_Path)));
     BASE_SWELF_KEY.SetValue(SWELF_Keys[(int)REG_KEY.ConsoleAppConfig_Contents], Crypto_Operation.Protect_Data_Value(File_Operation.READ_AllText(Settings.GET_AppConfigFile_Path)));
     BASE_SWELF_KEY.SetValue(SWELF_Keys[(int)REG_KEY.SearchTerms_File_Contents], Crypto_Operation.Protect_Data_Value(File_Operation.READ_AllText(Settings.GET_SearchTermsFile_Path)));
     BASE_SWELF_KEY.SetValue(SWELF_Keys[(int)REG_KEY.Logs_Last_Sent], Crypto_Operation.Protect_Data_Value(DateTime.Now.ToString()));
 }
Exemplo n.º 2
0
        internal static void READ_ALL_SWELF_Reg_Keys()
        {
            foreach (string RegKeyValue in BASE_SWELF_KEY.GetValueNames())
            {
                try
                {
                    if (String.IsNullOrEmpty(BASE_SWELF_KEY.GetValue(RegKeyValue).ToString()) == false)
                    {
                        Settings.REG_Keys.Add(RegKeyValue, READ_SWELF_Reg_Key(RegKeyValue));
                    }
                }
                catch (Exception e)
                {
                    if (e.Message.Contains("An item with the same key has already been added.") == false)
                    {
                        Error_Operation.Log_Error("READ_ALL_SWELF_Reg_Keys()", e.Message.ToString(), e.StackTrace.ToString(), Error_Operation.LogSeverity.Verbose);
                    }
                }
            }

            if (CHECK_SWELF_Reg_Key_Exists(REG_KEY.Logs_Last_Sent) == false)
            {
                string Date = DateTime.Now.ToString();
                BASE_SWELF_KEY.SetValue(SWELF_Keys[(int)REG_KEY.Logs_Last_Sent], Crypto_Operation.Protect_Data_Value(Date));
                Settings.REG_Keys.Add(SWELF_Keys[20], Date);
            }
        }
Exemplo n.º 3
0
        internal static void READ_ALL_SWELF_Reg_Keys()
        {
            foreach (string sub in BASE_SWELF_KEY.GetValueNames())
            {
                try
                {
                    if (String.IsNullOrEmpty(BASE_SWELF_KEY.GetValue(sub).ToString()) == false)
                    {
                        Settings.REG_Keys.Add(sub, READ_SWELF_Reg_Key(sub));
                    }
                }
                catch (Exception e)
                {
                    Error_Operation.Log_Error("READ_ALL_SWELF_Reg_Keys()", e.Message.ToString(), e.StackTrace.ToString(), Error_Operation.LogSeverity.Verbose);
                }
            }

            if (CHECK_SWELF_Reg_Key_Exists(REG_KEY.Logs_Last_Sent) == false)
            {
                string Date = DateTime.Now.ToString();
                BASE_SWELF_KEY.SetValue(SWELF_Keys[(int)REG_KEY.Logs_Last_Sent], Crypto_Operation.Protect_Data_Value(Date));
                Settings.REG_Keys.Add(SWELF_Keys[20], Date);
            }
        }
Exemplo n.º 4
0
 internal static bool CHECK_SWELF_Reg_Key_Exists(REG_KEY Key)
 {
     try
     {
         if (Settings.REG_Keys.Count > 1)
         {
             if (Settings.REG_Keys.ContainsKey(SWELF_Keys[(int)Key].ToString()))
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         else
         {
             if (String.IsNullOrEmpty(BASE_SWELF_KEY.GetValue(SWELF_Keys[(int)Key]).ToString()) == false)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception e)
     {
         if (Key != REG_KEY.logging_level)
         {
             Error_Operation.Log_Error("CHECK_SWELF_Reg_Key_Exists()", e.Message.ToString(), e.StackTrace.ToString(), Error_Operation.LogSeverity.Verbose);
             return(false);
         }
         else
         {
             BASE_SWELF_KEY.SetValue(SWELF_Keys[(int)REG_KEY.logging_level].ToString(), Crypto_Operation.Protect_Data_Value(Settings.Logging_Level_To_Report));
             return(true);
         }
     }
 }
Exemplo n.º 5
0
 internal static object READ_Eventlog_SWELF_Reg_Key(string Key)
 {
     if (Settings.REG_Keys.Count > 1)
     {
         if (Settings.REG_Keys.ContainsKey(Key))
         {
             return(Settings.REG_Keys[Key]);
         }
     }
     else
     {
         if (CHECK_Eventlog_SWELF_Reg_Key_Exists(Key))
         {
             if (Crypto_Operation.CHECK_Value_Encrypted(Crypto_Operation.ObjectToByteArray(BASE_SWELF_KEY.GetValue(Key))))
             {
                 return(Crypto_Operation.UnProtect_Data_Value(Crypto_Operation.ObjectToByteArray(BASE_SWELF_KEY.GetValue(Key))));
             }
             else
             {
                 ADD_or_CHANGE_SWELF_Reg_Key(Key, Crypto_Operation.CONVERT_To_String_From_Bytes(Crypto_Operation.Protect_Data_Value(Crypto_Operation.ObjectToByteArray(BASE_SWELF_KEY.GetValue(Key))), 1));
                 return(Crypto_Operation.UnProtect_Data_Value(Crypto_Operation.ObjectToByteArray(BASE_SWELF_KEY.GetValue(Key))));
             }
         }
         else
         {
             Error_Operation.Log_Error("CHANGE_Reg_Key()", "Reg Key does not exist. RegKey=" + Key, "", Error_Operation.LogSeverity.Warning);
             return("");
         }
     }
     return("");
 }
Exemplo n.º 6
0
 internal static string READ_SWELF_Reg_Key(REG_KEY Key, bool Log_Error = true)
 {
     try
     {
         if (Settings.REG_Keys.Count > 1)
         {
             if (Settings.REG_Keys.ContainsKey(SWELF_Keys[(int)Key].ToString()))
             {
                 return(Settings.REG_Keys[SWELF_Keys[(int)Key]].ToString());
             }
             else
             {
                 return("");
             }
         }
         else
         {
             if (CHECK_SWELF_Reg_Key_Exists(Key))
             {
                 if (Crypto_Operation.CHECK_Value_Encrypted(Crypto_Operation.ObjectToByteArray(BASE_SWELF_KEY.GetValue(SWELF_Keys[(int)Key]))))
                 {
                     try
                     {
                         return(Crypto_Operation.UnProtect_Data_Value((byte[])BASE_SWELF_KEY.GetValue(SWELF_Keys[(int)Key])));
                     }
                     catch (Exception e)
                     {
                         ADD_or_CHANGE_SWELF_Reg_Key(Key, SWELF_Keys[(int)Key]);
                         return(Crypto_Operation.UnProtect_Data_Value((byte[])BASE_SWELF_KEY.GetValue(SWELF_Keys[(int)Key])));
                     }
                 }
                 else
                 {
                     ADD_or_CHANGE_SWELF_Reg_Key(Key, Crypto_Operation.CONVERT_To_String_From_Bytes(Crypto_Operation.Protect_Data_Value(SWELF_Keys[(int)Key].ToString()), 1));
                     return(Crypto_Operation.UnProtect_Data_Value((byte[])BASE_SWELF_KEY.GetValue(SWELF_Keys[(int)Key])));
                 }
             }
             else
             {
                 return("");
             }
         }
     }
     catch
     {
         try
         {
             if (CHECK_SWELF_Reg_Key_Exists(Key))
             {
                 if (Crypto_Operation.CHECK_Value_Encrypted(Crypto_Operation.ObjectToByteArray(BASE_SWELF_KEY.GetValue(SWELF_Keys[(int)Key]))))
                 {
                     try
                     {
                         return(Crypto_Operation.UnProtect_Data_Value((byte[])BASE_SWELF_KEY.GetValue(SWELF_Keys[(int)Key])));
                     }
                     catch (Exception e)
                     {
                         ADD_or_CHANGE_SWELF_Reg_Key(Key, SWELF_Keys[(int)Key]);
                         return(Crypto_Operation.UnProtect_Data_Value((byte[])BASE_SWELF_KEY.GetValue(SWELF_Keys[(int)Key])));
                     }
                 }
                 else
                 {
                     ADD_or_CHANGE_SWELF_Reg_Key(Key, Crypto_Operation.CONVERT_To_String_From_Bytes(Crypto_Operation.Protect_Data_Value(SWELF_Keys[(int)Key].ToString()), 1));
                     return(Crypto_Operation.UnProtect_Data_Value((byte[])BASE_SWELF_KEY.GetValue(SWELF_Keys[(int)Key])));
                 }
             }
             else
             {
                 if (Log_Error)
                 {
                     Error_Operation.Log_Error("CHANGE_Reg_Key()", "Reg Key does not exist. RegKey=" + Key, "", Error_Operation.LogSeverity.Warning);
                 }
                 return("");
             }
         }
         catch (Exception e)
         {
             if (Log_Error)
             {
                 Error_Operation.Log_Error("CHANGE_Reg_Key()", "Reg Key does not exist. RegKey=" + Key + ". " + e.Message.ToString(), e.StackTrace.ToString(), Error_Operation.LogSeverity.Warning);
             }
             return("");
         }
     }
 }
Exemplo n.º 7
0
 internal static void ADD_or_CHANGE_SWELF_Reg_Key(string Key, string Value)
 {
     BASE_SWELF_KEY.SetValue(Key, Crypto_Operation.Protect_Data_Value(Value));
 }