8

I want to read data as string from .db.crypt file Is there any lib or method to decrypt data from this file ?

If Yes then kindly point me in direction or provide any sample.

Lucifer
  • 29,392
  • 25
  • 90
  • 143
Noman
  • 4,049
  • 10
  • 38
  • 59
  • Downvote, not by me, But I think it is because you are directly asking a readymade code. You should show some effort. – Lucifer Mar 10 '14 at 12:10
  • @Kedarnath.. i did .. infact i am doing !! Now mind has stopped so i need some direction or help :) – Noman Mar 10 '14 at 12:11
  • 3
    Take a deep breath... You should add some of your effort code while asking the question. Also error if any. – Lucifer Mar 10 '14 at 12:28
  • This question appears to be off-topic because it shows no prior research nor minimal understanding of the problem being solved – Marcin Orlowski Mar 10 '14 at 12:38
  • Presumably, the point of an encrypted database is that you *can't* read it, unless you have the tool and key which are supposed to be used to do so. Figure out where it came from, and that will probably point back to the tool that should be used - if it is something you are intended to be able to do. – Chris Stratton Mar 10 '14 at 13:44
  • this will help you to crack any .db.crypt database http://forum.xda-developers.com/showthread.php?t=1583021 – Kodr.F Mar 11 '14 at 02:57
  • @Kedarnath... see this http://stackoverflow.com/questions/22551704/android-whatsapp-db-file-decrypt – Noman Mar 21 '14 at 09:27
  • @MarcinOrlowski.. now see this.. hope you wont say again "off topic" !! – Noman Mar 21 '14 at 09:27
  • http://stackoverflow.com/questions/22551704/android-whatsapp-db-file-decrypt @MarcinOrlowski – Noman Mar 21 '14 at 09:50

2 Answers2

1

I have done this by using following code:

public void copyDbToSdcard()
{
    try
    {
        String comando = "cp -r /data/data/com.whatsapp/databases/msgstore.db /sdcard/My_Custom_Folder/";
        Process suProcess = Runtime.getRuntime().exec("su");
        DataOutputStream os = new DataOutputStream(suProcess.getOutputStream());
        os.writeBytes(comando + "\n");
        os.flush();
        os.writeBytes("exit\n");
        os.flush();
        try
        {
            int suProcessRetval = suProcess.waitFor();
            if(255 != suProcessRetval)
            {
                //
            }
            else
            {
                //
            }
        }
        catch (Exception ex)
        {
            Log.e("ERROR-->", ex.toString());
        }
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
}  


    private void openAndQueryDatabase()
{
    try
    {
        DataBaseHelper dbHelper = new DataBaseHelper(this.getApplicationContext());
        newDB = dbHelper.getWritableDatabase();

        Cursor c = newDB.rawQuery("SELECT data FROM messages where data!=''", null);

        if(c != null)
        {
            if(c.moveToFirst())
            {
                do
                {

                    String data = c.getString(c.getColumnIndex("data"));

                    results.add(data); //adding to arrayList

                }
                while (c.moveToNext());
            }
        }

                while (c3.moveToNext());
            }
        }
    }

    catch (SQLiteException se)
    {
        Log.e(getClass().getSimpleName(), "Could not create or Open the database");
    }
}  

And then display results in your TextView or whereever you want.

Cheers !! :)

Noman
  • 4,049
  • 10
  • 38
  • 59
0

I think .db.crypt is just a suffix defined by someone. For example, I can make a text file and name it abc.db.crypt. So you can not do anything just by knowing the suffix.

But sometimes the suffix is a clue to find the way to your solution. I guess this file is a database file which has been encrypted first. So what you need to do is to find the encrypt method(maybe DES or some algorithm just defined by the author), decrypt the file to a database file(xxx.db) and then use sqlite3 to get data from it.

twlkyao
  • 14,302
  • 7
  • 27
  • 44
tianwei
  • 1,859
  • 1
  • 15
  • 24
  • encrypted cannot be read by sqlite3 directly its need python to crack the information and extract first – Kodr.F Mar 11 '14 at 02:56
  • I said this xxx.db.crypt need to be decrypted to a .db file ,not use sqite3 to read directly . – tianwei Mar 11 '14 at 02:58
  • See this and if you get any clue then help: http://stackoverflow.com/questions/22551704/android-whatsapp-db-file-decrypt – Noman Mar 21 '14 at 09:27