Read Skype Data: Chatsync and SQLite
Recently I made some research regarding the way Skype stores the conversation's log. I was nicely surprised that the chat data on the user's computer stored in a very simple form.
The data stored by Skype (I have version 4.2.0.169) seems to be stored in two places and in two completely different formats (btw: does anybody know why? kind of "backward compatibility"?):
- .dat files in the \chatsync folder
- SQLite database files (the interesting file: main.db)
So to access the data we need either to read it from the .dat binaries or open the database files with any SQL frontend. Simple.
1. Accessing data from the .dat files
There are plenty of Skype log readers around in Internet, but why not to try to write my own tool in such beautiful summer evening! :)
All right, so what kind of files and data we are dealing with? All conversations are stored in \chatsync folder where you have many subfolders with binary .dat files inside. Each .dat file basically is a new conversation.
So if we want to get all messages exchanged in between User 1 and User 2 we have to:
- Create one big list of all files in all subfolders and sort them by timestamp.
- Read conversation id from each .dat file (it is in a fixed offset 0x35 at the very beginning of each file).
- Create sorted list of all conversations between the pair of users (User 1 <-> User 2) and (User 2 <-> User 1).
- Read chat messages from every .dat file on such "dedicated list" and store it somewhere.
How to retrieve messages? Each chat message starts from the prefix (0x03 0x02) and ends with the null byte (0x00).
I am quite far from the idea to do a complete reverse engineering of the .dat files, but below you may find a small proof of concept (see the binary file and the source code in Delphi). When you run the application you have to provide the full path to your \chatsync folder. Here how it looks like:
The program can collect a data when the Skype is running. FYI: some of the .dat files may be locked by Skype, so the correct way to open it (in read only mode) is:
fs := TFileStream.Create(chatSyncFName, fmOpenRead or fmShareDenyNone);
If you'd modify the source code a little and track the changes in those files (e.g.: by monitoring datetime stamp) - you can basically write a Skype conversations sniffer in an hour or so. ;)
2. Accessing SQLite database files
This is even more easy: locate the "main.db" file and open it with SQLite editor (e.g.: SQLIte Spy is good enough). Now you have very nice and elegant way to do whatever you want with the data by executing appropriate SQL query:









August 12th, 2010 - 06:21
Hi.
I wrote a comment yesterday (I think), but can see, that the comment hasn’t been approved yet (Either that, or I just f****d up when commenting :-))
Just to make sure here it is again:
I work for the danish national computer crime unit and would really like to talk to you regarding this excellent script you have written. It finds things, that the other readers only parse the Main.db (Except for 1, that cost 500$)
Now. I know a bit of EnScript (No not that… A language written for the program EnCase, that is similar to java and c++.) But I cannot understand delphi.
Is there any way to talk to you about your findings?
December 7th, 2010 - 16:49
I would like to open .dat files that appear to be locked. However, I do not know anything about writing or using code. Using your reader, is there a way that I could unlock these files? Or could you tell me what I can do to read them?
Thanks
December 8th, 2010 - 07:31
Well, try to close the Skype first as it often has exclusive access to a certain files. Then please follow the instructions for the Skype reader. :)
December 8th, 2010 - 16:24
Still unable to read files. I only see a time and date stamp. I cannot see the enitire conversation.
February 13th, 2011 - 08:22
i have the same probleme !! please help!
February 13th, 2011 - 15:36
Let me remind you once again, that conversations written in unicode are NOT supported now. As soon as this functionality will be available – it will be immediately introduced here! :)
February 24th, 2011 - 10:45
unicode will save me! or even a way to convert the dat file to text that i can read unicode in notepad++
thanks
May 15th, 2011 - 00:25
I put the maind.db folder on sqlitespy but it doesn’t come out liek yours it has all these codes…
June 10th, 2011 - 22:08
Where to download this software??? PLS…