Ejemplo n.º 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Write("Software Loaded");
            if (IsAdministrator())
            {
                Text = "Administrator: " + Text;
                Write("The Software is ran as administrator, please do not run it as administrator unless you are installing the main component for safety issues.");
            }


            //{921F5C8E-A7AC-4649-9CDC-4D9CDB1B35C5}
            if (!COMRegistered("{921F5C8E-A7AC-4649-9CDC-4D9CDB1B35C5}"))
            {
                TopMost = true;
                DialogResult confirmation = MessageBox.Show(this, "The Main Component is not installed, would you like to install it? (Required administrator privilege)", "COM Not Detected", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);
                TopMost = false;
                if (confirmation == DialogResult.Yes)
                {
                    if (IsAdministrator())
                    {
                        // Install it
                    }
                    else
                    {
                        MessageBox.Show("The main component cannot be installed due to lack of privilege, please run this software as administrator and try again (after you installed, administrator is not required). Press ok and the software will exit", "Installation Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else if (confirmation == DialogResult.No)
                {
                    MessageBox.Show("The Main Component cannot be detected from the registery. If you have choose to continue without installing so unless your sure that it installed and the detection made a mistake then an error will be thrown when you press OK", "Main Component Not Detected", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (confirmation == DialogResult.Cancel)
                {
                    MessageBox.Show("You have selected to quit the software, press ok to exit", "Software Exit", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Close();
                    return;
                }
                else
                {
                    MessageBox.Show("The Response was returned incorrectly, software will now shutdown", "Unknown Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Close();
                    return;
                }
            }
            try
            {
                api = new YubiClient();
            } catch (Exception ex)
            {
                MessageBox.Show("Software cannot start up, press ok to shutdown the software. Error: \n" + ex.Message, "Software Startup Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
                return;
            }
            api.enableNotifications = ycNOTIFICATION_MODE.ycNOTIFICATION_ON;
            if (string.IsNullOrWhiteSpace(Properties.Settings.Default.Challenge))
            {
                button2.Enabled = false;
                Write("You did not configurate the challenge yet, please configurate it before testing it out");
            }
        }
Ejemplo n.º 2
0
        public YubiSettings()
        {
            InitializeComponent();
            bool exit = false;

            try
            {
                api = new YubiClient();
            }
            catch
            {
                MessageBox.Show("Could not instantiate Yubico com api, is it installed?", "Yubico API failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
                exit = true;
                Application.Exit();
            }

            RegistryKey key   = Registry.LocalMachine.OpenSubKey(MSV1_0);
            Object      value = key.GetValue("Auth0");

            if (value == null && !exit)
            {
                DialogResult result = MessageBox.Show("YubiKey Logon is not enabled, do you want to enable it?", "YubiKey Logon not enabled", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result.Equals(DialogResult.Yes))
                {
                    toggleLabel.Text  = "YubiKey Logon enabled";
                    toggleButton.Text = "Disable";
                    toggleEnabled();
                }
                else
                {
                    toggleLabel.Text  = "YubiKey Logon disabled";
                    toggleButton.Text = "Enable";
                }
            }
            else if (((string)value).Equals("yubikeymsvsubauth"))
            {
                toggleLabel.Text  = "YubiKey Logon enabled";
                toggleButton.Text = "Disable";
            }
            else
            {
                toggleLabel.Text = "Unknown state";
            }

            RegistryKey settings        = Registry.LocalMachine.CreateSubKey(SETTINGS);
            Object      safemodeEnabled = settings.GetValue(SAFEMODE);

            if (safemodeEnabled != null && (int)safemodeEnabled == 1)
            {
                safemodeCheckBox.Checked = true;
            }
            object iterations = settings.GetValue("hashIterations");

            if (iterations == null)
            {
                settings.SetValue("hashIterations", DEFAULT_ITERATIONS);
            }

            testOutputLabel.Text = "";

            WqlObjectQuery           query    = new WqlObjectQuery("Select Name from WIN32_UserAccount where Disabled = false");
            ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);

            foreach (ManagementBaseObject user in searcher.Get())
            {
                String name = user.GetPropertyValue("Name").ToString();
                if (!name.EndsWith("$"))
                {
                    userSelect.Items.Add(name);
                }
            }

            api.deviceInserted += new _IYubiClientEvents_deviceInsertedEventHandler(yubiKey_Inserted);
            api.deviceRemoved  += new _IYubiClientEvents_deviceRemovedEventHandler(yubiKey_Removed);
        }