1

I have a Sqlite database file that has blob data in it. I only know the the database has blob data and I know what the expected output should be. The blob data's expected output should be a Mac address with other text.

I tried getting the hex output but does not really help me with getting the expected output that I know is in the database. I also used a Hex editor and sqlite viewer but only shows gibberish unreadable text.

Here is some code that I tried to get the bytes from the blob data but does not produce the output I expected. Sqlite doesn't have the getBlob function in Java.

if (rs.next()) {
    byte[] buffer = rs.getBytes(1);
    System.out.println(buffer.toString());
}

An expected output from the blob should be :" JOHN A6:44:33:A4:G5:A4 "

Here is a sample Hex dump 0008f473eb41 e8ba3b1c

How can I programattically retrieve the blob data and decode the contents of the blob in sqlite?

1 Answers1

0

Right now you are printing a byte[] array toString(). Arrays in Java don't implement in meaningful way.

You can try converting the byte[] array into a String with:

new String(buffer, Charsets.UTF_8)

If this doesn't work use rs.getBinaryStream(1) to get the InputStream representing the value and read it as per this answer.

Karol Dowbecki
  • 43,645
  • 9
  • 78
  • 111
  • Thanks for the fast reply but the output is still the same : This is the output from converting to string –v$%^KJ%^³‚W *Ôô – John Marshall Apr 17 '19 at 14:37
  • If you don't show how the value is stored I can only guess how to read it. – Karol Dowbecki Apr 17 '19 at 14:39
  • Yeah, I am reverse engineering and don't know how the value is stored. If I knew how it was stored, it would be fairly easy. I only know that it is a blob and that within that blob there should be a Mac address and text in there. – John Marshall Apr 17 '19 at 14:42
  • @JohnMarshall try different encodings from `Charsets` class and maybe one of them will solve the problem. – Karol Dowbecki Apr 17 '19 at 14:58
  • @KarolDowbecki can you please look into this?https://stackoverflow.com/questions/62016074/decode-the-blob-using-java – Gen May 26 '20 at 08:08