public BootOptionManager()
        {
            currentBootOptionFilePath = System.Windows.Forms.Application.StartupPath + "\\" + StringResource.bootOptionFileName;

            // 비밀번호 파일 읽기 (없으면 새로 생성)
            if (System.IO.File.Exists(currentBootOptionFilePath))
            {
                string prevPass  = System.IO.File.ReadAllText(currentBootOptionFilePath);
                string resultStr = PasswordEncryption.DecrypString(prevPass, App.passwordEncryptionKey);
                if (resultStr.Equals("true"))
                {
                    autoBootingOption = true;
                    runRegKey.SetValue("ProcessContorller", Environment.CurrentDirectory + "\\" + AppDomain.CurrentDomain.FriendlyName);
                }
                else if (resultStr.Equals("false"))
                {
                    autoBootingOption = false;
                    runRegKey.SetValue("ProcessController", false);
                }
            }
            else
            {
                FileStream myFile = System.IO.File.Create(currentBootOptionFilePath);
                myFile.Close();
                string prevPass = PasswordEncryption.EncrypString("true", App.passwordEncryptionKey);
                System.IO.File.WriteAllText(currentBootOptionFilePath, prevPass); //true로 기본 파일 생성
                autoBootingOption = true;
                runRegKey.SetValue("ProcessController", true);
            }
        }
        private void processBlockApplyButton_Click(object sender, RoutedEventArgs e)
        {
            finalBlockList = blockFileList;
            finalBlockList.Sort();
            string inputEncrypText = "";

            foreach (string splitWord in finalBlockList)
            {
                inputEncrypText += (splitWord + ",");
            }
            if (inputEncrypText.Length > 1)
            {
                inputEncrypText = inputEncrypText.Remove(inputEncrypText.Length - 1);
                inputEncrypText = PasswordEncryption.EncrypString(inputEncrypText, App.passwordEncryptionKey);
            }
            else
            {
                inputEncrypText = "";
            }
            System.IO.File.WriteAllText(currentBlockFileListPath, inputEncrypText); // 암호화 하여 저장


            if (bootingOptionCheck.IsChecked == true)
            {
                App.AppBootOptionManager.ChangeBootOption(true);
            }
            else if (bootingOptionCheck.IsChecked == false)
            {
                App.AppBootOptionManager.ChangeBootOption(false);
            }
            MessageBox.Show("변경 사항이 저장되었습니다.");
        }
        private MainWindow()
        {
            InitializeComponent();
            this.Title        = StringResource.mainWinTitle;
            noneBlockFileList = ProcessManager.BlockProcessName;
            noneBlockFileList.Sort();

            // 차단 프로세스 리스트 파일 읽기 (없으면 새로 생성)
            currentBlockFileListPath = System.Windows.Forms.Application.StartupPath + "\\" + StringResource.blockProcessFileName;
            if (System.IO.File.Exists(currentBlockFileListPath))
            {
                string prevPass = System.IO.File.ReadAllText(currentBlockFileListPath);
                if (prevPass != "")
                {
                    string   tempBlockStr = PasswordEncryption.DecrypString(prevPass, App.passwordEncryptionKey);
                    string[] splitWords   = tempBlockStr.Split(',');
                    foreach (string str in splitWords)
                    {
                        blockFileList.Add(str);
                        noneBlockFileList.Remove(str);
                    }
                    finalBlockList = blockFileList;
                    finalBlockList.Sort();
                }
            }
            else
            {
                FileStream myFile = System.IO.File.Create(currentBlockFileListPath);
                myFile.Close();
                System.IO.File.WriteAllText(currentBlockFileListPath, ""); //빈 파일 생성
            }
            ProcessManager.UpdateProcessList(blockFileList, noneBlockFileList, currentBlockProcessList, canBlockProcessList);
            foreach (string str in blockFileList)
            {
                Console.WriteLine("차단 : " + str);
            }
            foreach (string str in noneBlockFileList)
            {
                Console.WriteLine("비차단 : " + str);
            }


            // 부팅 옵션 처리
            if (App.AppBootOptionManager.AutoBootingOption == true)
            {
                bootingOptionCheck.IsChecked = true;
            }
            else
            {
                bootingOptionCheck.IsChecked = false;
            }
        }
 public void ChangeBootOption(bool flag)
 {
     if (flag)
     {
         string prevPass = PasswordEncryption.EncrypString("true", App.passwordEncryptionKey);
         System.IO.File.WriteAllText(currentBootOptionFilePath, prevPass);
         autoBootingOption = true;
         runRegKey.SetValue("ProcessContorller", Environment.CurrentDirectory + "\\" + AppDomain.CurrentDomain.FriendlyName);
     }
     else
     {
         string prevPass = PasswordEncryption.EncrypString("false", App.passwordEncryptionKey);
         System.IO.File.WriteAllText(currentBootOptionFilePath, prevPass);
         autoBootingOption = false;
         runRegKey.SetValue("ProcessController", false);
     }
 }
        private void completeButton_Click(object sender, RoutedEventArgs e)
        {
            if (passwordInputText.Password == "")
            {
                MessageBox.Show("비밀번호가 입력되지 않았습니다.");
                return;
            }
            string prevPass = PasswordEncryption.EncrypString(passwordInputText.Password, App.passwordEncryptionKey);

            System.IO.File.WriteAllText(App.CurrentPasswordPath, prevPass);
            App.Password = passwordInputText.Password;
            passwordInputText.Password = "";
            MessageBox.Show("비밀번호 변경이 완료되었습니다.");
            if (!App.LoginSession)
            {
                App.PasswordInputWin = PasswordInput.GetPasswordInputWin;
                App.PasswordInputWin.PasswordInputLoginAct();
            }
            this.Close();
        }
