private static void CreateConfig() { Console.WriteLine(" - Creating default conficuration file"); StringBuilder sb = new StringBuilder(); if (DB_KEY is null || DB_KEY.Length > 0) { Console.WriteLine(" - Generate DB_KEY"); DB_KEY = CryptoAes.GenerateHexString(40); DB_KEY_A = CryptoAes.KeyToBytes(DB_KEY, 32); //256-bits DB_KEY_B = CryptoAes.KeyToBytes(DB_KEY, 16); //128-bits } if (PRESHARED_KEY is null || PRESHARED_KEY.Length > 0) { Console.WriteLine(" - Generate PRESHARED_KEY"); PRESHARED_KEY = CryptoAes.GenerateHexString(40); PRESHARED_KEY_A = CryptoAes.KeyToBytes(PRESHARED_KEY, 32); //256-bits PRESHARED_KEY_B = CryptoAes.KeyToBytes(PRESHARED_KEY, 16); //128-bits } sb.AppendLine($"# version {Assembly.GetExecutingAssembly().GetName().Version.Major}.{Assembly.GetExecutingAssembly().GetName().Version.Minor}"); sb.AppendLine(); sb.AppendLine($"db_key = {DB_KEY}"); sb.AppendLine($"preshared_key = {PRESHARED_KEY}"); sb.AppendLine(); sb.AppendLine($"force_registry_keys = {force_registry_keys.ToString().ToLower()}"); sb.AppendLine(); sb.AppendLine("# you can use multiple entries"); sb.AppendLine("ip_access = *"); sb.AppendLine(); sb.AppendLine("http_enable = true"); sb.AppendLine("http_prefix = https://+:443/"); sb.AppendLine("http_prefix = http://127.0.0.1:80/"); sb.AppendLine(); sb.AppendLine("addressbook_enable = false"); sb.AppendLine("addressbook_prefix = http://*:911/"); sb.AppendLine(); sb.AppendLine(); sb.AppendLine("###"); sb.AppendLine("### Use NETSH to bind an SSL certificate with your https endpoint:"); sb.AppendLine($"### netsh http add sslcert ipport=0.0.0.0:443 certhash=[thumbprint] appid={{{GetAppid()}}}"); sb.AppendLine("###"); File.WriteAllText(Strings.FILE_CONFIG, sb.ToString()); }
public void SaveSettings() { Settings.Default.ip_index = cmbListennerIp.SelectedIndex; Settings.Default.port = (int)txtListennerPort.Value; Settings.Default.key = txtKey.Text; key = txtKey.Text; bKey = key.Length > 0 ? CryptoAes.KeyToBytes(key, 32) : null; //256-bits bIv = CryptoAes.KeyToBytes(key, 16); //128-bits Settings.Default.stamp_enable = srv_stamp.chkEnable.Checked; Settings.Default.uvnc_enable = srv_uvnc.chkEnable.Checked; Settings.Default.uvnc_exe = srv_uvnc.txtExe.Text; Settings.Default.uvnc_para = srv_uvnc.txtParam.Text; Settings.Default.uvnc_pass = CryptoAes.EncryptB64($"3{srv_uvnc.txtPassword.Text}", bKey, bIv); //add salt Settings.Default.mstsc_enable = srv_rdp.chkEnable.Checked; Settings.Default.mstsc_exe = srv_rdp.txtExe.Text; Settings.Default.mstsc_para = srv_rdp.txtParam.Text; Settings.Default.rdp_native_client = chkOverrideWinRdpClient.Checked; Settings.Default.rdp_user = srv_rdp.txtUsername.Text; Settings.Default.rdp_pass = CryptoAes.EncryptB64($"9{srv_rdp.txtPassword.Text}", bKey, bIv); //add salt Settings.Default.pse_enable = srv_pse.chkEnable.Checked; Settings.Default.pse_exe = srv_pse.txtExe.Text; Settings.Default.pse_para = srv_pse.txtParam.Text; Settings.Default.pse_user = srv_pse.txtUsername.Text; Settings.Default.pse_pass = CryptoAes.EncryptB64($"6{srv_pse.txtPassword.Text}", bKey, bIv); //add salt Settings.Default.winbox_enable = srv_winbox.chkEnable.Checked; Settings.Default.winbox_exe = srv_winbox.txtExe.Text; Settings.Default.winbox_para = srv_winbox.txtParam.Text; Settings.Default.winbox_user = srv_winbox.txtUsername.Text; Settings.Default.winbox_pass = CryptoAes.EncryptB64($"8{srv_winbox.txtPassword.Text}", bKey, bIv); //add salt Settings.Default.Save(); }
private void Connect() { string key = Settings.Default.key; byte[] bKey = key.Length > 0 ? CryptoAes.KeyToBytes(key, 32) : null; //256-bits byte[] bIv = CryptoAes.KeyToBytes(key, 16); string username = Settings.Default.rdp_user; string password = CryptoAes.DecryptB64(Settings.Default.rdp_pass, bKey, bIv).Substring(1); mstsc.Server = target; mstsc.UserName = username; IMsTscNonScriptable sec = (IMsTscNonScriptable)mstsc.GetOcx(); sec.ClearTextPassword = password; mstsc.DesktopWidth = this.ClientSize.Width; mstsc.DesktopHeight = this.ClientSize.Height; try { mstsc.Connect(); } catch { } }
private static bool LoadConfig() { if (!File.Exists(Strings.FILE_CONFIG)) { return(false); } List <string> httpPrefixes = new List <string>(); List <string> abPrefixes = new List <string>(); StreamReader fileReader = new StreamReader(Strings.FILE_CONFIG); string line; while ((line = fileReader.ReadLine()) != null) { line = line.Trim(); if (line.StartsWith("#")) { continue; } string[] split = line.Split('='); if (split.Length < 2) { continue; } split[0] = split[0].Trim().ToLower(); split[1] = split[1].Trim(); switch (split[0]) { case "db_key": DB_KEY = split[1]; DB_KEY_A = DB_KEY.Length > 0 ? CryptoAes.KeyToBytes(DB_KEY, 32) : null; //256-bits DB_KEY_B = DB_KEY.Length > 0 ? CryptoAes.KeyToBytes(DB_KEY, 16) : null; //128-bits break; case "preshared_key": PRESHARED_KEY = split[1]; PRESHARED_KEY_A = PRESHARED_KEY.Length > 0 ? CryptoAes.KeyToBytes(PRESHARED_KEY, 32) : null; //256-bits PRESHARED_KEY_B = PRESHARED_KEY.Length > 0 ? CryptoAes.KeyToBytes(PRESHARED_KEY, 16) : null; //128-bits break; case "force_registry_keys": force_registry_keys = (split[1] == "true"); break; case "http_enable": http_enable = (split[1] == "true"); break; case "http_prefix": httpPrefixes.Add(split[1].Trim()); break; case "addressbook_enable": addressbook_enable = (split[1] == "true"); break; case "addressbook_prefix": abPrefixes.Add(split[1].Trim()); break; case "ip_access": Session.ip_access.Add(split[1], null); break; } } fileReader.Close(); if (httpPrefixes.Count > 0) { http_prefixes = httpPrefixes.ToArray(); } if (abPrefixes.Count > 0) { addressbook_prefixes = abPrefixes.ToArray(); } return(true); }
public void LoadSettings() { int index = Settings.Default.ip_index; if (index > -1) { cmbListennerIp.SelectedIndex = index; } txtListennerPort.Value = Settings.Default.port; txtKey.Text = Settings.Default.key; key = txtKey.Text; bKey = key.Length > 0 ? CryptoAes.KeyToBytes(key, 32) : null; //256-bits bIv = CryptoAes.KeyToBytes(key, 16); //128-bits srv_stamp.chkEnable.Checked = Settings.Default.stamp_enable; srv_uvnc.chkEnable.Checked = Settings.Default.uvnc_enable; srv_uvnc.txtExe.Text = Settings.Default.uvnc_exe; srv_uvnc.txtParam.Text = Settings.Default.uvnc_para; srv_uvnc.txtPassword.Text = CryptoAes.DecryptB64(Settings.Default.uvnc_pass, bKey, bIv); if (srv_uvnc.txtPassword.Text.Length > 0) //remove salt { srv_uvnc.txtPassword.Text = srv_uvnc.txtPassword.Text.Substring(1); } srv_rdp.chkEnable.Checked = Settings.Default.mstsc_enable; srv_rdp.txtExe.Text = Settings.Default.mstsc_exe; srv_rdp.txtParam.Text = Settings.Default.mstsc_para; srv_rdp.txtUsername.Text = Settings.Default.rdp_user; srv_rdp.txtPassword.Text = CryptoAes.DecryptB64(Settings.Default.rdp_pass, bKey, bIv); if (srv_rdp.txtPassword.Text.Length > 0) //remove salt { srv_rdp.txtPassword.Text = srv_rdp.txtPassword.Text.Substring(1); } srv_pse.txtExe.Text = Settings.Default.pse_exe; srv_pse.txtParam.Text = Settings.Default.pse_para; srv_pse.txtUsername.Text = Settings.Default.pse_user; srv_pse.txtPassword.Text = CryptoAes.DecryptB64(Settings.Default.pse_pass, bKey, bIv); if (srv_pse.txtPassword.Text.Length > 0) //remove salt { srv_pse.txtPassword.Text = srv_pse.txtPassword.Text.Substring(1); } srv_winbox.txtExe.Text = Settings.Default.winbox_exe; srv_winbox.txtParam.Text = Settings.Default.winbox_para; srv_winbox.txtUsername.Text = Settings.Default.winbox_user; srv_winbox.txtPassword.Text = CryptoAes.DecryptB64(Settings.Default.winbox_pass, bKey, bIv); if (srv_winbox.txtPassword.Text.Length > 0) //remove salt { srv_winbox.txtPassword.Text = srv_winbox.txtPassword.Text.Substring(1); } chkOverrideWinRdpClient.Checked = Settings.Default.rdp_native_client; }