Beruflich Dokumente
Kultur Dokumente
cmanios
Developer life is a NullPointerException
Today I wanted to extract the SMS content out of the android SMS application SQLite database using ADB.
NOTE: The whole procedure was tested on a rooted phone running Cyanogenmod Android. It may not work
on unrooted phones
So I achieved that , using the following steps:
1. Find SMS database file location
2. Pull SQLite database file with ADB
3. Identify sms tables
4. Identify the thread _ID of the SMS you want to read
5. Find all sms messages for a specific thread id
In detail:
1. Find SMS database file location
After some searching I found that the location of sms database file is in
/data/data/com.android.providers.telephony/databases/mmssms.db
Now the whole sms database is copied locally in your working directory!
3. Identify sms tables
Open the SQLite using command line or your favourite SQLite editor. The tables in which the android
telephony application stores SMS messages are threads and sms.
Table Threads stores a record as a header for every SMS thread which is started:
https://cmanios.wordpress.com/2013/10/29/read-sms-directly-from-sqlite-database-in-android/
1/7
14/07/2015
Table SMS stores all outgoing and incoming messages for every thread:
https://cmanios.wordpress.com/2013/10/29/read-sms-directly-from-sqlite-database-in-android/
2/7
14/07/2015
+---------------------------------------------------------------------------------------------------------| date
| date_sent
| person
| body
|---------------------------------------------------------------------------------------------------------| 2013-10-20 13:48:18 | 2013-10-20 13:48:16 | 54
| Hello Christos! How are you?
| 2013-10-20 16:34:03 | 1970-01-01 02:00:00 |
| Fine, thanks ! I configure the left MFD of a F| 2013-10-20 16:40:02 | 2013-10-20 16:40:01 | 54
| Awesome! I am throwing a party tomorrow at 21:4
| 2013-10-20 17:15:15 | 1970-01-01 02:00:00 |
| Thanks! I will be there!
+----------------------------------------------------------------------------------------------------------
Note that person with id 54 is my friend Kitsos and person = NULL is me!
Good luck tampering and hacking with your Android device !
About these ads
Share t his:
Like
Be the first to like this.
Relat ed
About cmanios
programming
View all posts by cmanios
This entry was posted in Android, Databases, Linux, SQLite and tagged adb, android, cyanogenmod, database, file, linux, location, root, shell, sms, sqlite, telephony, thread.
Bookmark the permalink.
https://cmanios.wordpress.com/2013/10/29/read-sms-directly-from-sqlite-database-in-android/
3/7
14/07/2015
hello i need to urgent get back some sms i don know this sql. can u help me i can send u file or something..
Reply
Tomaz says:
January 12, 2014 at 14:02
cmanios says:
January 12, 2014 at 19:42
@Tomaz You can backup your sms database easily with an application like
https://play.google.com/store/apps/details?id=com.riteshsahu.SMSBackupRestore. However if you want you
may send me your database.
Reply
Tob says:
January 20, 2014 at 11:15
cmanios says:
January 20, 2014 at 11:47
Tob I assume that you have attached your phone to a Windows operating system. I am not sure if accessing your
files via explorer.exe is done using root user with admin privileges. I suggest that you use ADB or a root file
explorer.
Reply
Tob says:
January 21, 2014 at 11:19
Thank you! I found it with root explorer. The problem now is that the database only have a few records
visible in the sms table. I know that at least 100 sms has been deleted. Is there anyway to get them back or
they just dont exist anymore if not visible in the sms table?
cmanios says:
February 15, 2014 at 12:52
I am afraid that you need digital forensics software to view deleted files in your phone storage.
https://cmanios.wordpress.com/2013/10/29/read-sms-directly-from-sqlite-database-in-android/
4/7
14/07/2015
kundan says:
May 21, 2015 at 08:41
hello i have made an application that send sms to customer, now the problem is that i am using samsung tablet model
number GT-N8000 when i send sms from application it store the sms in inbox of tablet where we can see the sms
now i did not want to store or want to see that sms in inbox. Can you just help me out how to hide sms from inbox.
and i am using kitkat 4.4.2 version.
Reply
Hello! Ive been trying to write an app on Android that saves incoming SMS (sender, content and time) in an SQLite database
and replies based on the content and sender of the message with predefined answers. Unfortunately, I havent been able to
make it work as it gets stuck on accessing the database. I have written up my question in more detail with a copy of my code
on stack overflow and I was wondering if you could help me out. Heres the link:
http://stackoverflow.com/questions/25604039/how-to-update-sqlite-database-when-receiving-sms
Thanks!
Reply
cmanios says:
September 17, 2014 at 23:43
Demetris, I am afraid that your question is irrelevant to this blog post. When you want to access Contacts
programmatically in your application you should use Contacts Provider. Also the error you have in yout
StackOverflow post cannot help as there is nothing but a custom log message. You should post the actual
Exceptions or stacktrace in order to be comprehensible.
Reply
Tharun says:
October 27, 2014 at 07:15
I am creating a Kiosk based application on my rooted android tablet.One functionality is to reboot the device remotely by
sending an SMS,which is working fine.However,I observe that the phone reboots exactly after 30 min intervals and
thereafter for a couple of times.(This reboot functionality when triggered using GCM/phone call works fine and doesnt reboot
later,as expected).So i suspect that when I reboot using SMS,the SMS module is firing some notifications after 30 min interval
which is causing the erratic reboots.Could it be due to the messages not being marked as read? Anyhow I think I can solve
this if I can delete messages from the core android message storage.How can I achieve this ? Iv searched online but no good
results.Kindly assist .
Reply
cmanios says:
October 28, 2014 at 14:31
1. I am quite puzzled.. Do you want to reboot your tablet every 30 minutes after the first reboot which was fired by
the SMS BroadcastReceiver?
https://cmanios.wordpress.com/2013/10/29/read-sms-directly-from-sqlite-database-in-android/
5/7
14/07/2015
2. Are you sure that the reboots are caused by your application and not from the tablet itself?
3. Can you provide more details about your implementation or code extracts ?
Note that my example describes raw access to SMS Sqlite database via shell (cli) and not from an Android
ApplicationContext.
Reply
George says:
January 19, 2015 at 21:50
Hi, I looked in the location you said but my root data directory contains nothing. I have texts visible in the app so there should
be something but data/data doesnt even exist. Is there any other location they could be found at to your knowledge?
Im on a Nexus 4, Cyanogenmod.
Its driving me crazy, nobody online seems to give an answer that is true for me! Thanks.
Reply
cmanios says:
January 21, 2015 at 22:45
It seems to me that you have a permission issue. You possibly do not have root access. Try to access / directory
with a superuser application or via terminal running
su
command before
ls -l /data/data
.
Reply
kundan says:
May 21, 2015 at 08:46
hello i have made an application that send sms to customer, now the problem is that i am using samsung tablet model number
GT-N8000 when i send sms from application it store the sms in inbox of tablet where we can see the sms now i did not want
to store or want to see that sms in inbox. Can you just help me out how to hide sms from inbox. and i am using kitkat 4.4.2
version.
Reply
cmanios says:
June 3, 2015 at 08:11
6/7
14/07/2015
1. Follow my steps in a rooted phone and delete or move messages from sms database.
2. Use SMS Content Provider like in this example and delete or move messages.
I do not know if there is a way to hide them. You may want to move them to another database.
Reply
cmanios
The Twenty Ten Theme.
Blog at WordPress.com.
https://cmanios.wordpress.com/2013/10/29/read-sms-directly-from-sqlite-database-in-android/
7/7