Esempio n. 6
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            //중복 실행 방지
            try
            {
                Process[] myProcesses = Process.GetProcessesByName("ProcessController");
                if (myProcesses.Length > 1)
                {
                    MessageBox.Show("프로그램이 이미 실행중입니다");
                    System.Environment.Exit(0);
                }
            }
            catch (Exception ex)
            {
            }

            // 노티파이 메뉴 만들기
            NotifyIconHandler.SetNotifyObj(2, StringResource.notifyMenuTitle, ProcessController.Properties.Resources.notifyIcon, NotifyMenuMethod.NotifyTitleMethod);
            myNotify = NotifyIconHandler.NotifyObj;
            NotifyMenuMethod.SetNotifyMenu(myNotify);

            // 부팅 옵션 처리
            appBootOptionManager = new BootOptionManager();

            // 블록 프로세스 읽기
            ProcessManager.ReadBlockProcessName();

            currentPasswordPath = System.Windows.Forms.Application.StartupPath + "\\" + StringResource.passwordFileName;

            // 비밀번호 파일 읽기
            if (System.IO.File.Exists(currentPasswordPath))
            {
                string prevPass = System.IO.File.ReadAllText(currentPasswordPath);
                if (prevPass != "")
                {
                    password = PasswordEncryption.DecrypString(prevPass, passwordEncryptionKey);
                }
                else
                {
                    password = "";
                }
            }
            else
            {
                /*
                 * FileStream myFile = System.IO.File.Create(currentPasswordPath);
                 * myFile.Close();
                 * System.IO.File.WriteAllText(currentPasswordPath, blockPassKey); //차단 파일 생성
                 * password = PasswordEncryption.DecrypString(blockPassKey, passwordEncryptionKey);*/
                MessageBox.Show("암호 파일에 직접 접근한 흔적이 있습니다. 마스터 암호로 실행해주세요.");
                FileStream myFile = System.IO.File.Create(currentPasswordPath);
                myFile.Close();
                string prevPass = PasswordEncryption.EncrypString(blockPassKey, passwordEncryptionKey);
                System.IO.File.WriteAllText(currentPasswordPath, prevPass); //차단 파일 생성
                password = blockPassKey;
                AutoLogin();
            }


            if (password == "")
            {
                MessageBox.Show("암호 파일에 직접 접근한 흔적이 있습니다. 마스터 암호로 실행해주세요.");
                string prevPass = PasswordEncryption.EncrypString(blockPassKey, passwordEncryptionKey);
                System.IO.File.WriteAllText(currentPasswordPath, prevPass); //차단 파일 생성
                password = blockPassKey;
                AutoLogin();
            }
            else if (password == "MasterPass") // 초기 마스터 비밀번호 생성코드 필요
            {
                MessageBox.Show("첫 이용입니다. 비밀번호를 설정해주세요.");
                passwordApplyWin = PasswordApply.GetPasswordApplyWin;
                PasswordApplyWin.Show();
            }
            else if (appBootOptionManager.AutoBootingOption)
            {
                // 자동 로그인
                AutoLogin();
                MessageBox.Show(StringResource.appTitle + "가 실행됩니다.");
            }
            else if (password == emergencyExitKey)
            {
                MessageBox.Show("개발자 전용 긴급 exit 백도어");
                System.Environment.Exit(0);
            }
            else
            {
                LoginSession     = false;
                passwordInputWin = PasswordInput.GetPasswordInputWin;
                passwordInputWin.Show();
            }
        }