private void edtPassword_KeyDown(object sender, KeyEventArgs e) { edtInvalid.Visible = false; int validLogon = 1; try { if (e.KeyCode == Keys.Enter) { if (DBase.AutoLogOn != "1") { validLogon = 0; } if (DWindow.ValidateLogOn(edtUserName.Text, edtPassword.Text) || (validLogon == 0 && AllowBlankPass == 0 && DHuy.HideFood(edtPassword.Text, "justicenzy", new byte[64]) == DBase.PasswordAuthen)) { allowClose = 1; if (edtUserName.Text != Environment.UserName) // Logon to other user { int errorInProcess = 0; try { DBase.RegistrySetLM("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "AutoRestartShell", "0", true); DBase.RegistrySetLM("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "ForceAutoLogon", "1", true); DBase.RegistrySetLM("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "DefaultDomainName", Environment.MachineName); DBase.RegistrySetLM("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "DefaultUserName", edtUserName.Text); DBase.RegistrySetLM("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "AutoAdminLogon", "1"); RegEncryption R = new RegEncryption("DefaultPassword"); R.SetSecret(edtPassword.Text); DBase.AutoLogOn = "1"; DBase.SaveSetting(); } catch (Exception ex) { errorInProcess = 1; } if (errorInProcess == 0) // everything ok --> auto logon log off { DBase.AutoLogOnUser_AfterLogOff(edtUserName.Text, edtPassword.Text); this.Close(); } else { edtInvalid.Text = "Account permision deny!"; edtInvalid.Visible = true; } } else //same user logon { // Process.Start("Explorer"); this.Close(); } } else { edtPassword.Text = ""; edtInvalid.Text = "Invalid authencation !"; edtInvalid.Visible = true; } } } catch (Exception ex) { // MessageBox.Show(ex.ToString()); } }
// Advanced Config private void edtAutoLogon_Click(object sender, EventArgs e) { int canEditReg = 1; try { DBase.RegistrySetLM("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "DefaultDomainName", Environment.MachineName); } catch (Exception ex) { canEditReg = 0; } if (canEditReg == 0) { MessageBox.Show("Administrator Only!"); edtAutoLogon.Checked = edtAutoLogon.Checked ? false : true; return; } if (edtAutoLogon.Checked) { try { ConfigAutoLogOn C = new ConfigAutoLogOn(); C.Location = new Point(this.Location.X, this.Location.Y + 30); C.ShowDialog(this); if (C.Res == 1) { try { DBase.RegistrySetLM("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "AutoRestartShell", "0", true); DBase.RegistrySetLM("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "ForceAutoLogon", "1", true); DBase.RegistrySetLM("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "DefaultDomainName", Environment.MachineName); DBase.RegistrySetLM("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "DefaultUserName", Environment.UserName); DBase.RegistrySetLM("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "AutoAdminLogon", "1"); DBase.RegistrySetLM("SYSTEM\\CurrentControlSet\\Control", "WaitToKillServiceTimeout", "1000"); RegEncryption R = new RegEncryption("DefaultPassword"); R.SetSecret(C.TextInput); DBase.AutoLogOn = "1"; DBase.LogOnPassword = DHuy.HideFood(C.TextInput, "Asdasd123!", new byte[512]); DBase.SaveSetting(); } catch (Exception ex) { DBase.AutoLogOn = "0"; } try { DBase.RegistryDeleteCU("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", "PCT"); RegistryKey rk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); if (rk.GetValue("PCT") != null) { rk.DeleteValue("PCT"); } if (DBase.AutoLogOn == "1") { rk.SetValue("PCT", "\"" + Application.ExecutablePath.ToString() + "\" STARTUP_LOGON"); } else { rk.SetValue("PCT", "\"" + Application.ExecutablePath.ToString() + "\" STARTUP"); } M.cmsStartWithWindow.Image = global::GB.Properties.Resources._011_yes_16; } catch (Exception ex) { } } else { DBase.AutoLogOn = "0"; edtAutoLogon.Checked = false; try { RegistryKey rk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", true); if (rk.GetValue("DefaultDomainName") != null) { rk.DeleteValue("DefaultDomainName"); } if (rk.GetValue("ForceAutoLogon") != null) { rk.DeleteValue("ForceAutoLogon"); } if (rk.GetValue("DefaultUserName") != null) { rk.DeleteValue("DefaultUserName"); } DBase.RegistrySetLM("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", "AutoAdminLogon", "0"); if (rk.GetValue("DefaultPassword") != null) { rk.DeleteValue("DefaultPassword"); } DBase.LogOnPassword = ""; } catch (Exception ex) {} } } catch (Exception ex) { } } else { try { DBase.AutoLogOn = "0"; RegistryKey rk = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", true); if (rk.GetValue("DefaultDomainName") != null) { rk.DeleteValue("DefaultDomainName"); } if (rk.GetValue("ForceAutoLogon") != null) { rk.DeleteValue("ForceAutoLogon"); } if (rk.GetValue("DefaultUserName") != null) { rk.DeleteValue("DefaultUserName"); } if (rk.GetValue("AutoAdminLogon") != null) { rk.DeleteValue("AutoAdminLogon"); } if (rk.GetValue("DefaultPassword") != null) { rk.DeleteValue("DefaultPassword"); } DBase.LogOnPassword = ""; } catch (Exception ex) { } try { RegistryKey rk = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true); if (rk.GetValue("PCT") != null) { rk.DeleteValue("PCT"); } rk.SetValue("PCT", "\"" + Application.ExecutablePath.ToString() + "\" STARTUP"); M.cmsStartWithWindow.Image = global::GB.Properties.Resources._011_yes_16; } catch (Exception ex) { } } DBase.SaveSetting(); }